[Python-Dev] test_builtin failing? or just 64-bit platforms (original) (raw)
Fredrik Lundh fredrik@pythonware.com
Sat, 1 Dec 2001 12:35:16 +0100
- Previous message: [Python-Dev] test_builtin failing? or just 64-bit platforms
- Next message: [Python-Dev] Subclassing varying length types (What's a PyStructSequence ?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Barry A. Warsaw wrote:
TP> 20 bytes isn't enough to hold the result on a 64-bit box TP> (insert rant about the idiot practice of trying to make stack TP> buffers as small as possible). You have 20 characters in your TP> result, but need 21 to hold the trailing 0 byte too. I don't TP> know what snprintf does when there's not enough room, but I TP> think you just showed us what it does on Tru64 .
Heh, I was going to suggest that this might be a good place to substitute a call to PyStringFromFormat*() but then I read this little nugget: case 'd': case 'i': case 'x': (void) vaarg(count, int); /* 20 bytes should be enough to hold a 64-bit integer */ n += 20; break;
The size calculated by PyString_FromFormat is used to allocate a Python string, not a C string. The Python string allocator always adds an extra 0 byte at the end.
(if it hadn't, I would have used 21 instead)
- Previous message: [Python-Dev] test_builtin failing? or just 64-bit platforms
- Next message: [Python-Dev] Subclassing varying length types (What's a PyStructSequence ?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]