diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-10-16 09:22:37 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-10-16 10:09:16 +0100 |
commit | b9e98bb9919fa9f07782f23f79b3d35abb9ff542 (patch) | |
tree | ca56245a1f9ffb7cdabb48259518ed4de0adf774 /libstdc++-v3/python | |
parent | cc217a1ecb04c9234b2cce7ba3c27701a050e402 (diff) | |
download | gcc-b9e98bb9919fa9f07782f23f79b3d35abb9ff542.zip gcc-b9e98bb9919fa9f07782f23f79b3d35abb9ff542.tar.gz gcc-b9e98bb9919fa9f07782f23f79b3d35abb9ff542.tar.bz2 |
libstdc++: Fix Python deprecation warning in printers.py
python/libstdcxx/v6/printers.py:1355: DeprecationWarning: 'count' is passed as positional argument
The Python docs say:
Deprecated since version 3.13: Passing count and flags as positional
arguments is deprecated. In future Python versions they will be
keyword-only parameters.
Using a keyword argument for count only became possible with Python 3.1
so introduce a new function to do the substitution.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (strip_fundts_namespace): New.
(StdExpAnyPrinter, StdExpOptionalPrinter): Use it.
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 9210493..d05b797 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -220,6 +220,16 @@ def strip_versioned_namespace(typename): return typename.replace(_versioned_namespace, '') +def strip_fundts_namespace(typ): + """Remove "fundamentals_vN" inline namespace from qualified type name.""" + pattern = r'^std::experimental::fundamentals_v\d::' + repl = 'std::experimental::' + if sys.version_info[0] == 2: + return re.sub(pattern, repl, typ, 1) + else: # Technically this needs Python 3.1 but nobody should be using 3.0 + return re.sub(pattern, repl, typ, count=1) + + def strip_inline_namespaces(type_str): """Remove known inline namespaces from the canonical name of a type.""" type_str = strip_versioned_namespace(type_str) @@ -1355,8 +1365,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): self._typename = strip_versioned_namespace(typename) - self._typename = re.sub(r'^std::experimental::fundamentals_v\d::', - 'std::experimental::', self._typename, 1) + self._typename = strip_fundts_namespace(self._typename) self._val = val self._contained_type = None contained_value = None @@ -1449,10 +1458,8 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): """Print a std::optional or std::experimental::optional.""" def __init__(self, typename, val): - typename = strip_versioned_namespace(typename) - self._typename = re.sub( - r'^std::(experimental::|)(fundamentals_v\d::|)(.*)', - r'std::\1\3', typename, 1) + self._typename = strip_versioned_namespace(typename) + self._typename = strip_fundts_namespace(self._typename) payload = val['_M_payload'] if self._typename.startswith('std::experimental'): engaged = val['_M_engaged'] |