Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-wurlitzer for openSUSE:Factory checked in at 2024-07-01 11:19:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-wurlitzer (Old) and /work/SRC/openSUSE:Factory/.python-wurlitzer.new.18349 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-wurlitzer" Mon Jul 1 11:19:17 2024 rev:9 rq:1183915 version:3.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-wurlitzer/python-wurlitzer.changes 2024-05-03 19:44:08.631965977 +0200 +++ /work/SRC/openSUSE:Factory/.python-wurlitzer.new.18349/python-wurlitzer.changes 2024-07-01 11:19:18.444737151 +0200 @@ -1,0 +2,8 @@ +Sat Jun 29 05:32:32 UTC 2024 - Dirk Müller <dmueller@suse.com> + +- update to 3.1.1: + * fix restore after capture with optimized file pipes + * Minor readme clarification + * sys_pipes: check that sys.stdout isn't being forwarded to itself + +------------------------------------------------------------------- Old: ---- wurlitzer-3.1.0.tar.gz New: ---- wurlitzer-3.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-wurlitzer.spec ++++++ --- /var/tmp/diff_new_pack.U2Ebnt/_old 2024-07-01 11:19:19.076760175 +0200 +++ /var/tmp/diff_new_pack.U2Ebnt/_new 2024-07-01 11:19:19.076760175 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-wurlitzer -Version: 3.1.0 +Version: 3.1.1 Release: 0 Summary: Python package to capture C-level output in context managers License: MIT ++++++ wurlitzer-3.1.0.tar.gz -> wurlitzer-3.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/PKG-INFO new/wurlitzer-3.1.1/PKG-INFO --- old/wurlitzer-3.1.0/PKG-INFO 2024-04-29 12:39:41.315538000 +0200 +++ new/wurlitzer-3.1.1/PKG-INFO 2024-06-12 12:27:24.982421600 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: wurlitzer -Version: 3.1.0 +Version: 3.1.1 Summary: Capture C-level output in context managers Home-page: https://github.com/minrk/wurlitzer Author: Min RK @@ -37,7 +37,7 @@ stdout = out.read() ``` -Capture stdout/stderr in StringIO: +Capture both stdout and stderr in a single StringIO object: ```python from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/README.md new/wurlitzer-3.1.1/README.md --- old/wurlitzer-3.1.0/README.md 2024-04-29 12:39:34.000000000 +0200 +++ new/wurlitzer-3.1.1/README.md 2024-06-12 12:27:18.000000000 +0200 @@ -21,7 +21,7 @@ stdout = out.read() ``` -Capture stdout/stderr in StringIO: +Capture both stdout and stderr in a single StringIO object: ```python from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/pyproject.toml new/wurlitzer-3.1.1/pyproject.toml --- old/wurlitzer-3.1.0/pyproject.toml 2024-04-29 12:39:34.000000000 +0200 +++ new/wurlitzer-3.1.1/pyproject.toml 2024-06-12 12:27:18.000000000 +0200 @@ -15,7 +15,7 @@ github_url = "https://github.com/minrk/wurlitzer" [tool.tbump.version] -current = "3.1.0" +current = "3.1.1" # Example of a semver regexp. # Make sure this matches current_version before diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/test.py new/wurlitzer-3.1.1/test.py --- old/wurlitzer-3.1.0/test.py 2024-04-29 12:39:34.000000000 +0200 +++ new/wurlitzer-3.1.1/test.py 2024-06-12 12:27:18.000000000 +0200 @@ -104,6 +104,16 @@ assert stderr.getvalue() == u"Hi, stdérr\n" +def test_sys_pipes_check(): + # pytest redirects stdout; un-redirect it for the test + with mock.patch('sys.stdout', sys.__stdout__), mock.patch( + 'sys.stderr', sys.__stderr__ + ): + with pytest.raises(ValueError): + with sys_pipes(): + pass + + def test_redirect_everything(): stdout = io.StringIO() stderr = io.StringIO() @@ -219,6 +229,9 @@ assert w.thread is None printf("some stdout") printf_err("some stderr") + # make sure capture stopped + printf("after stdout") + printf_err("after stderr") with test_stdout.open() as f: assert f.read() == "some stdout\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/wurlitzer.egg-info/PKG-INFO new/wurlitzer-3.1.1/wurlitzer.egg-info/PKG-INFO --- old/wurlitzer-3.1.0/wurlitzer.egg-info/PKG-INFO 2024-04-29 12:39:41.000000000 +0200 +++ new/wurlitzer-3.1.1/wurlitzer.egg-info/PKG-INFO 2024-06-12 12:27:24.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: wurlitzer -Version: 3.1.0 +Version: 3.1.1 Summary: Capture C-level output in context managers Home-page: https://github.com/minrk/wurlitzer Author: Min RK @@ -37,7 +37,7 @@ stdout = out.read() ``` -Capture stdout/stderr in StringIO: +Capture both stdout and stderr in a single StringIO object: ```python from io import StringIO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wurlitzer-3.1.0/wurlitzer.py new/wurlitzer-3.1.1/wurlitzer.py --- old/wurlitzer-3.1.0/wurlitzer.py 2024-04-29 12:39:34.000000000 +0200 +++ new/wurlitzer-3.1.1/wurlitzer.py 2024-06-12 12:27:18.000000000 +0200 @@ -5,7 +5,7 @@ from __future__ import print_function -__version__ = '3.1.0' +__version__ = '3.1.1' __all__ = [ 'pipes', @@ -209,6 +209,7 @@ real_fd = getattr(sys, '__%s__' % name).fileno() save_fd = os.dup(real_fd) self._save_fds[name] = save_fd + self._real_fds[name] = real_fd try: capture_fd = getattr(self, "_" + name).fileno() @@ -233,7 +234,6 @@ dup2(pipe_in, real_fd) os.close(pipe_in) - self._real_fds[name] = real_fd # make pipe_out non-blocking flags = fcntl(pipe_out, F_GETFL) @@ -532,10 +532,29 @@ def sys_pipes(encoding=_default_encoding, bufsize=None): """Redirect C-level stdout/stderr to sys.stdout/stderr - This is useful of sys.sdout/stderr are already being forwarded somewhere. + This is useful of sys.sdout/stderr are already being forwarded somewhere, + e.g. in a Jupyter kernel. DO NOT USE THIS if sys.stdout and sys.stderr are not already being forwarded. """ + # check that we aren't forwarding stdout to itself + for name in ("stdout", "stderr"): + stream = getattr(sys, name) + capture_stream = getattr(sys, "__{}__".format(name)) + try: + fd = stream.fileno() + capture_fd = capture_stream.fileno() + except Exception: + # ignore errors - if sys.stdout doesn't need a fileno, + # it's definitely not the original sys.__stdout__ + continue + else: + if fd == capture_fd: + raise ValueError( + "Cannot forward sys.__{0}__ to sys.{0}: they are the same! Maybe you want wurlitzer.pipes()?".format( + name + ) + ) return pipes(sys.stdout, sys.stderr, encoding=encoding, bufsize=bufsize)