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.076419905
Marked as misclassified No
Message-id <>
> 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)
    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?
Date User Action Args
2009-01-07 11:46:50vstinnersetrecipients: + vstinner, amaury.forgeotdarc
2009-01-07 11:46:50vstinnersetmessageid: <>
2009-01-07 11:46:50vstinnerlinkissue4862 messages
2009-01-07 11:46:49vstinnercreate