[issue1267] Py3K cannot run as ``python -S``

Christian Heimes report at bugs.python.org
Sat Oct 20 03:37:14 CEST 2007


Christian Heimes added the comment:

Brett Cannon wrote:
> Brett Cannon added the comment:
> 
> It looks like the file object returned by imp.find_module() has its read
> position WAY too far forward (at least on OS X).

That's strange. It should never read more than 2 lines of a file. I
don't understand how it could happen.

char *
PyTokenizer_FindEncoding(FILE *fp) {
        struct tok_state *tok;
        char *p_start=NULL, *p_end=NULL;

        if ((tok = PyTokenizer_FromFile(fp, NULL, NULL, NULL)) == NULL) {
                rewind(fp);
                return NULL;
        }
        while(((tok->lineno <= 2) && (tok->done == E_OK))) {
                PyTokenizer_Get(tok, &p_start, &p_end);
        }

        rewind(fp);
        return tok->encoding;
}

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1267>
__________________________________


More information about the Python-bugs-list mailing list