[pypy-commit] pypy default: Fix issue with empty string as module attribute.
rlamy
pypy.commits at gmail.com
Wed Aug 8 11:17:18 EDT 2018
Author: Ronan Lamy <ronan.lamy at 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:
More information about the pypy-commit
mailing list