[Python-3000] Support for PEP 3131

Guillaume Proux gproux+py3000 at gmail.com
Sat Jun 2 07:15:31 CEST 2007


On 6/2/07, Rauli Ruohonen <rauli.ruohonen at gmail.com> wrote:
> (1) Add a mandatory ASCII-only special comment at the beginning of
>     each module. The comment would continue until the first empty
>     line and would contain only valid directives matching some
>     regular expression. Only whitespace is allowed before the
>     comment. Anything else is a syntax error.

Interesting proposal. I really like it indeed. I wonder how people
against "magic" will like it. Although there is a precedent with the
first line giving the path to the interpreter.
.. but it sounds quite a fair proposal and would solve some of the
issues raised here before

But i wonder if you would see the security issue with some person
sending you  diff file that would (among other changes...) do
something like this
"
1a2
>
"

(inserted a blank line)

Then you would be in trouble again...

An alternative would be to require for any comment before any code
that purposes to set identifier encoding restrictions etc...  to be
preceded by a specific character (just like the unix convention with
the " ! "). Any comment line starting with this character would be
restricted to be ascii only. "%" sounds like a good character for this
purpose.

Like for example...

#!/usr/bin/env python
#
# %coding: utf-8
# %identifier_charset: 0-1fffff
# %string_charset: 0-1fffff
# %indentation: unmixed

Regards,

Guillaume


More information about the Python-3000 mailing list