[issue28002] ast.unparse can't roundtrip some f-strings
Simon Percivall added the comment: Any and all code from astunparse is certainly available for inclusion. Go ahead. -- nosy: +simon.percivall ___ Python tracker <https://bugs.python.org/issue28002> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs
Simon Percivall added the comment: It think it's important to document this caveat in `get_type_hints`, that there is virtually _no_ way to use it safely with a class, and that there will always be a high risk of getting an exception unless using this function in a highly controlled setting. This also, as a consequence, means that there is no "best-effort" support for collecting type hints from a class hierarchy, and every instance of trying to use this function with classes, or traversing __annotations__ "manually", will need to be solved ad-hoc and from scratch by the user (until someone publishes a "typing-utils" package on PyPI). -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29966> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs
New submission from Simon Percivall: For classes with ForwardRef annotations, typing.get_type_hints is unusable. As example, we have two files: a.py: class Base: a: 'A' class A: pass b.py: from a import Base class MyClass(Base): b: 'B' class B: pass >>> from typing import get_type_hints >>> from b import MyClass >>> get_type_hints(MyClass) # NameError What should globals/locals be here? -- messages: 291058 nosy: simon.percivall priority: normal severity: normal status: open title: typing.get_type_hints doesn't really work for classes with ForwardRefs versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29966> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29167] Race condition in enum.py:_decompose()
Simon Percivall added the comment: Run this a couple of times (it fails for me the first time, but it's a race, so YMMV): ``` import enum from concurrent.futures import ThreadPoolExecutor class MyEnum(enum.IntFlag): one = 1 with ThreadPoolExecutor() as executor: print(list(executor.map(MyEnum.one.__or__, range(1000 ``` An easy fix would be: ``` diff --git a/Lib/enum.py b/Lib/enum.py index e79b0382eb..eca56ec3a7 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -846,7 +846,7 @@ def _decompose(flag, value): # check for named flags and powers-of-two flags flags_to_check = [ (m, v) -for v, m in flag._value2member_map_.items() +for v, m in list(flag._value2member_map_.items()) if m.name is not None or _power_of_two(v) ] members = [] ``` -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29167> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29167] Race condition in enum.py:_decompose()
New submission from Simon Percivall: When called by `_create_pseudo_member_()`, the dictionary iteration of `_value2member_map` in `_decompose()` in enum.py may lead to a "RuntimeError: dictionary changed size during iteration". For me, it happened in `re.compile`. ``` Traceback (most recent call last): ... File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 233, in compile return _compile(pattern, flags) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 301, in _compile p = sre_compile.compile(pattern, flags) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 562, in compile p = sre_parse.parse(p, flags) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 866, in parse p.pattern.flags = fix_flags(str, p.pattern.flags) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 835, in fix_flags flags |= SRE_FLAG_UNICODE File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 794, in __or__ result = self.__class__(self._value_ | self.__class__(other)._value_) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 291, in __call__ return cls.__new__(cls, value) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 533, in __new__ return cls._missing_(value) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 760, in _missing_ new_member = cls._create_pseudo_member_(value) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 769, in _create_pseudo_member_ _, extra_flags = _decompose(cls, value) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 849, in _decompose for v, m in flag._value2member_map_.items() File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/enum.py", line 848, in (m, v) RuntimeError: dictionary changed size during iteration ``` -- messages: 284724 nosy: simon.percivall priority: normal severity: normal status: open title: Race condition in enum.py:_decompose() type: crash versions: Python 3.6, Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29167> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation
Simon Percivall [EMAIL PROTECTED] added the comment: It's still a problem, as the test case demonstrates. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2074 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation
New submission from Simon Percivall: _safe_repr() tries to handle the case where two objects are unorderable by ordering on (str(type(key)), key, value), but this fails when str(type(key)) is equal for two objects, but key is different and unorderable. Easy fix: order just on the string representation. -- components: Library (Lib) files: pprint.diff messages: 62303 nosy: percivall severity: normal status: open title: pprint._safe_repr() unsafe on ordering differently types objects with same str represenation versions: Python 3.0 Added file: http://bugs.python.org/file9413/pprint.diff __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2074 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1358] Compile error on OS X 10.5
Simon Percivall added the comment: It has to do with the MACOSX_DEPLOYMENT_TARGET. If it's set to 10.4, the legacy version of setpgrp is used (with args), it it's 10.5, setpgrp expects no arguments. It seems configure won't detect the difference. -- nosy: +percivall __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1358 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com