New submission from Sven Berkvens-Matthijsse: 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. ---------- components: Interpreter Core messages: 254958 nosy: svenberkvens priority: normal severity: normal status: open title: int() from a buffer reads past the buffer boundaries type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25678> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com