Mike Stall wrote: > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > 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 "<stdin>", line 1, in <module> SystemError: Objects/stringobject.c:4269: bad argument to internal function >>> "%x" % x Traceback (most recent call last): File "<stdin>", line 1, in <module> 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4