The tokenize module could easily be used to do such tests, as lenient or as strict as required by any particular style guide.
On 5/23/07, Guillaume Proux <[EMAIL PROTECTED]> wrote: > Regarding using looking-alike glyphs (in certain fonts) security > issues, wouldn't it be a good thing for any project anyway to have a > number of pre-conditions for any given contribution to a given project > to be cleared. On of such litmus tests would be like the following. > try: > codecs.open("contributedfile.py","r","ascii") > print("contribution accepted") > except UnicodeDecodeError: > print("contribution rejected. evil non-ascii characters lurking > in your source. ") > > (it should be possible (and this is left as exercise to the reader) to > use some regexp to first remove from the scope of the test strings and > comments or to use AST tools to make the tests directly on the > generated AST) > > In Japan, replace the above "ascii" by "sjis" for example. > > it should be fairly easy to write a number of tools that would > highlight "strange" characters in a piece of source code and I trust > that if there is such a need, the market for python specialized > editors (and other generic editors) will let you pick a different > color for characters that would not be part of the ascii set. Once > again, mostly a presentation and workflow issue that can be solved by > using the right tools or writing some very simple tools to work around > your favorite editor's lacks. > > Regards, > > Guillaume > _______________________________________________ > Python-3000 mailing list > Python-3000@python.org > http://mail.python.org/mailman/listinfo/python-3000 > Unsubscribe: > http://mail.python.org/mailman/options/python-3000/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com