[Python-bugs-list] [ python-Bugs-603937 ] Exception during _PyString_Resize
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 03 Sep 2002 06:55:43 -0700
Bugs item #603937, was opened at 2002-09-03 13:28
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=603937&group_id=5470
Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Walter Dörwald (doerwalter)
Summary: Exception during _PyString_Resize
Initial Comment:
I *think* this is related to the newly mortal string interning (or maybe
to the recent changes Walter Dörwald checked in. I'll start with
Walter. ;-)
The attached little zipfile contains a trivial module (serverdir.py) and
an ASCII pickle (foo.dat) which has not changed for a couple years.
Today, I noticed that Python began barfing during startup (this
particular pickle gets read in as a side effect of my rather heavyweight
interactive initialization stuff). In a python -S session, if I execute:
import pickle
o = pickle.Unpickler(open("foo.dat")).load()
I get the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/pickle.py", line 674, in load
dispatch[key](self)
File "/usr/local/lib/python2.3/pickle.py", line 753, in load_string
self.append(rep.decode("string-escape"))
SystemError: ../Objects/stringobject.c:3268: bad argument to
internal function
Line 3268 in stringobject.c is in _PyString_Resize.
----------------------------------------------------------------------
>Comment By: Walter Dörwald (doerwalter)
Date: 2002-09-03 15:55
Message:
Logged In: YES
user_id=89016
Checked in as:
Lib/test/test_codecs.py 1.4
Objects/stringobject.c 2.187
----------------------------------------------------------------------
Comment By: Walter Dörwald (doerwalter)
Date: 2002-09-03 15:11
Message:
Logged In: YES
user_id=89016
This is a problem with PyString_DecodeEscape, not with the
PEP293 patch. The simplest test case is the following:
>>> import codecs
>>> codecs.escape_decode('') # empty string
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SystemError: Objects/stringobject.c:3268: bad argument to
internal function
PyString_DecodeEscape tries to resize the empty string
(which it got from PyString_FromStringAndSize(..., 0)) to
the length 0, which fails, because this empty string has
more than one reference. Checking whether a resize is
neccessary fixes this bug. I'll check in the fix and a test
case for it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=603937&group_id=5470