summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-20 21:19:14 (GMT)
committerBrett Cannon <brett@python.org>2012-04-20 21:19:14 (GMT)
commit5d5296d36e7be54141f06e79c4ab90a1ccde8544 (patch)
tree7f5abc5709cab118d6a450a378b51afa927bd195 /Lib
parentbbdc9cd3d2cbdc2cc64d2945da175bdc18a93ce3 (diff)
parent9a359bd97f5fc0ab3ae830ad874eda6e5e76b14c (diff)
downloadcpython-5d5296d36e7be54141f06e79c4ab90a1ccde8544.zip
cpython-5d5296d36e7be54141f06e79c4ab90a1ccde8544.tar.gz
cpython-5d5296d36e7be54141f06e79c4ab90a1ccde8544.tar.bz2
Merge
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_long.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 05b3e3e..b417bea 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -1228,6 +1228,20 @@ class LongTest(unittest.TestCase):
self.assertRaises(TypeError, myint.from_bytes, 0, 'big')
self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
+ def test_access_to_nonexistent_digit_0(self):
+ # http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that
+ # ob_digit[0] was being incorrectly accessed for instances of a
+ # subclass of int, with value 0.
+ class Integer(int):
+ def __new__(cls, value=0):
+ self = int.__new__(cls, value)
+ self.foo = 'foo'
+ return self
+
+ integers = [Integer(0) for i in range(1000)]
+ for n in map(int, integers):
+ self.assertEqual(n, 0)
+
def test_main():
support.run_unittest(LongTest)