Strange bug doesn't occur in Pydb
Diez B. Roggisch
deets at nospam.web.de
Thu Jun 12 08:25:08 EDT 2008
kj wrote:
> In <6bb01lF38u72tU1 at mid.uni-berlin.de> "Diez B. Roggisch"
> <deets at nospam.web.de> writes:
>
>>kj schrieb:
>>> I'm running into a strange seg fault with the module cjson. The
>>> strange part is that it does not occur when I run the code under
>>> Emacs' Pydb.
>>>
>>> Here's an example:
>>>
>>>
>>> import sys, cjson
>>>
>>> d1 = {'a': 1, 'b': 2, 'c': 3}
>>> print sys.version
>>> j1 = cjson.encode(d1)
>>> print j1 # should print the string '{"a": 1, "c": 3, "b": 2}'
>>>
>>> The code above runs fine under Pydb, but segfaults at the call to
>>> cjson.encode when I run it from the command line in a standard
>>> Linux shell interaction. In the printed version strings are
>>> identical.
>>>
>>> I figure this must be a bug in cjson. I'd love to find a workaround
>>> for it, and hope that this strange difference between Pydb and the
>>> shell command line may be a clue to that.
>>>
>>> Any thoughts?
>
>>Are you sure you actually run the same interpreter in emacs as you do on
>>the commandline?
>
> No, I'm not. All I know is that both Emacs and the commandline
> are running on the same machine, and that the version string that
> the program prints is the same in both conditions. How can I verify
> that that the same interpreter is running in both cases?
By e.g.
import sys
print sys.prefix
Additionally, you should compare what
sys.path
contains and if it's the same - otherwise it might be that cjson is picked
up from somewhere else.
If all that's the case, I'd invoke python through gdb and see where the
segfault happens.
BTW: I've been using (and even patching) cjson - without any troubles
whatsoever.
Diez
More information about the Python-list
mailing list