diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-08-01 01:06:32 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-08-01 01:06:32 (GMT) |
commit | 7888d0803d50fc3716839d0608bdf350cc0e3df4 (patch) | |
tree | 049e70de5450e438a38bb3520d2c8dcb82dae3b5 /Lib | |
parent | e2e36ba69600bf01ab43a003f788dbfab6e27cd1 (diff) | |
download | cpython-7888d0803d50fc3716839d0608bdf350cc0e3df4.zip cpython-7888d0803d50fc3716839d0608bdf350cc0e3df4.tar.gz cpython-7888d0803d50fc3716839d0608bdf350cc0e3df4.tar.bz2 |
Merged revisions 65339-65340,65342 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65339 | amaury.forgeotdarc | 2008-07-31 23:28:03 +0200 (jeu., 31 juil. 2008) | 5 lines
#3479: unichr(2**32) used to return u'\x00'.
The argument was fetched in a long, but PyUnicode_FromOrdinal takes an int.
(why doesn't gcc issue a truncation warning in this case?)
........
r65340 | amaury.forgeotdarc | 2008-07-31 23:35:03 +0200 (jeu., 31 juil. 2008) | 2 lines
Remove a dummy test that was checked in by mistake
........
r65342 | amaury.forgeotdarc | 2008-08-01 01:39:05 +0200 (ven., 01 août 2008) | 8 lines
Correct a crash when two successive unicode allocations fail with a MemoryError:
the freelist contained half-initialized objects with freed pointers.
The comment
/* XXX UNREF/NEWREF interface should be more symmetrical */
was copied from tupleobject.c, and appears in some other places.
I sign the petition.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 1 | ||||
-rw-r--r-- | Lib/test/test_exceptions.py | 8 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 14 |
3 files changed, 15 insertions, 8 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 7a898b2..f8d4ae0 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -216,6 +216,7 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(chr(0x0010FFFF), "\U0010FFFF") self.assertRaises(ValueError, chr, -1) self.assertRaises(ValueError, chr, 0x00110000) + self.assertRaises((OverflowError, ValueError), chr, 2**32) def test_cmp(self): self.assertEqual(cmp(-1, 1), -1) diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index b742fce..95c2dd1 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -12,14 +12,6 @@ from test.support import TESTFN, unlink, run_unittest, captured_output class ExceptionTests(unittest.TestCase): - def test00(self): - try: - sys.exit(ValueError('aaa')) - except SystemExit: - pass - finally: - pass - def raise_catch(self, exc, excname): try: raise exc("spam") diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 604fdf2..fdd90ca 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1156,6 +1156,20 @@ class UnicodeTest( self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) + def test_raiseMemError(self): + # Ensure that the freelist contains a consistent object, even + # when a string allocation fails with a MemoryError. + # This used to crash the interpreter, + # or leak references when the number was smaller. + try: + "a" * (sys.maxsize // 2 - 100) + except MemoryError: + pass + try: + "a" * (sys.maxsize // 2 - 100) + except MemoryError: + pass + def test_main(): support.run_unittest(__name__) |