Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-prompt_toolkit for 
openSUSE:Factory checked in at 2022-11-12 17:40:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-prompt_toolkit (Old)
 and      /work/SRC/openSUSE:Factory/.python-prompt_toolkit.new.1597 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-prompt_toolkit"

Sat Nov 12 17:40:23 2022 rev:19 rq:1035182 version:3.0.32

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-prompt_toolkit/python-prompt_toolkit.changes  
    2022-10-10 18:44:32.590866154 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-prompt_toolkit.new.1597/python-prompt_toolkit.changes
    2022-11-12 17:40:33.977952656 +0100
@@ -1,0 +2,16 @@
+Wed Nov  9 16:32:15 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com>
+
+- Update to version 3.0.32: 
+  Bug fixes:
+  - Use `DummyInput` by default in `create_input()` if `sys.stdin` does not 
have
+  a valid file descriptor. This fixes errors when `sys.stdin` is patched in
+  certain situations.
+  - Fix control-c key binding for `ProgressBar` when the progress bar was not
+  created from the main thread. The current code would try to kill the main
+  thread when control-c was pressed.
+  New features:
+  - Accept a `cancel_callback` in `ProgressBar` to specify the cancellation
+  behavior for when `control-c` is pressed.
+  - Small performance improvement in the renderer.
+
+-------------------------------------------------------------------

Old:
----
  prompt_toolkit-3.0.31.tar.gz

New:
----
  prompt_toolkit-3.0.32.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-prompt_toolkit.spec ++++++
--- /var/tmp/diff_new_pack.I8axF8/_old  2022-11-12 17:40:34.509955823 +0100
+++ /var/tmp/diff_new_pack.I8axF8/_new  2022-11-12 17:40:34.517955870 +0100
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-prompt_toolkit
-Version:        3.0.31
+Version:        3.0.32
 Release:        0
 Summary:        Library for building interactive command lines in Python
 License:        BSD-3-Clause

++++++ prompt_toolkit-3.0.31.tar.gz -> prompt_toolkit-3.0.32.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prompt_toolkit-3.0.31/CHANGELOG 
new/prompt_toolkit-3.0.32/CHANGELOG
--- old/prompt_toolkit-3.0.31/CHANGELOG 2022-09-02 11:00:02.000000000 +0200
+++ new/prompt_toolkit-3.0.32/CHANGELOG 2022-11-03 17:29:06.000000000 +0100
@@ -1,6 +1,23 @@
 CHANGELOG
 =========
 
+3.0.32: 2022-11-03
+------------------
+
+Bug fixes:
+- Use `DummyInput` by default in `create_input()` if `sys.stdin` does not have
+  a valid file descriptor. This fixes errors when `sys.stdin` is patched in
+  certain situations.
+- Fix control-c key binding for `ProgressBar` when the progress bar was not
+  created from the main thread. The current code would try to kill the main
+  thread when control-c was pressed.
+
+New features:
+- Accept a `cancel_callback` in `ProgressBar` to specify the cancellation
+  behavior for when `control-c` is pressed.
+- Small performance improvement in the renderer.
+
+
 3.0.31: 2022-09-02
 ------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prompt_toolkit-3.0.31/PKG-INFO 
new/prompt_toolkit-3.0.32/PKG-INFO
--- old/prompt_toolkit-3.0.31/PKG-INFO  2022-09-02 11:00:33.564112200 +0200
+++ new/prompt_toolkit-3.0.32/PKG-INFO  2022-11-03 17:32:01.266258000 +0100
@@ -1,9 +1,11 @@
 Metadata-Version: 2.1
 Name: prompt_toolkit
-Version: 3.0.31
+Version: 3.0.32
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/prompt-toolkit/python-prompt-toolkit
 Author: Jonathan Slenders
+License: UNKNOWN
+Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: BSD License
@@ -179,3 +181,5 @@
 .. |Codecov| image:: 
https://codecov.io/gh/prompt-toolkit/python-prompt-toolkit/branch/master/graphs/badge.svg?style=flat
     :target: https://codecov.io/gh/prompt-toolkit/python-prompt-toolkit/
 
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prompt_toolkit-3.0.31/src/prompt_toolkit/__init__.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/__init__.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/__init__.py    2022-09-02 
11:00:02.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/__init__.py    2022-11-03 
17:29:36.000000000 +0100
@@ -18,7 +18,7 @@
 from .shortcuts import PromptSession, print_formatted_text, prompt
 
 # Don't forget to update in `docs/conf.py`!
-__version__ = "3.0.31"
+__version__ = "3.0.32"
 
 # Version tuple.
 VERSION = tuple(__version__.split("."))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prompt_toolkit-3.0.31/src/prompt_toolkit/contrib/ssh/server.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/contrib/ssh/server.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/contrib/ssh/server.py  
2022-09-02 10:53:41.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/contrib/ssh/server.py  
2022-11-03 17:22:03.000000000 +0100
@@ -120,7 +120,7 @@
         self._input.send_text(data)
 
 
-class PromptToolkitSSHServer(asyncssh.SSHServer):  # type: ignore
+class PromptToolkitSSHServer(asyncssh.SSHServer):
     """
     Run a prompt_toolkit application over an asyncssh server.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prompt_toolkit-3.0.31/src/prompt_toolkit/input/defaults.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/input/defaults.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/input/defaults.py      
2022-09-01 17:02:15.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/input/defaults.py      
2022-11-03 15:44:40.000000000 +0100
@@ -1,3 +1,4 @@
+import io
 import sys
 from typing import ContextManager, Optional, TextIO
 
@@ -38,11 +39,20 @@
             stdin = sys.stdin
 
             if always_prefer_tty:
-                for io in [sys.stdin, sys.stdout, sys.stderr]:
-                    if io.isatty():
-                        stdin = io
+                for obj in [sys.stdin, sys.stdout, sys.stderr]:
+                    if obj.isatty():
+                        stdin = obj
                         break
 
+        # If we can't access the file descriptor for the selected stdin, return
+        # a `DummyInput` instead. This can happen for instance in unit tests,
+        # when `sys.stdin` is patched by something that's not an actual file.
+        # (Instantiating `Vt100Input` would fail in this case.)
+        try:
+            stdin.fileno()
+        except io.UnsupportedOperation:
+            return DummyInput()
+
         return Vt100Input(stdin)
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prompt_toolkit-3.0.31/src/prompt_toolkit/layout/utils.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/layout/utils.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/layout/utils.py        
2022-09-01 17:02:15.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/layout/utils.py        
2022-11-03 17:22:03.000000000 +0100
@@ -73,8 +73,8 @@
 
     result: List[_T] = []
 
-    for style, string, *rest in fragments:  # type: ignore
-        for c in string:  # type: ignore
+    for style, string, *rest in fragments:
+        for c in string:
             result.append((style, c, *rest))  # type: ignore
 
     return _ExplodedList(result)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/prompt_toolkit-3.0.31/src/prompt_toolkit/renderer.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/renderer.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/renderer.py    2022-09-02 
10:53:32.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/renderer.py    2022-10-28 
22:01:33.000000000 +0200
@@ -152,13 +152,12 @@
         - The `Window` adds a style class to the current line for highlighting
           (cursor-line).
         """
-        numbers = [
+        numbers = (
             index
             for index, cell in row.items()
             if cell.char != " " or style_string_has_style[cell.style]
-        ]
-        numbers.append(0)
-        return max(numbers)
+        )
+        return max(numbers, default=0)
 
     # Render for the first time: reset styling.
     if not previous_screen:
@@ -189,7 +188,6 @@
 
     # Loop over the rows.
     row_count = min(max(screen.height, previous_screen.height), height)
-    c = 0  # Column counter.
 
     for y in range(row_count):
         new_row = screen.data_buffer[y]
@@ -200,7 +198,7 @@
         previous_max_line_len = min(width - 1, 
get_max_column_index(previous_row))
 
         # Loop over the columns.
-        c = 0
+        c = 0  # Column counter.
         while c <= new_max_line_len:
             new_char = new_row[c]
             old_char = previous_row[c]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prompt_toolkit-3.0.31/src/prompt_toolkit/shortcuts/progress_bar/base.py 
