Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.6 Changeset: r97328:d041869f8bd4 Date: 2019-08-29 14:16 +0100 http://bitbucket.org/pypy/pypy/changeset/d041869f8bd4/
Log: hg merge default diff --git a/pypy/module/_warnings/interp_warnings.py b/pypy/module/_warnings/interp_warnings.py --- a/pypy/module/_warnings/interp_warnings.py +++ b/pypy/module/_warnings/interp_warnings.py @@ -400,7 +400,7 @@ return None # Split the source into lines. - w_source_list = space.call_method(w_source, "splitlines") + w_source_list = space.call_method(space.w_text, "splitlines", w_source) # Get the source line. w_source_line = space.getitem(w_source_list, space.newint(lineno - 1)) diff --git a/pypy/module/_warnings/test/test_warnings.py b/pypy/module/_warnings/test/test_warnings.py --- a/pypy/module/_warnings/test/test_warnings.py +++ b/pypy/module/_warnings/test/test_warnings.py @@ -107,3 +107,20 @@ except UnicodeEncodeError: continue _warnings.warn_explicit("text", UserWarning, filename, 1) + + def test_issue31285(self): + import _warnings + def get_bad_loader(splitlines_ret_val): + class BadLoader: + def get_source(self, fullname): + class BadSource(str): + def splitlines(self): + return splitlines_ret_val + return BadSource('spam') + return BadLoader() + # does not raise: + _warnings.warn_explicit( + 'eggs', UserWarning, 'bar', 1, + module_globals={'__loader__': get_bad_loader(42), + '__name__': 'foobar'}) + _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit