This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_unicode.test_raiseMemError fails in UCS4
Type: behavior Stage:
Components: Tests Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pitrou Nosy List: benjamin.peterson, pitrou
Priority: high Keywords: needs review, patch

Created on 2008-08-19 15:42 by benjamin.peterson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
memerror2.patch pitrou, 2008-08-23 19:46
Messages (6)
msg71429 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 15:42
======================================================================
ERROR: test_raiseMemError (test.test_unicode.UnicodeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/temp/python/trunk/Lib/test/test_unicode.py", line 1122, in
test_raiseMemError
    self.assertRaises(MemoryError, alloc)
  File "/temp/python/trunk/Lib/unittest.py", line 336, in failUnlessRaises
    callableObj(*args, **kwargs)
  File "/temp/python/trunk/Lib/test/test_unicode.py", line 1121, in <lambda>
    alloc = lambda: u"a" * (sys.maxsize - 100)
OverflowError: repeated string is too long

----------------------------------------------------------------------
msg71433 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-19 16:02
Ok, please disable the test for now, I have more important things to do
for the beta :)
msg71434 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 16:03
Oh. Sorry, I didn't mean to assign it to you anyway.
msg71436 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-19 16:07
(the fix is probably trivial, it involves dividing sys.maxsize by the number of
bytes of an unicode character, something like:

    width = sys.getsizeof("a") - sys.getsizeof("")
    alloc = lambda: u"a" * (sys.maxsize // width)
    self.assertRaises(MemoryError, alloc)
    self.assertRaises(MemoryError, alloc)

you can give it a try if you want ;-))
msg71809 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-23 19:46
This patch is ok on both UCS2 and UCS4 builds (on 32-bit machines).
Someone should test it on a 64-bit machine.
msg72635 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-05 22:13
Fixed in r66235, r66236.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47851
2008-09-05 22:13:28pitrousetstatus: open -> closed
resolution: fixed
messages: + msg72635
2008-08-23 19:46:26pitrousetkeywords: + patch, needs review
files: + memerror2.patch
messages: + msg71809
2008-08-21 14:11:34pitrousetassignee: pitrou
2008-08-19 16:07:59pitrousetmessages: + msg71436
2008-08-19 16:03:56benjamin.petersonsetassignee: pitrou -> (no value)
messages: + msg71434
2008-08-19 16:02:36pitrousetpriority: critical -> high
type: behavior
messages: + msg71433
components: + Tests
versions: + Python 2.6, Python 3.0
2008-08-19 15:42:05benjamin.petersoncreate