Author: Ronan Lamy <ronan.l...@gmail.com> Branch: Changeset: r94980:8c0c734e9e02 Date: 2018-08-08 15:59 +0100 http://bitbucket.org/pypy/pypy/changeset/8c0c734e9e02/
Log: Fix issue with empty string as module attribute. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1628,7 +1628,7 @@ else: skip_leading_underscores = False for name in all: - if skip_leading_underscores and name[0]=='_': + if skip_leading_underscores and name and name[0] == '_': continue into_locals[name] = getattr(module, name) ''', filename=__file__) diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -69,8 +69,8 @@ foobar = "found = 123", barbaz = "other = 543") setuppkg("pkg.withoutall", - __init__ = "", - foobar = "found = 123") + __init__ = "globals()[''] = 456", + foobar = "found = 123\n") setuppkg("pkg.bogusall", __init__ = "__all__ = 42") setuppkg("pkg_r", inpkg = "import x.y") @@ -373,7 +373,7 @@ raises(ImportError, __import__, 'xxxbadmodule', fromlist=[u'xx']) mod = __import__('collections', fromlist=[u'defaultdict']) assert mod is not None - + def test_import_relative_back_to_absolute2(self): from pkg import abs_x_y @@ -745,6 +745,13 @@ exec "from pkg.withoutall import *" in d assert d["foobar"].found == 123 + def test_import_star_empty_string(self): + for case in ["not-imported-yet", "already-imported"]: + d = {} + exec "from pkg.withoutall import *" in d + assert "" in d + + def test_import_star_with_bogus___all__(self): for case in ["not-imported-yet", "already-imported"]: try: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit