Author: Manuel Jacob <m...@manueljacob.de> Branch: py3k Changeset: r79231:07bfad12ceb6 Date: 2015-08-26 01:57 +0200 http://bitbucket.org/pypy/pypy/changeset/07bfad12ceb6/
Log: Fix an error at interpreter shutdown in case stdout or stderr is missing. diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py --- a/pypy/module/sys/__init__.py +++ b/pypy/module/sys/__init__.py @@ -130,8 +130,8 @@ """) def flush_std_files(self, space): - w_stdout = space.sys.get('stdout') - w_stderr = space.sys.get('stderr') + w_stdout = space.sys.getdictvalue(space, 'stdout') + w_stderr = space.sys.getdictvalue(space, 'stderr') for w_file in [w_stdout, w_stderr]: if not (space.is_none(w_file) or self._file_is_closed(space, w_file)): diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py --- a/pypy/module/sys/test/test_sysmodule.py +++ b/pypy/module/sys/test/test_sysmodule.py @@ -37,6 +37,18 @@ space.setattr(w_sys, space.wrap('stdout'), w_sys.get('__stdout__')) space.setattr(w_sys, space.wrap('stderr'), w_sys.get('__stderr__')) +def test_stdio_missing_at_shutdown(space): + w_sys = space.sys + + try: + space.delattr(w_sys, space.wrap('stdout')) + space.delattr(w_sys, space.wrap('stderr')) + # called at shtudown + w_sys.flush_std_files(space) + finally: + space.setattr(w_sys, space.wrap('stdout'), w_sys.get('__stdout__')) + space.setattr(w_sys, space.wrap('stderr'), w_sys.get('__stderr__')) + class AppTestAppSysTests: def setup_class(cls): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit