summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-03-05 15:37:18 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-03-05 15:37:18 (GMT)
commit8b34e6146145e50cde974cbbfd087838a05871c2 (patch)
tree916dd513b7c5a7b6c4ce600945b07df676ed9297
parent7a4b55ddc09e1a1d3d5120413f8e17db460379bc (diff)
downloadcpython-8b34e6146145e50cde974cbbfd087838a05871c2.zip
cpython-8b34e6146145e50cde974cbbfd087838a05871c2.tar.gz
cpython-8b34e6146145e50cde974cbbfd087838a05871c2.tar.bz2
backport gvanrossum's checkin of
revision 1.115 of test_descr.py SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects Due to the bizarre definition of _PyLong_Copy(), creating an instance of a subclass of long with a negative value could cause core dumps later on. Unfortunately it looks like the behavior of _PyLong_Copy() is quite intentional, so the fix is more work than feels comfortable. This fix is almost, but not quite, the code that Naofumi Honda added; in addition, I added a test case. I haven't quite worked out how to port the fix yet, but the test cases can go straight over.
-rw-r--r--Lib/test/test_descr.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index dd95dde..e667efb 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1748,6 +1748,10 @@ def inherits():
verify((a + 0).__class__ is long)
verify((0 + a).__class__ is long)
+ # Check that negative clones don't segfault
+ a = longclone(-1)
+ vereq(a.__dict__, {})
+
class precfloat(float):
__slots__ = ['prec']
def __init__(self, value=0.0, prec=12):