From 3b40b71217d7b73e59495de8cadd8fe1ad7cc6bc Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 21 Jan 2013 12:59:13 +0200 Subject: [PATCH] Fix memory error in test_ucn. unicode-escape decoder requires memory for result corresponding to input size. Fixes test for issue #16335. --- Lib/test/test_ucn.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py index de36cc366f0..ebff0e1d1aa 100644 --- a/Lib/test/test_ucn.py +++ b/Lib/test/test_ucn.py @@ -148,13 +148,14 @@ class UnicodeNamesTest(unittest.TestCase): # very very long bogus character name try: x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}' + self.assertEqual(len(x), len(b'\\N{SPACE}') + + (_testcapi.UINT_MAX + 1)) + self.assertRaisesRegex(UnicodeError, + 'unknown Unicode character name', + x.decode, 'unicode-escape' + ) except MemoryError: raise unittest.SkipTest("not enough memory") - self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1)) - self.assertRaisesRegex(UnicodeError, - 'unknown Unicode character name', - x.decode, 'unicode-escape' - ) def test_main():