[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-29 Thread Xiang Zhang
Xiang Zhang added the comment: Although Serhiy thinks we need a separate class for this but I still want to upload my patch first. Maybe some of it can be helpful later, or garbage. I add a mmap_contains to fix the in operator's behaviour (I don't find the separate issue). I use the simplest s

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Making iteration returns int is backward incompatible change. I afraid it is too later to do this. We lost a chance at a time of Python 3.0. We need separate mmap class that behave more like bytes/bytearray/memoryview/sequence of 8-bit integers. --

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Xiang Zhang
Xiang Zhang added the comment: Ho, I'm really curious to see the resolution. ;-) -- ___ Python tracker ___ ___ Python-bugs-list mailin

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Berker Peksag
Berker Peksag added the comment: Thanks for taking a look at this, Xiang. Like I said in msg263470, making the in operator work with mmap objects is out of scope for this issue and it should be handled in a separate issue (I already have a WIP patch, but please feel free to work on it). -

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Xiang Zhang
Xiang Zhang added the comment: I tried to write a patch to make mmap behave like bytearray more. Making iteration returns int is easy. But I am trapped in the contains operation. To support operation like b'aa' in b'aabbcc', we have to do a str in str search. I don't find any portable way exce

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-28 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Iterating a slice produces ints too (a slice is just a bytes object). >>> import mmap, sys >>> with open(sys.executable, 'rb') as f: ... mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) ... print(next(iter(mm))) ... print(next(iter(mm[:10])))

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-04-15 Thread Berker Peksag
Berker Peksag added the comment: I don't think we can change this in 3.5 since it would break backward compatibility. > Similarly the `in` operator seems to be broken; one could search for space > using `32 in bytesobj`, which would work for slices but not for the whole > mmap object. Seems

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-02-19 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- nosy: +twouters versions: -Python 3.2, Python 3.3, Python 3.4 ___ Python tracker ___ ___ Python-bugs-l

[issue26358] mmap.mmap.__iter__ is broken (yields bytes instead of ints)

2016-02-13 Thread Antti Haapala
New submission from Antti Haapala: Just noticed when answering a question on StackOverflow (http://stackoverflow.com/q/35387843/918959) that on Python 3 iterating over a mmap object yields individual bytes as bytes objects, even though iterating over slices, indexing and so on gives ints Exam