[pypy-commit] pypy py3.6: hg merge py3.5
mjacob
pypy.commits at gmail.com
Mon Mar 19 18:23:19 EDT 2018
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.6
Changeset: r94018:845ecbcca6b6
Date: 2018-03-19 23:22 +0100
http://bitbucket.org/pypy/pypy/changeset/845ecbcca6b6/
Log: hg merge py3.5
diff --git a/lib-python/3/distutils/msvc9compiler.py b/lib-python/3/distutils/msvc9compiler.py
--- a/lib-python/3/distutils/msvc9compiler.py
+++ b/lib-python/3/distutils/msvc9compiler.py
@@ -243,7 +243,7 @@
productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
productdir = os.path.abspath(productdir)
if not os.path.isdir(productdir):
-
+
log.debug("%s is not a valid directory" % productdir)
return None
else:
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -15,6 +15,7 @@
from rpython.rlib.listsort import make_timsort_class
from rpython.rlib.objectmodel import (
import_from_mixin, instantiate, newlist_hint, resizelist_hint, specialize)
+from rpython.rlib.rarithmetic import ovfcheck
from rpython.rlib import longlong2float
from rpython.tool.sourcetools import func_with_new_name
@@ -848,7 +849,12 @@
"""Extend w_list from a generic iterable"""
length_hint = self.space.length_hint(w_iterable, 0)
if length_hint:
- w_list._resize_hint(w_list.length() + length_hint)
+ try:
+ newsize_hint = ovfcheck(w_list.length() + length_hint)
+ except OverflowError:
+ pass
+ else:
+ w_list._resize_hint(newsize_hint)
extended = _do_extend_from_iterable(self.space, w_list, w_iterable)
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -618,6 +618,18 @@
assert l == [1.2, 2.3, 3.4, 4.5]
assert l is l0
+ def test_extend_iterable_length_hint_overflow(self):
+ import sys
+ class CustomIterable(object):
+ def __iter__(self):
+ if False:
+ yield
+ def __length_hint__(self):
+ return sys.maxsize
+ a = [1, 2, 3, 4]
+ a.extend(CustomIterable())
+ assert a == [1, 2, 3, 4]
+
def test_sort(self):
l = l0 = [1, 5, 3, 0]
l.sort()
More information about the pypy-commit
mailing list