[Python-modules-team] Bug#968600: prompt-toolkit: does deprecated import, causing warning

ralphb at gmx.ph ralphb at gmx.ph
Tue Aug 18 13:51:41 BST 2020


Hello,

This is an improved patch which will do the import in the
recommended way for Python 3 without breaking it for Python 2.

Thanks again,
Ralph.



Index: prompt-toolkit-1.0.15/prompt_toolkit/styles/from_dict.py
===================================================================
--- prompt-toolkit-1.0.15.orig/prompt_toolkit/styles/from_dict.py
+++ prompt-toolkit-1.0.15/prompt_toolkit/styles/from_dict.py
@@ -6,7 +6,10 @@ This is very similar to the Pygments sty
 - Support for ANSI color names. (These will map directly to the 16 terminal
   colors.)
 """
-from collections import Mapping
+try:
+    from collections.abc import Mapping
+except ImportError: # < Python 3.3
+    from collections import Mapping

 from .base import Style, DEFAULT_ATTRS, ANSI_COLOR_NAMES
 from .defaults import DEFAULT_STYLE_EXTENSIONS



More information about the Python-modules-team mailing list