[Python-3000] MemoryError oddities

Guido van Rossum guido at python.org
Wed Jul 30 02:05:13 CEST 2008


Did anyone come up with a fix for these?

It's true that OverflowError and MemoryError are returned pretty
randomly when we detect that an allocation is not going to fit. I
think MemoryError is better though, so perhaps those uses of
OverflowError should be fixed. I doubt that there are any apps (except
unit tests for this specific feature) that depend on such specific
errors.

On Mon, Jul 21, 2008 at 11:26 AM, Georg Brandl <g.brandl at gmx.net> wrote:
> In a debug-build 3k, do this (32-bit machine):
>
> Python 3.0b2+ (py3k:65171M, Jul 21 2008, 20:08:20)
> [GCC 4.2.4 (Gentoo 4.2.4 p1.0)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> "a"*1000000000
> instinstTraceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41296 refs]
>>>> "a"*1000000000
> inst[1]    21400 segmentation fault  ./python
>
> Here, something fishy is probably going on in the unicode free list.
> Compare with 2.6:
>
> Python 2.6b2+ (trunk:65131:65163M, Jul 21 2008, 19:58:07)
> [GCC 4.2.4 (Gentoo 4.2.4 p1.0)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> u"a"*1000000000
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> MemoryError
> [34330 refs]
>>>> u"a"*1000000000
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> MemoryError
> [34332 refs]
>
> Still, the refcount seems to leak.
>
> Also:
>
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41297 refs]
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41317 refs]
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41337 refs]
>
> This probably has to do with the fact that this MemoryError is a prebuilt
> instance.
>
> Finally:
>
>>>> "a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> OverflowError: repeated string is too long
> [41379 refs]
>
> Nothing wrong here, but the exception is a different one.
>
> Georg
>
> --
> Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
> Four shall be the number of spaces thou shalt indent, and the number of thy
> indenting shall be four. Eight shalt thou not indent, nor either indent thou
> two, excepting that thou then proceed to four. Tabs are right out.
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/guido%40python.org
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list