diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-07-12 16:03:41 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-07-12 16:03:41 +0200 |
commit | 204721836133485efb1acba6d2795193788f9eda (patch) | |
tree | 6983bd6a5d0d34df823f0536255f8aa9d11ed2f8 /qutebrowser/utils/utils.py | |
parent | bf373e0ff66659af2b2b0114d0a5a2e286effa7c (diff) | |
download | qutebrowser-204721836133485efb1acba6d2795193788f9eda.tar.gz qutebrowser-204721836133485efb1acba6d2795193788f9eda.zip |
Revert "Fix enum stringification for Python 3.10 a7+"
This reverts commit e2c5fe6262564d9d85806bfa9d4486a411cf5045.
See https://mail.python.org/archives/list/python-dev@python.org/thread/ZMC67QA2JVQJSWSFWRS6IM6ZX4EK277G/#LSTMFAPSPD3BGZ4D6HQFODXZVB3PLYKF
Diffstat (limited to 'qutebrowser/utils/utils.py')
-rw-r--r-- | qutebrowser/utils/utils.py | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index fb0165de2..a56769255 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -375,18 +375,6 @@ def is_enum(obj: Any) -> bool: return False -def pyenum_str(value: enum.Enum) -> str: - """Get a string representation of a Python enum value. - - This will have the form of "EnumType.membername", which is the default string - representation for Python up to 3.10. Unfortunately, that changes with Python 3.10: - https://bugs.python.org/issue40066 - """ - if sys.version_info[:2] >= (3, 10): - return repr(value) - return str(value) - - def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str: """Get a suitable __repr__ string for an object. @@ -399,14 +387,8 @@ def get_repr(obj: Any, constructor: bool = False, **attrs: Any) -> str: cls = qualname(obj.__class__) parts = [] items = sorted(attrs.items()) - for name, val in items: - if isinstance(val, enum.Enum): - s = pyenum_str(val) - else: - s = repr(val) - parts.append(f'{name}={s}') - + parts.append('{}={!r}'.format(name, val)) if constructor: return '{}({})'.format(cls, ', '.join(parts)) else: |