[Python-bugs-list] [Bug #121013] codecs.StreamReadWriter.writelines method accesses null ptr
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 27 Nov 2000 10:12:17 -0800
Bug #121013, was updated on 2000-Nov-01 10:17
Here is a current snapshot of the bug.
Project: Python
Category: Modules
Status: Open
Resolution: None
Bug Group: None
Priority: 7
Summary: codecs.StreamReadWriter.writelines method accesses null ptr
Details: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.6 -- press F1 for help
>>> import codecs
>>> f = codecs.open("c:\\temp\\junk.txt", "w", "UTF-8")
>>> msg = u"this is a test"
>>> f.writelines(msg)
result:
The instruction at "0x002925a6 referenced memory at "0x00000000". The memory could not be "read".
Follow-Ups:
Date: 2000-Nov-01 11:06
By: lemburg
Comment:
The bug headline is misleading: the bug boils down to
""..join(u"this is a test")
causing a segfault. (Note that you should pass a list to .join()... not
a string.
The cause is the PySequence_Fast_GET_ITEM() macro:
#define PySequence_Fast_GET_ITEM(o, i)\
(PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
... this only works for lists and tuples and not arbitrary sequences like
the name implies.
-------------------------------------------------------
Date: 2000-Nov-01 14:39
By: jhylton
Comment:
I think the cause is whatever uses the PySequence_Fast_GET_ITEM macro (which may have a misleading name).
It looks like it might also be useful to raise an exception when join is passed a string. I think it's more likely to be an error than deliberate.
-------------------------------------------------------
Date: 2000-Nov-27 10:12
By: mwh
Comment:
I hope you're all suitably embarrassed - please see patch #102548 for the trivial fix...
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=121013&group_id=5470