Patchwork [2,of,2,hglib] hglib: don't try to use long under Python 3 (issue4520)

login
register
mail settings
Submitter Brett Cannon
Date March 20, 2015, 8:35 p.m.
Message ID <ef8eb78fc88df516d835.1426883702@bcannon-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/8205/
State Accepted
Headers show

Comments

Brett Cannon - March 20, 2015, 8:35 p.m.
# HG changeset patch
# User Brett Cannon <brett@python.org>
# Date 1426883682 14400
#      Fri Mar 20 16:34:42 2015 -0400
# Node ID ef8eb78fc88df516d835d4ab532807aee4d0e82f
# Parent  0808bb03add5fe4f264ac90926f64b3ca6b75730
hglib: don't try to use long under Python 3 (issue4520)
Matt Mackall - March 23, 2015, 7:40 p.m.
On Fri, 2015-03-20 at 16:35 -0400, Brett Cannon wrote:
> # HG changeset patch
> # User Brett Cannon <brett@python.org>
> # Date 1426883682 14400
> #      Fri Mar 20 16:34:42 2015 -0400
> # Node ID ef8eb78fc88df516d835d4ab532807aee4d0e82f
> # Parent  0808bb03add5fe4f264ac90926f64b3ca6b75730
> hglib: don't try to use long under Python 3 (issue4520)

These are pushed, thanks.

Patch

diff -r 0808bb03add5 -r ef8eb78fc88d hglib/context.py
--- a/hglib/context.py	Fri Mar 20 16:32:53 2015 -0400
+++ b/hglib/context.py	Fri Mar 20 16:34:42 2015 -0400
@@ -1,7 +1,7 @@ 
 import hglib.client  # Circular dependency.
 from hglib import util, templates
 from hglib.error import CommandError
-from hglib.util import b, strtobytes
+from hglib.util import b, strtobytes, integertypes
 
 _nullcset = [b('-1'), b('0000000000000000000000000000000000000000'), b(''),
              b(''), b(''), b(''), b('')]
@@ -19,7 +19,7 @@ 
         elif changeid == -1:
             cset = _nullcset
         else:
-            if isinstance(changeid, (long, int)):
+            if isinstance(changeid, integertypes):
                 changeid = b('rev(') + strtobytes(changeid) + b(')')
 
             notfound = False
diff -r 0808bb03add5 -r ef8eb78fc88d hglib/util.py
--- a/hglib/util.py	Fri Mar 20 16:32:53 2015 -0400
+++ b/hglib/util.py	Fri Mar 20 16:34:42 2015 -0400
@@ -7,12 +7,14 @@ 
 
 if sys.version_info[0] > 2:
     izip = zip
+    integertypes = (int,)
 
     def b(s):
         """Encode the string as bytes."""
         return s.encode('latin-1')
 else:
     from itertools import izip
+    integertypes = (long, int)
 
     def b(s):
         """Encode the string as bytes."""