This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ztane
Recipients ztane
Date 2016-02-14.03:37:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455421066.19.0.307034706486.issue26358@psf.upfronthosting.co.za>
In-reply-to
Content
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

Example:

    import mmap

    with open('test.dat', 'rb') as f:
        mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
        for b in mm:
            print(b)
            # prints for example b'A' instead of 65
        mm.close()

I believe this should be fixed for the sake of completeness - the documentation says that "Memory-mapped file objects behave like both bytearray and like file objects." - however the current behaviour is neither like a bytearray nor like a file object, and quite confusing.

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.
History
Date User Action Args
2016-02-14 03:37:46ztanesetrecipients: + ztane
2016-02-14 03:37:46ztanesetmessageid: <1455421066.19.0.307034706486.issue26358@psf.upfronthosting.co.za>
2016-02-14 03:37:46ztanelinkissue26358 messages
2016-02-14 03:37:44ztanecreate