Author: Yannick Jadoul <[email protected]>
Branch: py3.7-bpo-29839
Changeset: r97818:dd823d097737
Date: 2019-10-18 17:30 +0200
http://bitbucket.org/pypy/pypy/changeset/dd823d097737/
Log: First check the result of __len__ for negative values rather before
checking for overflow, implementing bpo-29839
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -267,9 +267,12 @@
def _check_len_result(space, w_obj):
# Will complain if result is too big.
- result = space.getindex_w(w_obj, space.w_OverflowError)
- if result < 0:
+ w_result = space.index(w_obj)
+ assert space.isinstance_w(w_result, space.w_int)
+ if space.unwrap(w_result) < 0:
raise oefmt(space.w_ValueError, "__len__() should return >= 0")
+ result = space.getindex_w(w_result, space.w_OverflowError)
+ assert result >= 0
return result
def is_iterable(space, w_obj):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit