[Python-Dev] cpython (3.2): Issue #16335: Fix integer overflow in unicode-escape decoder. (original) (raw)
Christian Heimes christian at python.org
Mon Jan 21 11:29:45 CET 2013
- Previous message: [Python-Dev] Modules/socketmodule.c: avoiding second fcntl() call worth the effort?
- Next message: [Python-Dev] cpython (2.7): Fix memory error in test_ucn.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 21.01.2013 10:46, schrieb serhiy.storchaka:
http://hg.python.org/cpython/rev/7625866f8127 changeset: 81622:7625866f8127 branch: 3.2 parent: 81610:260a9afd999a user: Serhiy Storchaka <storchaka at gmail.com> date: Mon Jan 21 11:38:00 2013 +0200 summary: Issue #16335: Fix integer overflow in unicode-escape decoder.
files: Lib/test/testucn.py | 16 ++++++++++++++++ Objects/unicodeobject.c | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Lib/test/testucn.py b/Lib/test/testucn.py --- a/Lib/test/testucn.py +++ b/Lib/test/testucn.py @@ -8,6 +8,7 @@ """#" import unittest +import testcapi from test import support @@ -141,6 +142,21 @@ str, b"\NSPACE", 'unicode-escape', 'strict' ) + @unittest.skipUnless(testcapi.INTMAX < testcapi.PYSSIZETMAX, + "needs UINTMAX < SIZEMAX") + def testissue16335(self): + # very very long bogus character name + try: + x = b'\N{SPACE' + b'x' * (testcapi.UINTMAX + 1) + b'}' + except MemoryError: + raise unittest.SkipTest("not enough memory") + self.assertEqual(len(x), len(b'\N{SPACE}') + (testcapi.UINTMAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) + +
The test requires a lot of memory on my 64bit Linux box. Two of three times the test process was killed by the Kernel's out of memory manager although I have 8 GB physical RAM and 4 GB swap. Can you rewrite the test to use less memory?
- Previous message: [Python-Dev] Modules/socketmodule.c: avoiding second fcntl() call worth the effort?
- Next message: [Python-Dev] cpython (2.7): Fix memory error in test_ucn.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]