Message254958
Calling int() or long() on a buffer() object in Python 2.7 does not do the right thing. The following code snippet:
buf = buffer("123test", 1, 2)
print buf
print int(buf)
does not do what I would expect (that it print "23" twice). Instead, it prints "23" once and then throws an exception:
ValueError: invalid literal for int() with base 10: '23test'
This is caused by Objects/abstract.c function int_from_string(), which gets passed the length of the string but does not actually use that information to limit what part is parsed from the string. It only uses it to check for embedded NUL bytes. The real culprit is probably PyInt_FromString() which does not take a length indicator. |
|
Date |
User |
Action |
Args |
2015-11-20 08:40:40 | svenberkvens | set | recipients:
+ svenberkvens |
2015-11-20 08:40:40 | svenberkvens | set | messageid: <1448008840.02.0.961643049915.issue25678@psf.upfronthosting.co.za> |
2015-11-20 08:40:39 | svenberkvens | link | issue25678 messages |
2015-11-20 08:40:39 | svenberkvens | create | |
|