[Csv] Something's fishy...
Skip Montanaro
skip at pobox.com
Mon Feb 3 21:23:46 CET 2003
I rearranged the dialect initialization stuff a bit earlier today, then
started getting segfaults from the interpreter. From gdb I was able to
track it down to what looked like an invalid keyword_args parameter passed
to csv_parser():
(gdb) p args
$1 = (PyObject *) 0x418030
(gdb) pyo args
object : ()
type : tuple
refcount: 1911
address : 0x418030
$2 = void
(gdb) p keyword_args
$3 = (PyObject *) 0xb3b0c0
(gdb) pyo keyword_args
object : {'delimiter': ',', 'escapechar': None, 'lineterminator':
Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x0067d940 in ?? ()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (_PyObject_Dump) will be abandoned.
pyo is a user-defined gdb command:
define pyo
print _PyObject_Dump($arg0)
end
Figuring there was maybe something wrong there, I stuck a print statement in
csv.py:_OCcsv:__init__ just before the last line of the method:
print ">>", parser_options
The segfault went away. I was left with a lot of output and one error:
% python test_csv.py
>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
..>> {'delimiter': '\t', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
...E>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': None, 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 0, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': '\\', 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 3, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': '\\', 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 3, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': '\\', 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 2, 'doublequote': True}
.>> {'delimiter': ',', 'escapechar': '\\', 'lineterminator': '\r\n', 'skipinitialspace': False, 'quotechar': '"', 'quoting': 2, 'doublequote': True}
.
======================================================================
ERROR: test_register (__main__.TestDialects)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_csv.py", line 200, in test_register
csv.unregister_dialect("myexceltsv")
AttributeError: 'module' object has no attribute 'unregister_dialect'
----------------------------------------------------------------------
Ran 38 tests in 0.314s
FAILED (errors=1)
I added the missing function. Everything seems fine once again. I'm
checking in what I have, but _csv.c should probably be carefully inspected
to see if there's an argument out of place, a missing INCREF, an array
bounds violation, or something similar. Errors don't just magically go
away. Whatever was wrong is still wrong, just hiding.
Skip
More information about the Csv
mailing list