[Python-Dev] python3k : imp.find_module raises SyntaxError (original) (raw)
Sylvain Thénault sylvain.thenault at logilab.fr
Mon Nov 29 12:53:11 CET 2010
- Previous message: [Python-Dev] python3k : imp.find_module raises SyntaxError
- Next message: [Python-Dev] python3k : imp.find_module raises SyntaxError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 25 novembre 11:22, Ron Adam wrote:
On 11/25/2010 08:30 AM, Emile Anclin wrote: > >hello, > >working on Pylint, we have a lot of voluntary corrupted files to test >Pylint behavior; for instance > >$ cat /home/emile/var/pylint/test/input/funcunknownencoding.py ># -- coding: IBO-8859-1 -- >""" check correct unknown encoding declaration >""" > >revision = 'éééé' > > >and we try to find that module : >findmodule('funcunknownencoding', None). But python3 raises SyntaxError >in that case ; it didn't raise SyntaxError on python2 nor does so on our >funcnonasciinoencoding and funcwrongencoding modules (with obvious >names) > >Python 3.2a2 (r32a2:84522, Sep 14 2010, 15:22:36) >[GCC 4.3.4] on linux2 >Type "help", "copyright", "credits" or "license" for more information. >>>>from imp import findmodule >>>>findmodule('funcunknownencoding', None) >Traceback (most recent call last): > File "", line 1, in >SyntaxError: encoding problem: with BOM
I don't think there is a clear reason by design. Also try importing the same modules directly and noting the differences in the errors you get.
IMO the point is that we can consider as a bug the fact that find_module tries to somewhat read the content of the file, no? Though it seems to only doing this for encoding detection or like since find_module doesn't choke on a module containing another kind of syntax error.
So the question is, should we deal with this in pylint/astng, or can we expect this to be fixed at some point?
Sylvain Thénault LOGILAB, Paris (France) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org
- Previous message: [Python-Dev] python3k : imp.find_module raises SyntaxError
- Next message: [Python-Dev] python3k : imp.find_module raises SyntaxError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]