Patchwork [5,of,8] py3: work around the lack of sys.maxint in contrib/perf

login
register
mail settings
Submitter Matt Harbison
Date Sept. 22, 2018, 3:28 p.m.
Message ID <eee31df781ee594ac9fa.1537630121@Envy>
Download mbox | patch
Permalink /patch/34919/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 22, 2018, 3:28 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1537575373 14400
#      Fri Sep 21 20:16:13 2018 -0400
# Node ID eee31df781ee594ac9fa82e34014790792c927c1
# Parent  04f33f6d0d4ab3006dd83b26c70a61ceee66a720
py3: work around the lack of sys.maxint in contrib/perf

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1888,7 +1888,7 @@  def perflrucache(ui, mincost=0, maxcost=
 
     values = []
     for i in pycompat.xrange(size):
-        values.append(random.randint(0, sys.maxint))
+        values.append(random.randint(0, pycompat.maxint))
 
     # Get mode fills the cache and tests raw lookup performance with no
     # eviction.
@@ -1919,7 +1919,7 @@  def perflrucache(ui, mincost=0, maxcost=
     setseq = []
     costs = []
     for i in pycompat.xrange(sets):
-        setseq.append(random.randint(0, sys.maxint))
+        setseq.append(random.randint(0, pycompat.maxint))
         costs.append(random.choice(costrange))
 
     def doinserts():
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -128,6 +128,7 @@  if ispy3:
     getargspec = inspect.getfullargspec
 
     long = int
+    maxint = sys.maxsize  # per py3 docs for replacing maxint
 
     # TODO: .buffer might not exist if std streams were replaced; we'll need
     # a silly wrapper to make a bytes stream backed by a unicode one.
@@ -346,6 +347,7 @@  else:
     byterepr = repr
     bytestr = str
     iterbytestr = iter
+    maxint = sys.maxint
     maybebytestr = identity
     sysbytes = identity
     sysstr = identity