would this be called bug?

Terry Reedy tjreedy at udel.edu
Sat May 24 01:15:17 EDT 2008


"Amit Gupta" <emailamit at gmail.com> wrote in message 
news:ab143223-2592-4973-943a-a4bd94e25701 at u36g2000prf.googlegroups.com...
| The code is attached below. Basically I am taking a substring of
| variable m, and using "buffer" instead of slicing.
|
| However, the application of int on that buffer start correctly from
| the offset, but it scans all the way to the end, instead of stopping
| at the length of the buffer.
|
| It works however, if I apply str function to output of buffer
| function.
|
| -A
|
|
| (Pdb) m = "AA1234AA"
| (Pdb) x = buffer(m, 2, 4)
| (Pdb) x
| <read-only buffer for 0x2a9d0c18a0, size 4, offset 2 at 0x2a9d0cb7f0>
| (Pdb) int(x)
| *** ValueError: invalid literal for int() with base 10: '1234AA'
| (Pdb) m = "AA1234AA"
| (Pdb) m = "AA1234"
| (Pdb) x = buffer(m, 2, 4)
| (Pdb) int(x)
| 1234
| (Pdb)

Just so you know, buffer() has been deprecated in 2.x and has been replaced 
in Py3 by memoryview() (I believe) because others have had problems with 
buffer().
Don't know any more.






More information about the Python-list mailing list