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 vstinner
Recipients amaury.forgeotdarc, vstinner
Date 2009-01-07.11:46:49
SpamBayes Score 0.0764199
Marked as misclassified No
Message-id <1231328810.61.0.792806559105.issue4862@psf.upfronthosting.co.za>
In-reply-to
Content
> This is because the zero in seek(0) is a "cookie" 
> which contains both the position and the decoder state. 
> Unfortunately, state=0 means 'endianness has been determined:
> native order'.

The problem is maybe that TextIOWrapper._pack_cookie() can create a 
cookie=0. Example to create a non-null value, replace:
    def _pack_cookie(self, position, ...):
        return (position | (dec_flags<<64) | ...
    def _unpack_cookie(self, bigint):
        rest, position = divmod(bigint, 1<<64)
        ...
by
    def _pack_cookie(self, position, ...):
        return (1 | (position<<1) | (dec_flags<<65) | ...
    def _unpack_cookie(self, bigint):
        if not (bigint & 1):
           raise ValueError("invalid cookie")
        bigint >>= 1
        rest, position = divmod(bigint, 1<<64)
        ...

Why the cookie is an integer and not an object with attributes?
History
Date User Action Args
2009-01-07 11:46:50vstinnersetrecipients: + vstinner, amaury.forgeotdarc
2009-01-07 11:46:50vstinnersetmessageid: <1231328810.61.0.792806559105.issue4862@psf.upfronthosting.co.za>
2009-01-07 11:46:50vstinnerlinkissue4862 messages
2009-01-07 11:46:49vstinnercreate