new/prompt_toolkit-3.0.32/src/prompt_toolkit/shortcuts/progress_bar/base.py
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit/shortcuts/progress_bar/base.py 
2022-09-01 17:02:15.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit/shortcuts/progress_bar/base.py 
2022-11-03 17:22:03.000000000 +0100
@@ -15,6 +15,7 @@
 import traceback
 from asyncio import new_event_loop, set_event_loop
 from typing import (
+    Callable,
     Generic,
     Iterable,
     Iterator,
@@ -69,7 +70,7 @@
 _SIGWINCH = getattr(signal, "SIGWINCH", None)
 
 
-def create_key_bindings() -> KeyBindings:
+def create_key_bindings(cancel_callback: Optional[Callable[[], None]]) -> 
KeyBindings:
     """
     Key bindings handled by the progress bar.
     (The main thread is not supposed to handle any key bindings.)
@@ -80,10 +81,13 @@
     def _clear(event: E) -> None:
         event.app.renderer.clear()
 
-    @kb.add("c-c")
-    def _interrupt(event: E) -> None:
-        # Send KeyboardInterrupt to the main thread.
-        os.kill(os.getpid(), signal.SIGINT)
+    if cancel_callback is not None:
+
+        @kb.add("c-c")
+        def _interrupt(event: E) -> None:
+            "Kill the 'body' of the progress bar, but only if we run from the 
main thread."
+            assert cancel_callback is not None
+            cancel_callback()
 
     return kb
 
@@ -108,6 +112,9 @@
         can be a callable or formatted text.
     :param style: :class:`prompt_toolkit.styles.BaseStyle` instance.
     :param key_bindings: :class:`.KeyBindings` instance.
+    :param cancel_callback: Callback function that's called when control-c is
+        pressed by the user. This can be used for instance to start "proper"
+        cancellation if the wrapped code supports it.
     :param file: The file object used for rendering, by default `sys.stderr` 
is used.
 
     :param color_depth: `prompt_toolkit` `ColorDepth` instance.
@@ -122,6 +129,7 @@
         bottom_toolbar: AnyFormattedText = None,
         style: Optional[BaseStyle] = None,
         key_bindings: Optional[KeyBindings] = None,
+        cancel_callback: Optional[Callable[[], None]] = None,
         file: Optional[TextIO] = None,
         color_depth: Optional[ColorDepth] = None,
         output: Optional[Output] = None,
@@ -134,6 +142,20 @@
         self.counters: List[ProgressBarCounter[object]] = []
         self.style = style
         self.key_bindings = key_bindings
+        self.cancel_callback = cancel_callback
+
+        # If no `cancel_callback` was given, and we're creating the progress
+        # bar from the main thread. Cancel by sending a `KeyboardInterrupt` to
+        # the main thread.
+        if (
+            self.cancel_callback is None
+            and threading.currentThread() == threading.main_thread()
+        ):
+
+            def keyboard_interrupt_to_main_thread() -> None:
+                os.kill(os.getpid(), signal.SIGINT)
+
+            self.cancel_callback = keyboard_interrupt_to_main_thread
 
         # Note that we use __stderr__ as default error output, because that
         # works best with `patch_stdout`.
@@ -143,7 +165,6 @@
 
         self._thread: Optional[threading.Thread] = None
 
-        self._loop = get_event_loop()
         self._app_loop = new_event_loop()
         self._has_sigwinch = False
         self._app_started = threading.Event()
@@ -179,7 +200,7 @@
 
         progress_controls = [
             Window(
-                content=_ProgressControl(self, f),
+                content=_ProgressControl(self, f, self.cancel_callback),
                 width=functools.partial(width_for_formatter, f),
             )
             for f in self.formatters
@@ -271,10 +292,15 @@
     User control for the progress bar.
     """
 
-    def __init__(self, progress_bar: ProgressBar, formatter: Formatter) -> 
None:
+    def __init__(
+        self,
+        progress_bar: ProgressBar,
+        formatter: Formatter,
+        cancel_callback: Optional[Callable[[], None]],
+    ) -> None:
         self.progress_bar = progress_bar
         self.formatter = formatter
-        self._key_bindings = create_key_bindings()
+        self._key_bindings = create_key_bindings(cancel_callback)
 
     def create_content(self, width: int, height: int) -> UIContent:
         items: List[StyleAndTextTuples] = []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/prompt_toolkit-3.0.31/src/prompt_toolkit.egg-info/PKG-INFO 
new/prompt_toolkit-3.0.32/src/prompt_toolkit.egg-info/PKG-INFO
--- old/prompt_toolkit-3.0.31/src/prompt_toolkit.egg-info/PKG-INFO      
2022-09-02 11:00:33.000000000 +0200
+++ new/prompt_toolkit-3.0.32/src/prompt_toolkit.egg-info/PKG-INFO      
2022-11-03 17:32:01.000000000 +0100
@@ -1,9 +1,11 @@
 Metadata-Version: 2.1
 Name: prompt-toolkit
-Version: 3.0.31
+Version: 3.0.32
 Summary: Library for building powerful interactive command lines in Python
 Home-page: https://github.com/prompt-toolkit/python-prompt-toolkit
 Author: Jonathan Slenders
+License: UNKNOWN
+Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: BSD License
@@ -179,3 +181,5 @@
 .. |Codecov| image:: 
https://codecov.io/gh/prompt-toolkit/python-prompt-toolkit/branch/master/graphs/badge.svg?style=flat
     :target: https://codecov.io/gh/prompt-toolkit/python-prompt-toolkit/
 
+
+

Reply via email to