[issue1278] imp.find_module() ignores -*- coding: Latin-1 -*-

Guido van Rossum report at bugs.python.org
Mon Oct 15 21:30:23 CEST 2007


Guido van Rossum added the comment:

Call PyTokenizer_Get until the line number is > 2?

On 10/15/07, Christian Heimes <report at bugs.python.org> wrote:
>
> Christian Heimes added the comment:
>
> > Try harder. :-) Look at the code that accomplishes this feat in the
> > regular parser...
>
> I've already found the methods that find the encoding in
> Parser/tokenizer.c: check_coding_spec() and friends.
>
> But it seems like a waste of time to use PyTokenizer_FromFile() just to
> find the encoding. *reading* Mmh ... It's not a waste of time if I can
> stop the tokenizer. I think it may be possible to use the tokenizer to
> get the encoding efficiently. I could read until
> tok_state->read_coding_spec or tok_state->indent != 0.
>
> Do you know a better way to stop the tokenizer when the line isn't a
> special comment line "# -*-"?
>
> Christian
>
> __________________________________
> Tracker <report at bugs.python.org>
> <http://bugs.python.org/issue1278>
> __________________________________
>

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


More information about the Python-bugs-list mailing list