Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r90866:9df4aced5d6e Date: 2017-03-29 22:31 +0300 http://bitbucket.org/pypy/pypy/changeset/9df4aced5d6e/
Log: delay checking fromlist values till later, allows ImportError to happen first diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py --- a/pypy/module/imp/importing.py +++ b/pypy/module/imp/importing.py @@ -362,11 +362,6 @@ # to get a better trace. if it is unwrapped, the immutability of the # tuple is lost length = space.len_w(w_fromlist) - for i in range(length): - w_name = space.getitem(w_fromlist, space.newint(i)) - if not space.isinstance_w(w_name, space.w_text): - raise oefmt(space.w_TypeError, - "'fromlist' items must be str, not %T", w_name) if w_path is not None: if length == 1 and space.eq_w( space.getitem(w_fromlist, space.newint(0)), @@ -384,6 +379,9 @@ if w_fromlist is not None: for i in range(length): w_name = space.getitem(w_fromlist, space.newint(i)) + if not space.isinstance_w(w_name, space.w_text): + raise oefmt(space.w_TypeError, + "'Item in ``fromlist'' not a string") if try_getattr(space, w_mod, w_name) is None: return None return w_mod @@ -430,6 +428,9 @@ if w_fromlist is not None: for i in range(length): w_name = space.getitem(w_fromlist, space.newint(i)) + if not space.isinstance_w(w_name, space.w_text): + raise oefmt(space.w_TypeError, + "'Item in ``fromlist'' not a string") if try_getattr(space, w_mod, w_name) is None: load_part(space, w_path, prefix, space.text0_w(w_name), w_mod, tentative=1) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit