[Python-Dev] CPython crash with '%o' (original) (raw)

Christian Heimes lists at cheimes.de
Wed Nov 14 20:47:42 CET 2007


Mike Stall wrote:

Traceback (most recent call last): File "", line 1, in SystemError: \loewis\25\python\Objects\stringobject.c:4236: bad argument to internal function Note that if c derives from 'int' instead of 'long', everything works as expected.

I'm able to reproduce the error with Python 2.5.1 and 2.5 svn on Linux. It also happens when I overwrite hex and do "%x" % c(5) for subclasses of long but not for subclasses from int.

class c(long): def hex(self): return "100" def oct(self): return "100"

x = c(5) hex(x) '100' oct(x) '100' "%o" % x Traceback (most recent call last): File "", line 1, in SystemError: Objects/stringobject.c:4269: bad argument to internal function "%x" % x Traceback (most recent call last): File "", line 1, in SystemError: Objects/stringobject.c:4269: bad argument to internal function

Objects/stringobject.c:_PyString_FormatLong(...) ... /* To modify the string in-place, there can only be one reference. */ if (result->ob_refcnt != 1) { PyErr_BadInternalCall(); return NULL; } ... Christian



More information about the Python-Dev mailing list