Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r45089:c57b14cc361f Date: 2011-06-23 10:57 -0700 http://bitbucket.org/pypy/pypy/changeset/c57b14cc361f/
Log: Don't mangle names with "."s in them, aka package names in imports. diff --git a/pypy/interpreter/astcompiler/misc.py b/pypy/interpreter/astcompiler/misc.py --- a/pypy/interpreter/astcompiler/misc.py +++ b/pypy/interpreter/astcompiler/misc.py @@ -92,7 +92,10 @@ return name if len(name) + 2 >= MANGLE_LEN: return name - if name.endswith('__'): + # Don't mangle __id__ or names with dots. The only time a name with a dot + # can occur is when we are compiling an import statement that has a package + # name. + if name.endswith('__') or '.' in name: return name try: i = 0 diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -308,6 +308,15 @@ "p.__name__", os.path.__name__) yield (self.st, 'from os import *', "path.__name__, sep", (os.path.__name__, os.sep)) + yield (self.st, ''' + class A(object): + def m(self): + from __foo__.bar import x + try: + A().m() + except ImportError, e: + msg = str(e) + ''', "msg", "No module named __foo__") def test_if_stmts(self): yield self.st, "a = 42\nif a > 10: a += 2", "a", 44 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit