From report at bugs.python.org Fri Jan 1 00:16:27 2021 From: report at bugs.python.org (Steven D'Aprano) Date: Fri, 01 Jan 2021 05:16:27 +0000 Subject: [New-bugs-announce] [issue42801] Exception catching function crashes on recursive list Message-ID: <1609478187.83.0.886724654093.issue42801@roundup.psfhosted.org> New submission from Steven D'Aprano : This function crashes on the following recursive list: def length(x): try: return sum(length(i) for i in x) except Exception: return 1 a = [[1, 2, 3], [4, 5, 6]] a.append(a) length(a) Crashes: Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow. Python runtime state: initialized Current thread 0x00007eff18d77740 (most recent call first): File "", line 3 in length File "", line 3 in File "", line 3 in length File "", line 3 in ... Aborted (core dumped) For brevity I've cut some of the output. There are about fifty pairs of "line 3 in length"/line 3 in " lines, all identical. ---------- components: Interpreter Core messages: 384150 nosy: steven.daprano priority: normal severity: normal status: open title: Exception catching function crashes on recursive list type: crash versions: Python 3.7, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 09:28:27 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 01 Jan 2021 14:28:27 +0000 Subject: [New-bugs-announce] [issue42802] distutils: Remove bdist_wininst command Message-ID: <1609511307.58.0.913169413627.issue42802@roundup.psfhosted.org> New submission from STINNER Victor : Attached PR removes it. The bdist_wininst command was deprecated in Python 3.8: commit 1da4462765b084dfa8d869b6cb5855e8f6014a11 Author: Victor Stinner Date: Fri Jul 5 10:44:12 2019 +0200 bpo-37481: Deprecate distutils bdist_wininst command (GH-14553) The distutils bdist_wininst command is now deprecated, use bdist_wheel (wheel packages) instead. "What?s New In Python 3.9: Build Changes" also announced: * On non-Windows platforms, creating ``bdist_wininst`` installers is now officially unsupported. (See :issue:`10945` for more details.) https://docs.python.org/dev/whatsnew/3.9.html#build-changes See bpo-37481 and: https://discuss.python.org/t/deprecate-bdist-wininst/1929 ---------- components: Distutils messages: 384173 nosy: dstufft, eric.araujo, vstinner priority: normal severity: normal status: open title: distutils: Remove bdist_wininst command versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 09:43:03 2021 From: report at bugs.python.org (Ned Batchelder) Date: Fri, 01 Jan 2021 14:43:03 +0000 Subject: [New-bugs-announce] [issue42803] Traced line number is wrong for "if not __debug__" Message-ID: <1609512183.17.0.454209386156.issue42803@roundup.psfhosted.org> New submission from Ned Batchelder : (Using CPython commit 6b1ac809b9) This program never executes line 4, but the "if not __debug__" is partly attributed to line 4, giving an incorrect trace: for value in [True, False]: if value: if not __debug__: 1/0 # line 4 else: x = 6 Using a simple trace program (https://github.com/nedbat/coveragepy/blob/master/lab/run_trace.py), it produces this output: call 1 @-1 line 1 @0 line 2 @8 line 3 @12 line 4 @14 line 1 @4 line 2 @8 line 6 @16 line 1 @4 return 1 @24 Various simplifications of the program make the problem go away. ---------- components: Interpreter Core messages: 384178 nosy: Mark.Shannon, nedbat priority: normal severity: normal status: open title: Traced line number is wrong for "if not __debug__" versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 13:00:07 2021 From: report at bugs.python.org (Bharath Posa) Date: Fri, 01 Jan 2021 18:00:07 +0000 Subject: [New-bugs-announce] [issue42804] Unable to compile the code x86 windows Message-ID: <1609524007.28.0.23660757957.issue42804@roundup.psfhosted.org> New submission from Bharath Posa : Hi Team, While I am trying to build the cpython in windows 10. I am getting tcl.h file not found error. You can find the screen shot of the error along with the bug. regards Sunny ---------- components: Build files: error_python_compilation.JPG messages: 384194 nosy: pbharat priority: normal severity: normal status: open title: Unable to compile the code x86 windows versions: Python 3.8 Added file: https://bugs.python.org/file49715/error_python_compilation.JPG _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 14:39:57 2021 From: report at bugs.python.org (monchy) Date: Fri, 01 Jan 2021 19:39:57 +0000 Subject: [New-bugs-announce] [issue42805] broken pygame integration into wxpython Message-ID: <1609529997.71.0.350416816551.issue42805@roundup.psfhosted.org> New submission from monchy : in previous python verions a pygame window could be embedded into wxpython by assigning the SDL_WINDOWID to the current wx.Panel.GetHandle() and the SDL_VIDEODRIVER to 'windib' before importing python the same code creates a separate pygame window in the newest python version a basic implementation can be found here: https://github.com/Monchytales/Puppet-Theatre/blob/main/pygame_panel.py ---------- messages: 384203 nosy: MonchyTales priority: normal severity: normal status: open title: broken pygame integration into wxpython type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 19:00:22 2021 From: report at bugs.python.org (Anthony Sottile) Date: Sat, 02 Jan 2021 00:00:22 +0000 Subject: [New-bugs-announce] [issue42806] Incorrect offsets in new parser for f-string substitutions Message-ID: <1609545622.39.0.162230247041.issue42806@roundup.psfhosted.org> New submission from Anthony Sottile : here's a sample file. this is distilled down from an example which broke a code formatter here: https://github.com/asottile/add-trailing-comma/issues/106 def f(): x = ( 'PERL_MM_OPT', ( f'INSTALL-BASE={shlex.quote(venv)} ' f'wat' ), ) A diff from astpretty (https://github.com/asottile/astpretty) between the old and new parser: ```console $ diff -u <(.tox/py39/bin/python -X oldparser -m astpretty perl.py) <(.tox/py39/bin/python -m astpretty perl.py) --- /dev/fd/63 2021-01-01 15:58:09.108060968 -0800 +++ /dev/fd/62 2021-01-01 15:58:09.108060968 -0800 @@ -35,19 +35,19 @@ end_col_offset=22, value=Call( lineno=4, - col_offset=32, + col_offset=16, end_lineno=4, - end_col_offset=49, + end_col_offset=33, func=Attribute( lineno=4, - col_offset=32, + col_offset=16, end_lineno=4, - end_col_offset=43, - value=Name(lineno=4, col_offset=32, end_lineno=4, end_col_offset=37, id='shlex', ctx=Load()), + end_col_offset=27, + value=Name(lineno=4, col_offset=16, end_lineno=4, end_col_offset=21, id='shlex', ctx=Load()), attr='quote', ctx=Load(), ), - args=[Name(lineno=4, col_offset=44, end_lineno=4, end_col_offset=48, id='venv', ctx=Load())], + args=[Name(lineno=4, col_offset=28, end_lineno=4, end_col_offset=32, id='venv', ctx=Load())], keywords=[], ), conversion=-1, ``` the old parser is correct here, and the new parser is wrong notably it thinks that the call inside the f-string substitution is positioned at column 16 which is the position of the f-string start this bug is also present in 3.10: ```console $ venv/bin/python3.10 --version Python 3.10.0a3 $ diff -u <(.tox/py39/bin/python -X oldparser -m astpretty perl.py) <(venv/bin/python3.10 -m astpretty perl.py) --- /dev/fd/63 2021-01-01 15:59:54.000059968 -0800 +++ /dev/fd/62 2021-01-01 15:59:54.000059968 -0800 @@ -35,19 +35,19 @@ end_col_offset=22, value=Call( lineno=4, - col_offset=32, + col_offset=16, end_lineno=4, - end_col_offset=49, + end_col_offset=33, func=Attribute( lineno=4, - col_offset=32, + col_offset=16, end_lineno=4, - end_col_offset=43, - value=Name(lineno=4, col_offset=32, end_lineno=4, end_col_offset=37, id='shlex', ctx=Load()), + end_col_offset=27, + value=Name(lineno=4, col_offset=16, end_lineno=4, end_col_offset=21, id='shlex', ctx=Load()), attr='quote', ctx=Load(), ), - args=[Name(lineno=4, col_offset=44, end_lineno=4, end_col_offset=48, id='venv', ctx=Load())], + args=[Name(lineno=4, col_offset=28, end_lineno=4, end_col_offset=32, id='venv', ctx=Load())], keywords=[], ), conversion=-1, ``` ---------- components: Interpreter Core messages: 384208 nosy: Anthony Sottile priority: normal severity: normal status: open title: Incorrect offsets in new parser for f-string substitutions type: behavior versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 1 23:23:16 2021 From: report at bugs.python.org (oon arfiandwi) Date: Sat, 02 Jan 2021 04:23:16 +0000 Subject: [New-bugs-announce] [issue42807] smtplib send_message should gives more clear exception if the msg is None Message-ID: <1609561396.29.0.629926386929.issue42807@roundup.psfhosted.org> New submission from oon arfiandwi : I want to enhance the error message on the send_message method of class SMTP, in module smtplib. One of the parameters on send_message is msg which is email.message.Message object, this is a required argument. If the msg is None, currently it will raise "AttributeError: 'NoneType' object has no attribute 'get_all'". This message is not straight forward and a bit hard to debug. As the easy fix with additional check if msg is None in send_message method. I want to add PR on this, also with the additional test(s). This is my first issue, appreciate any feedback. thank you. ---------- components: Library (Lib) messages: 384216 nosy: oon priority: normal severity: normal status: open title: smtplib send_message should gives more clear exception if the msg is None type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 2 05:00:06 2021 From: report at bugs.python.org (Dennis Sweeney) Date: Sat, 02 Jan 2021 10:00:06 +0000 Subject: [New-bugs-announce] [issue42808] Add PyType_Type.tp_vectorcall for type(obj) performance Message-ID: <1609581606.85.0.894764244692.issue42808@roundup.psfhosted.org> New submission from Dennis Sweeney : # common case .\python.bat -m pyperf timeit "type(17)" Master: 49.9 ns +- 1.8 ns ---> PR: 33.3 ns +- 1.4 ns # uncommon case .\python.bat -m pyperf timeit "type('A', (object, ), {})" Master: 5.14 us +- 0.04 us ---> PR: 5.43 us +- 0.06 us ---------- components: Interpreter Core messages: 384218 nosy: Dennis Sweeney priority: normal severity: normal status: open title: Add PyType_Type.tp_vectorcall for type(obj) performance type: performance versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 2 05:47:08 2021 From: report at bugs.python.org (Serhiy Storchaka) Date: Sat, 02 Jan 2021 10:47:08 +0000 Subject: [New-bugs-announce] [issue42809] Improve pickle tests for recursive data Message-ID: <1609584428.87.0.716102907179.issue42809@roundup.psfhosted.org> New submission from Serhiy Storchaka : The proposed PR extends tests for pickling recursive structures. The code is now more generic and covers more corner cases (found during work on issue36694). ---------- components: Tests messages: 384220 nosy: alexandre.vassalotti, serhiy.storchaka priority: normal severity: normal status: open title: Improve pickle tests for recursive data type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 2 10:09:25 2021 From: report at bugs.python.org (Ned Batchelder) Date: Sat, 02 Jan 2021 15:09:25 +0000 Subject: [New-bugs-announce] [issue42810] Nested if/else gets phantom else trace (3.10) Message-ID: <1609600165.12.0.126191975832.issue42810@roundup.psfhosted.org> New submission from Ned Batchelder : (Using CPython commit 6b1ac809b9) This program never executes line 6, but tracing it claims that it does: a = b = x = y = z = 1 if a == 1: if b == 1: x = 4 else: y = 6 else: z = 8 assert (a, b, x, y, z) == (1, 1, 4, 1, 1) Using a simple trace program (https://github.com/nedbat/coveragepy/blob/master/lab/run_trace.py), it produces this output: call 1 @-1 line 1 @0 line 2 @20 line 3 @28 line 4 @36 line 6 @40 line 9 @52 return 9 @76 ---------- components: Interpreter Core messages: 384222 nosy: Mark.Shannon, nedbat priority: normal severity: normal status: open title: Nested if/else gets phantom else trace (3.10) versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 2 15:27:59 2021 From: report at bugs.python.org (Brett Cannon) Date: Sat, 02 Jan 2021 20:27:59 +0000 Subject: [New-bugs-announce] [issue42811] Update docs for importlib.util.resolve_name() to use __spec__ instead of __package__ Message-ID: <1609619279.01.0.578638244778.issue42811@roundup.psfhosted.org> New submission from Brett Cannon : Since importlib now prefers `__spec__` over `__package__`, https://docs.python.org/3/library/importlib.html#importlib.util.resolve_name should be updated to use `__spec__.parent` instead in the. example. ---------- assignee: brett.cannon components: Documentation keywords: easy messages: 384238 nosy: brett.cannon priority: low severity: normal stage: needs patch status: open title: Update docs for importlib.util.resolve_name() to use __spec__ instead of __package__ versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 00:51:32 2021 From: report at bugs.python.org (Chaim Gewirtz) Date: Sun, 03 Jan 2021 05:51:32 +0000 Subject: [New-bugs-announce] [issue42812] @overload-ing method of parent class without actual implementation Message-ID: <1609653092.18.0.893619520042.issue42812@roundup.psfhosted.org> New submission from Chaim Gewirtz : Why should @overload need to be followed by an implementation when an implementation already exists in the parent class? Illustrative example: class Parent: def foo(**kwargs): """Argument names of foo vary depending on the child class.""" class Child(Parent): @overload foo(a, b): ... Raises: "NotImplementedError: You should not call an overloaded function. A series of @overload-decorated functions outside a stub module should always be followed by an implementation that is not @overload-ed." ---------- messages: 384255 nosy: chaim422 priority: normal severity: normal status: open title: @overload-ing method of parent class without actual implementation type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 03:33:08 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Sun, 03 Jan 2021 08:33:08 +0000 Subject: [New-bugs-announce] [issue42813] Extra spaces cause unexpected EOF error in "compile" function with mode "single" Message-ID: <1609662788.81.0.389452774776.issue42813@roundup.psfhosted.org> New submission from Xinmeng Xia : Running the following program will lead to an unexpected EOF error. If we delete the space before triple-quotation mark("""), the error will gone. If we replace the content of snippet with "a = 1", the program will work well. However, if we replace the content of snippet with "if a:pass" in a single line, the program cause an error again. This is weird. Spaces in the end of a statement should not affect the compilation of program in "single" mode. Besides, the error messages are different in Python2 and Python3. Indentation error are reported in Python 2 for snippet" if a:pass" while SyntaxError are reported in Python 3. ====================================================== import math def check_stack_size( code): # To assert that the alleged stack size is not O(N), we # check that it is smaller than log(N). if isinstance(code, str): code = compile(code, "", "single") max_size = math.ceil(math.log(len(code.co_code))) # self.assertLessEqual(code.co_stacksize, max_size) def test_if_else(): snippet =""" if x: a elif y: b else: c """ check_stack_size(snippet) test_if_else() ===================================================== Behavior in Python 3.10: Traceback (most recent call last): File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in test_if_else() File "/home/xxm/Desktop/nameChanging/report/temp.py", line 20, in test_if_else check_stack_size(snippet) File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in check_stack_size code = compile(code, "", "single") File "", line 8 SyntaxError: unexpected EOF while parsing Behaviors in Python2: Traceback (most recent call last): File "/home/xxm/Desktop/nameChanging/report/temp.py", line 30, in test_if_else() File "/home/xxm/Desktop/nameChanging/report/temp.py", line 27, in test_if_else check_stack_size(snippet) File "/home/xxm/Desktop/nameChanging/report/temp.py", line 6, in check_stack_size code = compile(code, "", "single") File "", line 3 ^ IndentationError: unexpected indent ---------- components: Interpreter Core messages: 384257 nosy: xxm priority: normal severity: normal status: open title: Extra spaces cause unexpected EOF error in "compile" function with mode "single" type: compile error versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 06:40:24 2021 From: report at bugs.python.org (Zackery Spytz) Date: Sun, 03 Jan 2021 11:40:24 +0000 Subject: [New-bugs-announce] [issue42814] Undefined behavior in Objects/genericaliasobject.c Message-ID: <1609674024.61.0.74243567004.issue42814@roundup.psfhosted.org> New submission from Zackery Spytz : In is_typing_name(), va_end() is not always called before the function returns. It is undefined behavior to call va_start() without also calling va_end(). ---------- components: Interpreter Core messages: 384261 nosy: ZackerySpytz priority: normal severity: normal status: open title: Undefined behavior in Objects/genericaliasobject.c versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 06:43:34 2021 From: report at bugs.python.org (Yurii Karabas) Date: Sun, 03 Jan 2021 11:43:34 +0000 Subject: [New-bugs-announce] [issue42815] new thread doesn't copy context of the parent thread Message-ID: <1609674214.71.0.941381845328.issue42815@roundup.psfhosted.org> New submission from Yurii Karabas <1998uriyyo at gmail.com>: New thread doesn't copy context of the parent thread. The minimal example to reproduce the issue: ``` from threading import Thread from contextvars import ContextVar foo: ContextVar[str] = ContextVar("foo") def temp(): print(foo.get()) foo.set("bar") t = Thread(target=temp) t.start() t.join() ``` Is it expected behavior? PEP 567 I didn't find anything regarding this case. ---------- components: Library (Lib) messages: 384262 nosy: uriyyo priority: normal severity: normal status: open title: new thread doesn't copy context of the parent thread type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 08:09:42 2021 From: report at bugs.python.org (Martin Winks) Date: Sun, 03 Jan 2021 13:09:42 +0000 Subject: [New-bugs-announce] [issue42816] Add str.split_iter function Message-ID: <1609679382.47.0.0845431201313.issue42816@roundup.psfhosted.org> New submission from Martin Winks : Split string by given separator and return iterator as a result. The naive and not very efficient solution would be using current str.split: def split_iter(self: str, sep: str) -> 'Iterator[str]': return iter(self.split(sep)) Probably, need we'll some better solution without allocating new list. ---------- components: Unicode messages: 384270 nosy: ezio.melotti, uwinx, vstinner priority: normal severity: normal status: open title: Add str.split_iter function type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 08:19:56 2021 From: report at bugs.python.org (Kevin Rasmussen) Date: Sun, 03 Jan 2021 13:19:56 +0000 Subject: [New-bugs-announce] [issue42817] timedelta zeropadding hh Message-ID: <1609679996.96.0.581038745817.issue42817@roundup.psfhosted.org> New submission from Kevin Rasmussen : It looks like hh should be zeropadded to 2 and isn't for timedelta. ---------- messages: 384273 nosy: krasmussen priority: normal severity: normal status: open title: timedelta zeropadding hh type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 09:09:35 2021 From: report at bugs.python.org (Klaus Ethgen) Date: Sun, 03 Jan 2021 14:09:35 +0000 Subject: [New-bugs-announce] [issue42818] AttributeError: 'zipimporter' object has no attribute 'find_spec' Message-ID: <1609682975.59.0.559934544299.issue42818@roundup.psfhosted.org> New submission from Klaus Ethgen : I encountered the bug when installing a package with `python3 setup.py install --user`. After that, a second installation failed with this stack trace: ``` Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2191, in _handle_ns loader = importer.find_spec(packageName).loader AttributeError: 'zipimporter' object has no attribute 'find_spec' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/klaus/devel/upstream/pass-git-helper/setup.py", line 1, in from setuptools import setup File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 16, in import setuptools.version File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in import pkg_resources File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3239, in def _initialize_master_working_set(): File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3222, in _call_aside f(*args, **kwargs) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set tuple( File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3265, in dist.activate(replace=False) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2780, in activate declare_namespace(pkg) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2279, in declare_namespace _handle_ns(packageName, path_item) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2196, in _handle_ns loader = importer.find_spec(packageName) AttributeError: 'zipimporter' object has no attribute 'find_spec' ``` This error happens now also with different tools. Solution is to `rm -fr ~/.local/lib`. But the next installation triggers the bug again. The only solution is to install via `python3 setup.py install --user --old-and-unmanageable`. When I look into the code of zipimport(er), I do not see any find_spec only the old find_loader. Despite it is a core library, this must be fixed! And with that the name should match the name of the py file to make it able to find the relevant file. ---------- components: Library (Lib) messages: 384279 nosy: mowgli priority: normal severity: normal status: open title: AttributeError: 'zipimporter' object has no attribute 'find_spec' type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 15:52:35 2021 From: report at bugs.python.org (Dustin Rodrigues) Date: Sun, 03 Jan 2021 20:52:35 +0000 Subject: [New-bugs-announce] [issue42819] readline 8.1 bracketed paste Message-ID: <1609707155.89.0.22999518491.issue42819@roundup.psfhosted.org> New submission from Dustin Rodrigues : Readline 8.1 enables bracketed paste by default. Package managers like Homebrew for macOS and distributions like Arch Linux which use the latest version of readline (released December 2020) now have new behavior when pasting multiline strings into the python REPL. Disabling bracketed paste on 8.1 reverts to the expected behavior, and enabling bracketed paste on 8.0 also reproduces the behavior. Further information in https://github.com/Homebrew/homebrew-core/issues/68193 Example with bracketed paste on: $ cat in 1+2 3+4 5+6 $ pbcopy < in $ /usr/local/Cellar/python\@3.9/3.9.1_3/bin/python3 Python 3.9.1 (default, Dec 28 2020, 11:22:14) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1+2 3+4 5+6 File "", line 1 1+2 3+4 5+6 ^ SyntaxError: multiple statements found while compiling a single statement >>> Example with it off: $ /usr/local/bin/python3 Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:10:52) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1+2 3 >>> 3+4 7 >>> 5+6 11 >>> ---------- messages: 384297 nosy: dtrodrigues priority: normal severity: normal status: open title: readline 8.1 bracketed paste type: behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 3 20:28:14 2021 From: report at bugs.python.org (Tim Hoffmann) Date: Mon, 04 Jan 2021 01:28:14 +0000 Subject: [New-bugs-announce] [issue42820] Sphinx conf.py needs_version entry is outdated Message-ID: <1609723694.82.0.961390909546.issue42820@roundup.psfhosted.org> New submission from Tim Hoffmann : The sphinx conf.py entry `needs_version=1.8` (https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/conf.py#L48) is not in sync with the doc build requirements (https://github.com/python/cpython/blob/1470edd6131c29b8a09ce012cdfee3afa269d553/Doc/requirements.txt#L6) Possible solutions: a) Drop the `needs_version` config value. It's optional. b) Make sure to update both places. c) Or at minimum add a comment that `needs_version` is only a safeguard against very old sphinx versions but is not necessarily sufficient to build. ---------- assignee: docs at python components: Documentation messages: 384305 nosy: docs at python, timhoffm priority: normal severity: normal status: open title: Sphinx conf.py needs_version entry is outdated _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 03:00:54 2021 From: report at bugs.python.org (karl) Date: Mon, 04 Jan 2021 08:00:54 +0000 Subject: [New-bugs-announce] [issue42821] HTMLParser: subsequent duplicate attributes should be ignored Message-ID: <1609747254.8.0.505282394857.issue42821@roundup.psfhosted.org> New submission from karl : This comes up while working on issue 41748 browser input data:text/html,
text
browser output
text
Actual HTMLParser output see https://github.com/python/cpython/pull/24072#discussion_r551158342 ('starttag', 'div', [('class', 'bar'), ('class', 'foo')])] Expected HTMLParser output ('starttag', 'div', [('class', 'bar')])] ---------- components: Library (Lib) messages: 384308 nosy: karlcow priority: normal severity: normal status: open title: HTMLParser: subsequent duplicate attributes should be ignored versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 08:03:42 2021 From: report at bugs.python.org (Julien Palard) Date: Mon, 04 Jan 2021 13:03:42 +0000 Subject: [New-bugs-announce] [issue42822] Missing backslashes in documentation for 3.8 and 3.9 Message-ID: <1609765422.49.0.483236804978.issue42822@roundup.psfhosted.org> New submission from Julien Palard : This is just to track the issue, initially reported here: https://github.com/python/python-docs-theme/issues/63 Then discussed here: https://github.com/python/cpython/pull/23827#issuecomment-753598860 Then reverted: - in 3.8 https://github.com/python/cpython/pull/24093 - in 3.9 https://github.com/python/cpython/pull/24092 I edited the revert to keep only relevant parts, as only a few bits of the commit were causing troubles. Issue is: Sphinx 2 and Sphinx 3 have incompatible handling of backslahes, fixing them for Sphinx 3 in Python 3.10, then backporting to 3.8 and 3.9 which use Sphinx 2 caused an issue: `\n` for example are rendered as `n`, easy to notice in the documentaion of print: print(*objects, sep=' ', end='n', file=sys.stdout, flush=False)? As migration to Sphinx 3 was hard (done for Python 3.10 documentation), it won't be backported to 3.8 and 3.9, which will still be built using Sphinx 2, so some bits had to be reverted for the doc to display the backslash of `\n`. ---------- assignee: mdk components: Documentation messages: 384324 nosy: adelfino, mdk priority: normal severity: normal stage: commit review status: open title: Missing backslashes in documentation for 3.8 and 3.9 versions: Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 11:32:45 2021 From: report at bugs.python.org (Mark Shannon) Date: Mon, 04 Jan 2021 16:32:45 +0000 Subject: [New-bugs-announce] [issue42823] Incorrect frame.f_lineno when frame.f_trace is set Message-ID: <1609777965.06.0.667792191004.issue42823@roundup.psfhosted.org> New submission from Mark Shannon : The logic for frame.f_lineno assumes that the internal C field will be updated when f_trace is set, but that is incorrect. Consequently, the following code import sys def print_line(): print(sys._getframe(1).f_lineno) def test(): print_line() sys._getframe(0).f_trace = True print_line() print_line() test() prints 7 8 8 it should print 7 9 10 Fixing this is required by PEP 626, but it should be fixed anyway. ---------- assignee: Mark.Shannon messages: 384331 nosy: Mark.Shannon priority: normal severity: normal status: open title: Incorrect frame.f_lineno when frame.f_trace is set _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 11:55:18 2021 From: report at bugs.python.org (Fabian.M) Date: Mon, 04 Jan 2021 16:55:18 +0000 Subject: [New-bugs-announce] [issue42824] get_type_hints throws for local class reference Message-ID: <1609779318.04.0.39059957238.issue42824@roundup.psfhosted.org> New submission from Fabian.M : The following code throws with "NameError: name 'Nested' is not defined". For reference, it works well when moving class definitions out of the local scope. import typing T = typing.TypeVar('T') def test(): class Nested(typing.Generic[T]): pass class Test(typing.Generic[T]): nested: Nested[T] typing.get_type_hints(Test) # this throws test() ---------- components: Library (Lib) messages: 384332 nosy: Fabian.M priority: normal severity: normal status: open title: get_type_hints throws for local class reference type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 12:42:40 2021 From: report at bugs.python.org (Austin Lamb) Date: Mon, 04 Jan 2021 17:42:40 +0000 Subject: [New-bugs-announce] [issue42825] Optimization opportunity on Windows Message-ID: <1609782160.13.0.0224895080942.issue42825@roundup.psfhosted.org> New submission from Austin Lamb : I noticed that CPython and the various libraries built out of the repo aren't using the "/OPT:REF" linker optimization on Windows. This optimization allows the linker to throw away dead/unreachable code, resulting in a substantial decrease in binary size. That in turn also reduces the amount of Disk I/O that must be done to get these binaries in memory (which can be meaningful on spinning hard drives that are still rather common), and the reference set of applications using Python. I'll send a PR for this shortly, just filing the issue to be able to reference it in the PR. ---------- components: Windows messages: 384333 nosy: Austin-Lamb, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Optimization opportunity on Windows type: performance versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 12:47:07 2021 From: report at bugs.python.org (=?utf-8?q?Peter_Pavlini=C4=8D?=) Date: Mon, 04 Jan 2021 17:47:07 +0000 Subject: [New-bugs-announce] [issue42826] typing.Iterable does not need__getitem__() method Message-ID: <1609782427.22.0.495333991832.issue42826@roundup.psfhosted.org> New submission from Peter Pavlini? : https://docs.python.org/3.10/glossary.html#term-iterable ---------- assignee: docs at python components: Documentation messages: 384334 nosy: docs at python, peter.pavlinic priority: normal severity: normal status: open title: typing.Iterable does not need__getitem__() method type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 4 15:48:09 2021 From: report at bugs.python.org (Julien Palard) Date: Mon, 04 Jan 2021 20:48:09 +0000 Subject: [New-bugs-announce] [issue42827] Multiline eval with assignment to function call segfaults Message-ID: <1609793289.79.0.762652539307.issue42827@roundup.psfhosted.org> New submission from Julien Palard : Tested in 3.9.0 and master (127dde5916): $ cat test.py eval( """[file for str(file) in [] ] """ ) $ ./python test.py python: Parser/pegen.c:149: byte_offset_to_character_offset: Assertion `col_offset >= 0 && (unsigned long)col_offset <= strlen(str)' failed. Fatal Python error: Aborted Current thread 0x00007f6454cfe280 (most recent call first): File "/home/mdk/clones/python/cpython/test.py", line 1 in Aborted (core dumped) (Adding Guido and Pablo to nosy as, IIRC, you're interested in parser things :)) ---------- messages: 384348 nosy: gvanrossum, mdk, pablogsal priority: normal severity: normal status: open title: Multiline eval with assignment to function call segfaults type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 05:19:01 2021 From: report at bugs.python.org (Marco Franzo) Date: Tue, 05 Jan 2021 10:19:01 +0000 Subject: [New-bugs-announce] [issue42828] Python readline module Message-ID: <1609841941.92.0.341483279239.issue42828@roundup.psfhosted.org> New submission from Marco Franzo : It would be better to write at the end of the program this: os.system('stty sane') because when you import readline, at the end of program, the console remains unusable ---------- assignee: docs at python components: Documentation messages: 384379 nosy: docs at python, frenzisys priority: normal severity: normal status: open title: Python readline module type: enhancement versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 06:18:32 2021 From: report at bugs.python.org (Svyatoslav) Date: Tue, 05 Jan 2021 11:18:32 +0000 Subject: [New-bugs-announce] [issue42829] get_type_hints throws for nested class with __future__ annotations Message-ID: <1609845512.57.0.0433631135188.issue42829@roundup.psfhosted.org> New submission from Svyatoslav : If a class X has nested class Y and class X has annotation Y AFTER the definition of Y, get_type_hints(X) throws NameError if import from future annotations is present. This is because get_type_hints looks only at mro of the class. Its namespace must be included too as locals. ---------- files: annotations.py messages: 384381 nosy: Prometheus3375 priority: normal severity: normal status: open title: get_type_hints throws for nested class with __future__ annotations versions: Python 3.9 Added file: https://bugs.python.org/file49719/annotations.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 06:28:47 2021 From: report at bugs.python.org (=?utf-8?b?TWllY3p5c8WCYXcgVG9yY2hhxYJh?=) Date: Tue, 05 Jan 2021 11:28:47 +0000 Subject: [New-bugs-announce] [issue42830] tempfile mkstemp() leaks file descriptors if os.close() is not called Message-ID: <1609846127.44.0.860192251042.issue42830@roundup.psfhosted.org> New submission from Mieczys?aw Torcha?a : tempfile mkstemp() documentation says: "Unlike TemporaryFile(), the user of mkstemp() is responsible for deleting the temporary file when done with it." mkstemp() returns a tuple: file_descriptor, file_path = mkstemp() Calling only os.unlink(file_path) removes the file, but causes leaking file descriptors and when the number of temporary files created is higher than `ulimit -n`, the process crashes (see /proc/$pid/fd in real time until crash). The solution I found is to also call on descriptor: os.close(file_descriptor) but the documentation doesn't mention that (i.e. releasing file descriptor in addition to removing temporary file). For many users it doesn't matter as they create a few files and when the process finishes, leaking file descriptors are released. However, when a lot of files is created during the execution, it will finally crash (unless someone has a huge ulimit -n setting). If this is not a bug, at least the documentation should mention that both the temp file needs to be removed and the file descriptor released. However, this means calling two commands when only one command was used to create the temporary file. Therefore, maybe adding a function to tempfile library to fully remove a file without a leaking file descriptor is a solution. ---------- components: Library (Lib) messages: 384384 nosy: mieczyslaw.torchala priority: normal severity: normal status: open title: tempfile mkstemp() leaks file descriptors if os.close() is not called type: resource usage versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 07:54:54 2021 From: report at bugs.python.org (E. Paine) Date: Tue, 05 Jan 2021 12:54:54 +0000 Subject: [New-bugs-announce] [issue42831] IDLE fix colours for MacOS dark mode Message-ID: <1609851294.14.0.191191657845.issue42831@roundup.psfhosted.org> New submission from E. Paine : Currently IDLE, in some places, uses predefined colours which assume it is in light mode. However, on the new Universal2 installers (I tested using 3.10.0a4) this causes issues, where this can no longer be assumed. Taking the "About IDLE" dialogue as an example, it appears in a light theme and most notably makes button text very hard to read (as this is changed to white). I propose, on macOS systems running Tk >=8.6.10, we try to switch these colours to the system colours described in https://github.com/tcltk/tk/blob/main/macosx/README (IMO, we would test colour availability and catch a TclError rather than specifying conditions ourselves). For the about dialogue I think we would, for example, replace `#bbbbbb` with one of the `systemWindowBackgroundColor`s. ---------- assignee: terry.reedy components: IDLE messages: 384391 nosy: epaine, taleinat, terry.reedy priority: normal severity: normal status: open title: IDLE fix colours for MacOS dark mode versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 10:07:33 2021 From: report at bugs.python.org (Irit Katriel) Date: Tue, 05 Jan 2021 15:07:33 +0000 Subject: [New-bugs-announce] [issue42832] classmethod change in 3.9 needs better documentation Message-ID: <1609859253.42.0.13260337218.issue42832@roundup.psfhosted.org> New submission from Irit Katriel : The change in issue 19072 broke our code where a decorator assumes that __get__ is only called for instance methods. It might be worth adding this to What's new in 3.9. Also in the documentation: https://docs.python.org/3/library/functions.html#classmethod It implies that before 3.9 it was not possible to wrap, but it was possible, it just behaved differently. ---------- assignee: docs at python components: Documentation messages: 384404 nosy: docs at python, iritkatriel priority: normal severity: normal status: open title: classmethod change in 3.9 needs better documentation type: behavior versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 10:35:06 2021 From: report at bugs.python.org (Pierre Tardy) Date: Tue, 05 Jan 2021 15:35:06 +0000 Subject: [New-bugs-announce] [issue42833] Lib/urllib/request.py: digest algorithm should be case insensitive Message-ID: <1609860906.08.0.978981588338.issue42833@roundup.psfhosted.org> New submission from Pierre Tardy : original bug report: https://github.com/buildbot/buildbot/issues/5743 Twisted by default advertises its algorithm in lowercase, which is uncommon, but allowed by the spec. https://tools.ietf.org/html/rfc3230#section-4.1.1 python's request.py is only supporting MD5 or SHA as algorithm, and not lowercase equivalent. This is an easy and harmless fix. ---------- messages: 384409 nosy: Pierre.Tardy priority: normal severity: normal status: open title: Lib/urllib/request.py: digest algorithm should be case insensitive type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 10:54:05 2021 From: report at bugs.python.org (Ken Jin) Date: Tue, 05 Jan 2021 15:54:05 +0000 Subject: [New-bugs-announce] [issue42834] [subinterpreters] Convert "global" static variable caches in _json to heap variables Message-ID: <1609862045.06.0.177130417143.issue42834@roundup.psfhosted.org> New submission from Ken Jin : _json currently uses a few static locals for caching of PyUnicode and one Exception object. This patch aims to move them to the heap. Apologies if this isn't the right way to track subinterpreter issues, I took a look at issue36876 but it seemed like a meta issue to me. ---------- components: Library (Lib), Subinterpreters messages: 384411 nosy: eric.snow, kj, vstinner priority: normal severity: normal status: open title: [subinterpreters] Convert "global" static variable caches in _json to heap variables versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Jan 5 18:53:31 2021 From: report at bugs.python.org (Michael L. Boom) Date: Tue, 05 Jan 2021 23:53:31 +0000 Subject: [New-bugs-announce] [issue42835] Can't Built libxml2 When Using Python 3.9.x Message-ID: <1609890811.68.0.419297459642.issue42835@roundup.psfhosted.org> New submission from Michael L. Boom : When building libxml2 using Python 3.9.0 or Python 3.9.1 and gcc 10.2.0 I get the below error. Others are having this problem according to my Google search. make[4]: Entering directory '/local/users/michael.l.boom/gits/scoring_engine/git/aae_tmp_dir/libxml2-2.9.10/python' CC libxml.lo CC libxml2-py.lo CC types.lo In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/pytime.h:6, from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:85, from libxml_wrap.h:1, from types.c:9: types.c: In function ?libxml_xmlXPathObjectPtrConvert?: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/object.h:633:41: error: expected ?(? before ?PyType_HasFeature? 633 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) | ^~~~~~~~~~~~~~~~~ /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/longobject.h:15:9: note: in expansion of macro ?PyType_FastSubclass? 15 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) | ^~~~~~~~~~~~~~~~~~~ types.c:607:15: note: in expansion of macro ?PyLong_Check? 607 | } else if PyLong_Check(obj) { | ^~~~~~~~~~~~ types.c:607:33: error: expected ?;? before ?{? token 607 | } else if PyLong_Check(obj) { | ^ libxml.c: In function ?xmlPythonFileCloseRaw?: libxml.c:259:5: warning: ?PyEval_CallMethod? is deprecated [-Wdeprecated-declarations] 259 | ret = PyEval_CallMethod(file, (char *) "close", (char *) "()"); | ^~~ In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:145, from libxml.c:14: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/ceval.h:28:43: note: declared here 28 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod( | ^~~~~~~~~~~~~~~~~ libxml.c: In function ?xmlPythonFileReadRaw?: libxml.c:289:5: warning: ?PyEval_CallMethod? is deprecated [-Wdeprecated-declarations] 289 | ret = PyEval_CallMethod(file, (char *) "read", (char *) "(i)", len); | ^~~ In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:145, from libxml.c:14: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/ceval.h:28:43: note: declared here 28 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod( | ^~~~~~~~~~~~~~~~~ In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/pytime.h:6, from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:85, from libxml.c:14: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/object.h:633:41: error: expected ?(? before ?PyType_HasFeature? 633 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) | ^~~~~~~~~~~~~~~~~ /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/unicodeobject.h:115:18: note: in expansion of macro ?PyType_FastSubclass? 115 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) | ^~~~~~~~~~~~~~~~~~~ libxml.c:297:15: note: in expansion of macro ?PyUnicode_Check? 297 | } else if PyUnicode_Check (ret) { | ^~~~~~~~~~~~~~~ libxml.c:297:37: error: expected ?;? before ?{? token 297 | } else if PyUnicode_Check (ret) { | ^ libxml.c: In function ?xmlPythonFileRead?: libxml.c:354:5: warning: ?PyEval_CallMethod? is deprecated [-Wdeprecated-declarations] 354 | ret = PyEval_CallMethod(file, (char *) "io_read", (char *) "(i)", len); | ^~~ In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:145, from libxml.c:14: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/ceval.h:28:43: note: declared here 28 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod( | ^~~~~~~~~~~~~~~~~ In file included from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/pytime.h:6, from /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/Python.h:85, from libxml.c:14: /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/object.h:633:41: error: expected ?(? before ?PyType_HasFeature? 633 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) | ^~~~~~~~~~~~~~~~~ /local/users/michael.l.boom/gits/scoring_engine/git/aae_build_python_3.9.1/include/python3.9/unicodeobject.h:115:18: note: in expansion of macro ?PyType_FastSubclass? 115 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) | ^~~~~~~~~~~~~~~~~~~ libxml.c:362:15: note: in expansion of macro ?PyUnicode_Check? 362 | } else if PyUnicode_Check (ret) { | ^~~~~~~~~~~~~~~ libxml.c:362:37: error: expected ?;? before ?{? token 362 | } else if PyUnicode_Check (ret) { | ^ ---------- components: C API messages: 384443 nosy: boom0192 priority: normal severity: normal status: open title: Can't Built libxml2 When Using Python 3.9.x type: compile error versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 04:05:31 2021 From: report at bugs.python.org (Sandeep Subramanian) Date: Wed, 06 Jan 2021 09:05:31 +0000 Subject: [New-bugs-announce] [issue42836] docs: struct: clarify struct caching behaviour Message-ID: <1609923931.89.0.0226570295473.issue42836@roundup.psfhosted.org> New submission from Sandeep Subramanian : As per docs in :https://docs.python.org/3.7/library/struct.html#struct.Struct > The compiled versions of the most recent format strings passed to Struct and the module-level functions are cached, so programs that use only a few format strings needn?t worry about reusing a single Struct instance. This statement seems to imply that the format string passed as `struct.Struct(format)` is also cached. This doesn't appear to be the case. Only format strings passed to the module level functions seems to be cached. `cache_struct_converter` at https://github.com/python/cpython/blob/v3.7.7/Modules/_struct.c#L2052 appears to be used only in the top module level functions `pack` and `pack_into` and is *not* used in `Struct.__init__`. Would it be better to change the doc to: > The compiled versions of the most recent format strings passed to the module-level functions are cached, so programs that use only a few format strings needn?t worry about reusing a single Struct instance. This issue was introduced by https://github.com/python/cpython/commit/3666b3c1f695a145adab1bf644c22e564e8eb0ee and is present in every version since. Refs: https://github.com/python/cpython/pull/7700 https://bugs.python.org/issue33032 ---------- assignee: docs at python components: Documentation messages: 384476 nosy: docs at python, sandeep2 priority: normal severity: normal status: open title: docs: struct: clarify struct caching behaviour type: enhancement versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 04:51:20 2021 From: report at bugs.python.org (Mark Shannon) Date: Wed, 06 Jan 2021 09:51:20 +0000 Subject: [New-bugs-announce] [issue42837] Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation Message-ID: <1609926680.76.0.190133632062.issue42837@roundup.psfhosted.org> New submission from Mark Shannon : This is an internal inconsistency. I have not identified any surface level bugs, but it is a trap for future compiler work. ---------- assignee: Mark.Shannon messages: 384479 nosy: Mark.Shannon, larry priority: normal severity: normal status: open title: Symbol table incorrectly identifies code as a generator, when 'yield' occurs in an annotation _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 08:56:08 2021 From: report at bugs.python.org (xloem) Date: Wed, 06 Jan 2021 13:56:08 +0000 Subject: [New-bugs-announce] [issue42838] Wait for cleanup coroutines before event loop is closed. Message-ID: <1609941368.33.0.950412728581.issue42838@roundup.psfhosted.org> New submission from xloem <0xloem at gmail.com>: To handle destruction of resources especially during exceptions, it would be nice if there were some way to provide coroutines/tasks that run at the termination or closure of an event loop. There are a lot of api options here. Maybe a simple one would be to have close() call a run_until_closed() function that starts all of these and steps the loop to wait for them, before closing, and provide run_close() functions to queue them for delay. ---------- components: asyncio messages: 384503 nosy: asvetlov, xloem, yselivanov priority: normal severity: normal status: open title: Wait for cleanup coroutines before event loop is closed. type: enhancement versions: Python 3.10, Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 09:32:12 2021 From: report at bugs.python.org (favonia) Date: Wed, 06 Jan 2021 14:32:12 +0000 Subject: [New-bugs-announce] [issue42839] SourceFileLoader does not (fully) accept path-like objects Message-ID: <1609943532.78.0.260162878801.issue42839@roundup.psfhosted.org> New submission from favonia : If one uses the loader created by importlib.machinery.SourceFileLoader(module_name, path) in a meta path finder, where path is not a str, then the following error would happen at the moment the module is being imported. Note that, the error would not occur if the corresponding bytecode cache (__pycache__/*.pyc) is present. File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 972, in _find_and_load_unlocked File "", line 228, in _call_with_frames_removed File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 786, in exec_module File "", line 932, in get_code File "", line 604, in _code_to_timestamp_pyc ValueError: unmarshallable object Here is an example that could trigger the error. The package unipath is not very important except that unipath.Path is not marshallable. (Any library with a fancy, unmarshallable path-like object would work.) The choice of 'local' and the use of 'os.getcwd()' are also irrelevant. The actual production code is quite complicated, using different path-like objects and convoluted logic. I made up this example from scratch. import os import sys import importlib import importlib.abc import importlib.util from unipath import Path # just an example class DummyFinder(importlib.abc.MetaPathFinder): def __init__(self): self.cwd = os.getcwd() def find_spec(self, fullname, path, target=None): if fullname == 'local': initpath = os.path.join(self.cwd, '__init__.py') if os.path.isfile(initpath): loader = importlib.machinery.SourceFileLoader(fullname, Path(initpath)) # some non-str Path-like object here return importlib.util.spec_from_file_location(fullname, initpath, loader = loader, submodule_search_locations=[self.cwd]) else: return None sys.meta_path.append(DummyFinder()) importlib.import_module("local.test2") If this is indeed a bug, there might be other classes and functions in importlib that share the same problem. ---------- components: Library (Lib) messages: 384504 nosy: favonia priority: normal severity: normal status: open title: SourceFileLoader does not (fully) accept path-like objects type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 10:21:21 2021 From: report at bugs.python.org (Erik Soma) Date: Wed, 06 Jan 2021 15:21:21 +0000 Subject: [New-bugs-announce] [issue42840] `type` takes **kwargs for __init_subclass__ Message-ID: <1609946481.51.0.225785046936.issue42840@roundup.psfhosted.org> New submission from Erik Soma : The documentation (https://docs.python.org/3/library/functions.html#type) shows type's signature as: class type(object) class type(name, bases, dict) But the "actual" 2nd signature in CPython 3.6+ is: class type(name, bases, dict, **kwargs) **kwargs here gets passed to __init_subclass__ in the same way that keywords in a class statement do so that: type("Bar", (Foo,), {}, spam='ham') is equivalent to class Bar(Foo, spam='ham'): pass It's not clear to me whether this is behavior to rely on. I started using this intuitively, but found that my type checker reasonably complained. Looking through the commit that implemented PEP 487 (d78448e9), it seems this may have been incidental. Additionally I haven't found mention of this in PEP 487 or the documentation and I can't seem to find any tests for it. ---------- messages: 384506 nosy: esoma priority: normal severity: normal status: open title: `type` takes **kwargs for __init_subclass__ type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 10:27:26 2021 From: report at bugs.python.org (Yurii Karabas) Date: Wed, 06 Jan 2021 15:27:26 +0000 Subject: [New-bugs-announce] [issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping Message-ID: <1609946846.04.0.311249244168.issue42841@roundup.psfhosted.org> New submission from Yurii Karabas <1998uriyyo at gmail.com>: In python3.9 `dict` `bitwise or` operator was introduced. I think it will be great if `collections.abc.Mapping` and `collections.abc.MutableMapping` will have a default implementation of `bitwise or` operator. ---------- messages: 384507 nosy: uriyyo priority: normal severity: normal status: open title: Add bitwise or operator to collections.abc Mapping and MutableMapping _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 11:30:16 2021 From: report at bugs.python.org (sasquatchplatypus) Date: Wed, 06 Jan 2021 16:30:16 +0000 Subject: [New-bugs-announce] [issue42842] import logging.handlers shows weird behavior Message-ID: <1609950616.34.0.697361127063.issue42842@roundup.psfhosted.org> New submission from sasquatchplatypus : when trying to import a handler from logging.handlers, you have to explicitely import logging.handlers, because trying to get it from logging directly (for example import logging, logging.handlers.RotatingFileHandlers) raises this error: AttributeError: module 'logging' has no attribute 'handlers' ---------- messages: 384509 nosy: sasquatchplatypus priority: normal severity: normal status: open title: import logging.handlers shows weird behavior type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 11:52:46 2021 From: report at bugs.python.org (Julien Palard) Date: Wed, 06 Jan 2021 16:52:46 +0000 Subject: [New-bugs-announce] [issue42843] What min_sphinx for Python 3.10 Message-ID: <1609951966.97.0.867485424131.issue42843@roundup.psfhosted.org> New submission from Julien Palard : According to [1] there's no concensus on which minimum Sphinx version we should use for Python 3.10. "sadly" since https://github.com/python/cpython/pull/23620 which make use of a Sphinx 3.2.0 only feature, we should bump it to 3.2, but it may not work for everybody. [1]: https://github.com/python/cpython/pull/23620#issuecomment-755420205 ---------- assignee: mdk components: Documentation messages: 384512 nosy: mdk priority: normal severity: normal status: open title: What min_sphinx for Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 12:00:12 2021 From: report at bugs.python.org (Stephen) Date: Wed, 06 Jan 2021 17:00:12 +0000 Subject: [New-bugs-announce] [issue42844] Turtle Module -- "onclick" arguments enchancement Message-ID: <1609952412.13.0.0764333219073.issue42844@roundup.psfhosted.org> New submission from Stephen : I have created an enhancement in the Turtle module. When a programmer wants to have an action performed after clicking on a Turtle object, the programmer is currently unable to supply any arguments into the method that is run when "on_clicked" which is extremely limiting, especially to beginners who are looking to modify multiple objects on the screen at one time, such as in a game. I have modified the implementation of the ?on_clicked? method to be able to provide keyword arguments into the method through a dictionary that is later unpacked into the target method. Attached is an example of the benefits of this enhancement to the turtle module. ---------- components: Library (Lib) files: on_click_arguments_example.py messages: 384513 nosy: sc1341 priority: normal severity: normal status: open title: Turtle Module -- "onclick" arguments enchancement type: enhancement versions: Python 3.10 Added file: https://bugs.python.org/file49723/on_click_arguments_example.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 12:08:08 2021 From: report at bugs.python.org (Shreyan Avigyan) Date: Wed, 06 Jan 2021 17:08:08 +0000 Subject: [New-bugs-announce] [issue42845] Third Party Module Installation using pip fails in Python 3.10.0a3 Message-ID: <1609952888.82.0.0280575677398.issue42845@roundup.psfhosted.org> New submission from Shreyan Avigyan : A few days ago, I tried installing Python 3.10.a3 for testing. After installing, I tried using the Python built-in modules, they were working fine. Then I tried going for installing third party modules using pip from the command prompt. While installing I noticed that some modules I could install perfectly but for most of the modules, they failed to install. After trying to install them, I tried looking for the full error message. After a lot of searching I found out that it is looking for Microsoft Visual C++ and couldn't find it because I haven't installed it and gave me that error. I haven't tried installing Python 3.10.0a4 yet and I don't know if it's already solved or not but this problem is continuously occurring in Python 3.10.0a3. ---------- components: Installation messages: 384515 nosy: shreyanavigyan priority: normal severity: normal status: open title: Third Party Module Installation using pip fails in Python 3.10.0a3 versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 17:38:22 2021 From: report at bugs.python.org (neonene) Date: Wed, 06 Jan 2021 22:38:22 +0000 Subject: [New-bugs-announce] [issue42846] Using _multibytecodec module on Windows, test_threading/embed get failure Message-ID: <1609972702.01.0.789985510588.issue42846@roundup.psfhosted.org> New submission from neonene : After https://github.com/python/cpython/commit/0b858cdd5d114f0890b11b6c4d6559d0ceb468ab (bpo-1635741: Convert _multibytecodec to multi-phase init), On Windows x64/x86 with chinese/japanese/korean system-locale, MultibyteCodec_Check() in multibytecodec.c returns false and PyExc_TypeError follows. This affects some tests and PGO training. 1) python -m test --verbose test_threading ====================================================================== FAIL: test_daemon_threads_fatal_error (test.test_threading.SubinterpThreadi ngTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\cpython-0b858\lib\test\test_threading.py", line 1124, in test_da emon_threads_fatal_error self.assertIn("Fatal Python error: Py_EndInterpreter: " AssertionError: 'Fatal Python error: Py_EndInterpreter: not the last thread ' not found in 'TypeError: codec is unexpected type\nFatal Python error: _P yThreadState_Delete: tstate 00000000003FF980 is still current\nPython runti me state: initialized\n\nThread 0x00000710 (most recent call first):\n\n' 2) python -m test --verbose test_embed ====================================================================== FAIL: test_audit_subinterpreter (test.test_embed.AuditingTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\cpython-0b858\lib\test\test_embed.py", line 1433, in test_audit_ subinterpreter self.run_embedded_interpreter("test_audit_subinterpreter") File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded _interpreter self.assertEqual(p.returncode, returncode, AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete : tstate 000000000050CAF0 is still current\nPython runtime state: initializ ed\n\nThread 0x000009d8 (most recent call first):\n\n' ====================================================================== FAIL: test_subinterps_different_ids (test.test_embed.EmbeddingTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\cpython-0b858\lib\test\test_embed.py", line 169, in test_subinte rps_different_ids for run in self.run_repeated_init_and_subinterpreters(): File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated _init_and_subinterpreters out, err = self.run_embedded_interpreter("test_repeated_init_and_subint erpreters") File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded _interpreter self.assertEqual(p.returncode, returncode, AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete : tstate 000000000041C960 is still current\nPython runtime state: initializ ed\n\nThread 0x00000a40 (most recent call first):\n\n' ====================================================================== FAIL: test_subinterps_distinct_state (test.test_embed.EmbeddingTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\cpython-0b858\lib\test\test_embed.py", line 177, in test_subinte rps_distinct_state for run in self.run_repeated_init_and_subinterpreters(): File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated _init_and_subinterpreters out, err = self.run_embedded_interpreter("test_repeated_init_and_subint erpreters") File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded _interpreter self.assertEqual(p.returncode, returncode, AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete : tstate 000000000047C960 is still current\nPython runtime state: initializ ed\n\nThread 0x00000b34 (most recent call first):\n\n' ====================================================================== FAIL: test_subinterps_main (test.test_embed.EmbeddingTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\cpython-0b858\lib\test\test_embed.py", line 163, in test_subinte rps_main for run in self.run_repeated_init_and_subinterpreters(): File "C:\cpython-0b858\lib\test\test_embed.py", line 110, in run_repeated _init_and_subinterpreters out, err = self.run_embedded_interpreter("test_repeated_init_and_subint erpreters") File "C:\cpython-0b858\lib\test\test_embed.py", line 104, in run_embedded _interpreter self.assertEqual(p.returncode, returncode, AssertionError: 3221225477 != 0 : bad returncode 3221225477, stderr is 'Typ eError: codec is unexpected type\nFatal Python error: _PyThreadState_Delete : tstate 000000000032C960 is still current\nPython runtime state: initializ ed\n\nThread 0x00000bf0 (most recent call first):\n\n' ---------- components: Extension Modules, Subinterpreters, Tests, Windows messages: 384541 nosy: corona10, erlendaasland, neonene, paul.moore, petr.viktorin, shihai1991, steve.dower, tim.golden, vstinner, zach.ware priority: normal severity: normal status: open title: Using _multibytecodec module on Windows, test_threading/embed get failure type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 18:41:04 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Wed, 06 Jan 2021 23:41:04 +0000 Subject: [New-bugs-announce] [issue42847] Normalise file encodings in Lib/sqlite3/test/ Message-ID: <1609976464.16.0.541873091964.issue42847@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : GitHub does not play well with other file encodings than UTF-8. For example, when the "suggestion" in https://github.com/python/cpython/pull/20538#discussion_r552926126 was applied, GitHub silently converted Lib/sqlite3/test/types.py from ISO-8859 to UTF-8, as seen in the resulting commit fd4f65141925f2d84e0efd17ca4b9395c171d7ba. Apart from being annoying, this created an inconsistency between the `#-*- coding: iso-8859-1 -*-` header in Lib/sqlite3/test/types.py and its actual encoding (now UTF-8). I suggest to convert Lib/sqlite3/test/* to UTF-8 encoding for consistency. $ file Lib/sqlite3/test/*.py Lib/sqlite3/test/backup.py: Python script text executable, ASCII text Lib/sqlite3/test/dbapi.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/dump.py: Python script text executable, ASCII text Lib/sqlite3/test/factory.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/hooks.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/regression.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/transactions.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/types.py: Python script text executable, ISO-8859 text Lib/sqlite3/test/userfunctions.py: Python script text executable, UTF-8 Unicode text ---------- components: Library (Lib) messages: 384543 nosy: berker.peksag, erlendaasland priority: normal severity: normal status: open title: Normalise file encodings in Lib/sqlite3/test/ versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 21:10:12 2021 From: report at bugs.python.org (asleep-cult) Date: Thu, 07 Jan 2021 02:10:12 +0000 Subject: [New-bugs-announce] [issue42848] asyncio produces an unexpected traceback with recursive __getattribute__ Message-ID: <1609985412.09.0.749639106788.issue42848@roundup.psfhosted.org> New submission from asleep-cult : The code below produces an unexpected traceback format that makes the source of an error very hard to find, this more than likely happens in less specific situations but this is how I came across it. I'm also not sure if this is an issue with asyncio, logging or the traceback module. import asyncio class Bar: def __init__(self): self.y = None class Foo: def __init__(self): self._bar = Bar() self.y def __getattribute__(self, name): try: attr = super().__getattribute__(name) except AttributeError as e: try: attr = self.ooops_spelled_bar_wrong.__getattribute__(name) except AttributeError: raise e return attr async def foo(): Foo() loop = asyncio.get_event_loop() loop.create_task(foo()) loop.run_forever() Traceback: Exception in default exception handler Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1733, in call_exception_handler self.default_exception_handler(context) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1707, in default_exception_handler logger.error('\n'.join(log_lines), exc_info=exc_info) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1471, in error self._log(ERROR, msg, args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1585, in _log self.handle(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1595, in handle self.callHandlers(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1665, in callHandlers lastResort.handle(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 950, in handle self.emit(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1081, in emit msg = self.format(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 925, in format return fmt.format(record) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 672, in format record.exc_text = self.formatException(record.exc_info) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 622, in formatException traceback.print_exception(ei[0], ei[1], tb, None, sio) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 103, in print_exception for line in TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( [Previous line repeated 488 more times] File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 476, in __init__ _seen.add(id(exc_value)) RecursionError: maximum recursion depth exceeded while calling a Python object ``` The code below procures the expected traceback import traceback class Bar: def __init__(self): self.y = None class Foo: def __init__(self): self._bar = Bar() self.y def __getattribute__(self, name): try: attr = super().__getattribute__(name) except AttributeError as e: try: attr = self.ooops_spelled_bar_wrong.__getattribute__(name) except AttributeError: raise e return attr try: Foo() except: traceback.print_exc() Traceback: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:/Development/test/test.py", line 15, in __getattribute__ attr = super().__getattribute__(name) AttributeError: 'Foo' object has no attribute 'ooops_spelled_bar_wrong' # The part above is repeated hundreds of times Traceback (most recent call last): File "c:/Development/test/test.py", line 24, in Foo() File "c:/Development/test/test.py", line 11, in __init__ self.y File "c:/Development/test/test.py", line 18, in __getattribute__ attr = self.ooops_spelled_bar_wrong.__getattribute__(name) File "c:/Development/test/test.py", line 18, in __getattribute__ attr = self.ooops_spelled_bar_wrong.__getattribute__(name) File "c:/Development/test/test.py", line 18, in __getattribute__ attr = self.ooops_spelled_bar_wrong.__getattribute__(name) [Previous line repeated 992 more times] File "c:/Development/test/test.py", line 15, in __getattribute__ attr = super().__getattribute__(name) RecursionError: maximum recursion depth exceeded while calling a Python object During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:/Development/test/test.py", line 26, in traceback.print_exc() File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 163, in print_exc print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain) File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 103, in print_exception for line in TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\traceback.py", line 493, in __init__ context = TracebackException( [Previous line repeated 495 more times] RecursionError: maximum recursion depth exceeded ---------- components: Library (Lib) messages: 384551 nosy: asleep-cult priority: normal severity: normal status: open title: asyncio produces an unexpected traceback with recursive __getattribute__ type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Jan 6 23:00:06 2021 From: report at bugs.python.org (Zhesi Huang) Date: Thu, 07 Jan 2021 04:00:06 +0000 Subject: [New-bugs-announce] [issue42849] pool worker can't be terminated Message-ID: <1609992006.83.0.897606551243.issue42849@roundup.psfhosted.org> New submission from Zhesi Huang : i see a case, the worker proc of pool can't be terminated, i try kill -SIGTERM or -SIGINT, but it still can't terminated the worker proc, then the pool __exit__ will hang forever ``` class NonDaemonProcess(multiprocessing.Process): # https://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic # make 'daemon' attribute always return False def _get_daemon(self): return False def _set_daemon(self, value): pass daemon = property(_get_daemon, _set_daemon) def wrapper_copy_parallel(output_name, local_output_path, obs_path): log_thread('upload the content of [%s] outputs' % output_name) try: if os.path.exists(local_output_path): log_thread('%s has %d files to be uploaded' % (output_name, len(file_list))) xxxxxx log_thread('upload the content of [%s] outputs successfully' % output_name) log_thread('it can be accessed at obs path [%s]' % obs_path) else: log_thread('local output path is not found, skip upload the content of [%s] outputs' % output_name) except Exception as upload_exception: err_thread('upload the content of [%s] outputs failed: %s' % (output_name, str(upload_exception))) return 255 return 0 def upload_to_s3(): """ upload the content of local path to s3, handle action [on_completed] :return: """ outputs = [] for local_output_path, (output_name, obs_path, action, _, _) in local_to_target.items(): if action == ACTION_ON_COMPLETED: outputs.append((output_name, local_output_path, obs_path)) if len(outputs) == 0: return 0 with NonDaemonPool(processes=len(outputs)) as pool: results = pool.starmap(wrapper_copy_parallel, outputs) for result in results: if result != 0: return result return 0 ``` stdout/stderr log [ma-test Service Log][INFO][2021/01/05 03:07:49,218]: registered signal handler [ma-test Service Log][INFO][2021/01/05 03:09:40,299]: output-handler finalizing [ma-test Service Log][INFO][2021-01-05 03:09:40,309][NonDaemonPoolWorker-1]: child process calling self.run() [ma-test Service Log][INFO][2021-01-05 03:09:40,311][NonDaemonPoolWorker-1]: upload the content of [] outputs [ma-test Service Log][INFO][2021-01-05 03:09:41,331][Process-1:1]: child process calling self.run() [ma-test Service Log][INFO][2021-01-05 03:09:41,333][Process-1:2]: child process calling self.run() [ma-test Service Log][INFO][2021-01-05 03:09:41,338][Process-1:3]: child process calling self.run() [ma-test Service Log][INFO][2021-01-05 03:09:41,351][Process-1:1]: process shutting down [ma-test Service Log][INFO][2021-01-05 03:09:41,351][Process-1:1]: process exiting with exitcode 0 [ma-test Service Log][INFO][2021-01-05 03:09:41,386][Process-1:2]: process shutting down [ma-test Service Log][INFO][2021-01-05 03:09:41,386][Process-1:2]: process exiting with exitcode 0 [ma-test Service Log][INFO][2021-01-05 03:09:41,410][Process-1:3]: process shutting down [ma-test Service Log][INFO][2021-01-05 03:09:41,410][Process-1:3]: process exiting with exitcode 0 [ma-test Service Log][INFO][2021-01-05 03:09:41,415][NonDaemonPoolWorker-1]: upload the content of [] outputs successfully [ma-test Service Log][INFO][2021-01-05 03:09:41,415][NonDaemonPoolWorker-1]: it can be accessed at obs path [s3://ma-test-algorancher-intel/model_evaluation/6e5746ff-2839-400a-ba93-df38311415f4/dac957b0-b43b-43e2-ab19-0b45672a7ea0/] 18 (pid) proc python stacktrace >>> Interrupting process at following point: File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", line 396, in ret_code = upload_to_obs() File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", line 287, in upload_to_obs results = pool.starmap(wrapper_copy_parallel, outputs) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 623, in __exit__ self.terminate() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 548, in terminate self._terminate() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/util.py", line 201, in __call__ res = self._callback(*self._args, **self._kwargs) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 617, in _terminate_pool p.join() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/process.py", line 140, in join res = self._popen.wait(timeout) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", line 48, in wait return self.poll(os.WNOHANG if timeout == 0.0 else 0) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", line 28, in poll pid, sts = os.waitpid(self.pid, flag) 18 (pid) proc gdb bt #0 0x00007f15c2c5ff7b in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0 #1 0x000055f54a8a5180 in os_waitpid_impl.isra.78 (options=0, pid=28) at /tmp/build/80754af9/python_1588882889832/work/Modules/posixmodule.c:7066 #2 os_waitpid () at /tmp/build/80754af9/python_1588882889832/work/Modules/clinic/posixmodule.c.h:3049 #3 0x000055f54a7f1b19 in _PyMethodDef_RawFastCallKeywords () at /tmp/build/80754af9/python_1588882889832/work/Objects/call.c:655 #4 0x000055f54a7f1db1 in _PyCFunction_FastCallKeywords (func=0x7f15c1f175f0, args=, nargs=, kwnames=) at /tmp/build/80754af9/python_1588882889832/work/Objects/call.c:734 28 (pid) proc python stacktrace Interrupting process at following point: File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", line 396, in ret_code = upload_to_obs() File "/home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py", line 286, in upload_to_obs with NonDaemonPool(processes=len(outputs)) as pool: File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 176, in __init__ self._repopulate_pool() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 241, in _repopulate_pool w.start() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/process.py", line 112, in start self._popen = self._Popen(self) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/context.py", line 277, in _Popen return Popen(process_obj) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", line 20, in __init__ self._launch(process_obj) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/popen_fork.py", line 74, in _launch code = process_obj._bootstrap() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs) File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/pool.py", line 110, in worker task = get() File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/queues.py", line 351, in get with self._rlock: File "/home/ma-user/miniconda3/lib/python3.7/multiprocessing/synchronize.py", line 95, in __enter__ return self._semlock.__enter__() 28 (pid) proc gdb bt #0 0x00007f15c2c5e827 in do_futex_wait.constprop () from /lib/x86_64-linux-gnu/libpthread.so.0 #1 0x00007f15c2c5e8d4 in __new_sem_wait_slow.constprop.0 () from /lib/x86_64-linux-gnu/libpthread.so.0 #2 0x00007f15c2c5e97a in sem_wait@@GLIBC_2.2.5 () from /lib/x86_64-linux-gnu/libpthread.so.0 #3 0x00007f15a98058b1 in semlock_acquire () at /usr/local/src/conda/python-3.7.7/Modules/_multiprocessing/semaphore.c:319 #4 0x000055f54a7f1c94 in _PyMethodDef_RawFastCallKeywords () at /tmp/build/80754af9/python_1588882889832/work/Objects/call.c:694 #5 0x000055f54a7f8aef in _PyMethodDescr_FastCallKeywords () at /tmp/build/80754af9/python_1588882889832/work/Objects/descrobject.c:288 proc list ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ps -ef UID PID PPID C STIME TTY TIME CMD ma-user 1 0 0 Jan05 ? 00:00:00 /bin/bash /home/ma-user/sidecar.sh ma-user 16 1 0 Jan05 ? 00:00:00 tail -n 0 -F /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log ma-user 18 1 0 Jan05 ? 00:00:00 python /home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py ma-user 28 18 0 Jan05 ? 00:00:00 python /home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py ma-user 102 0 0 Jan05 pts/0 00:00:00 bash ma-user 911 0 0 14:56 pts/1 00:00:00 bash ma-user 931 911 0 14:57 pts/1 00:00:00 ps -ef ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ 28 fd ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ls -alh /proc/28/fd total 0 dr-x------ 2 ma-user ma-group 0 Jan 6 20:23 . dr-xr-xr-x 9 ma-user ma-group 0 Jan 5 17:27 .. lr-x------ 1 ma-user ma-group 64 Jan 6 20:23 0 -> /dev/null l-wx------ 1 ma-user ma-group 64 Jan 6 20:23 1 -> /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log l-wx------ 1 ma-user ma-group 64 Jan 6 20:23 2 -> /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log lr-x------ 1 ma-user ma-group 64 Jan 6 20:23 3 -> /dev/urandom lr-x------ 1 ma-user ma-group 64 Jan 6 20:23 4 -> pipe:[952852668] lrwx------ 1 ma-user ma-group 64 Jan 6 20:23 5 -> socket:[952857499] lrwx------ 1 ma-user ma-group 64 Jan 6 20:23 6 -> /home/ma-user/conf/scc_logger.conf l-wx------ 1 ma-user ma-group 64 Jan 6 20:23 7 -> pipe:[952852671] lr-x------ 1 ma-user ma-group 64 Jan 6 20:23 8 -> /dev/null l-wx------ 1 ma-user ma-group 64 Jan 6 20:23 9 -> pipe:[952852675] 18 fd ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ls -alh /proc/18/fd total 0 dr-x------ 2 ma-user ma-group 0 Jan 6 20:26 . dr-xr-xr-x 9 ma-user ma-group 0 Jan 5 03:07 .. lr-x------ 1 ma-user ma-group 64 Jan 6 20:26 0 -> /dev/null l-wx------ 1 ma-user ma-group 64 Jan 6 20:26 1 -> /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log l-wx------ 1 ma-user ma-group 64 Jan 6 20:26 2 -> /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log lr-x------ 1 ma-user ma-group 64 Jan 6 20:26 3 -> /dev/urandom lr-x------ 1 ma-user ma-group 64 Jan 6 20:26 4 -> pipe:[952852668] l-wx------ 1 ma-user ma-group 64 Jan 6 20:26 5 -> pipe:[952852668] lr-x------ 1 ma-user ma-group 64 Jan 6 20:26 6 -> pipe:[952852671] l-wx------ 1 ma-user ma-group 64 Jan 6 20:26 7 -> pipe:[952852671] lr-x------ 1 ma-user ma-group 64 Jan 6 20:26 8 -> pipe:[952852675] SIGTERM / SIGINT not work ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ps -ef UID PID PPID C STIME TTY TIME CMD ma-user 1 0 0 Jan05 ? 00:00:00 /bin/bash /home/ma-user/sidecar.sh ma-user 16 1 0 Jan05 ? 00:00:00 tail -n 0 -F /home/ma-user/ma-test/log/-0---ma-platform-sidecar.log ma-user 18 1 0 Jan05 ? 00:00:00 python /home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py ma-user 28 18 0 Jan05 ? 00:00:00 python /home/ma-user/runtime-scripts-v2/init-container/outputs-handler.py ma-user 102 0 0 Jan05 pts/0 00:00:00 bash ma-user 1166 0 0 Jan06 pts/1 00:00:00 bash ma-user 1216 1166 0 10:51 pts/1 00:00:00 ps -ef ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ kill -SIGTERM 28 ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ kill -SIGINT 28 ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ ma-user at ma-test-eval-dac957b0-b43b-43e2-ab19-0b45672a7ea0-worker-0:/$ finally, pool hang ---------- components: Library (Lib) messages: 384560 nosy: huangzhesi priority: normal severity: normal status: open title: pool worker can't be terminated type: behavior versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 01:13:56 2021 From: report at bugs.python.org (Robin Scheibler) Date: Thu, 07 Jan 2021 06:13:56 +0000 Subject: [New-bugs-announce] [issue42850] Process hangs when calling urllib.request in a multiprocessing.Process with import of sounddevice package Message-ID: <1610000036.98.0.246954881352.issue42850@roundup.psfhosted.org> New submission from Robin Scheibler : I am having an issue with using urllib in a multiprocessing.Process when the package sounddevice (https://github.com/spatialaudio/python-sounddevice) has been already imported. The sub-process hangs upon calling urllib.request.urlopen (and methods from the requests package too). 1. If the package sounddevice is not imported, things work as expected. 2. If the package sounddevice is imported, but urllib.request.urlopen is called once prior to launching thee sub-process, then things also work as expected. I have attached a file containing code to reproduce the issue. I have run this example file in: - Python 3.7.9 (conda distribution) - Mac OS X 10.15.7 # Running the code as is reproduces the problem > python ./test_mp_req.py Nothing in the queue. Leave. wait for process to terminate... finished # Running the code with either line 8 commented *or* line 32 uncommented # gives the expected output > python ./test_mp_req.py Received https://api.github.com. Send GET request... done. Received https://www.google.com. Send GET request... done. https://api.github.com: ok https://www.google.com: ok Nothing in the queue. Leave. wait for process to terminate... finished ---------- components: Interpreter Core, Library (Lib), ctypes files: test_mp_req.py messages: 384562 nosy: fakufaku priority: normal severity: normal status: open title: Process hangs when calling urllib.request in a multiprocessing.Process with import of sounddevice package type: crash versions: Python 3.7 Added file: https://bugs.python.org/file49724/test_mp_req.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 01:39:43 2021 From: report at bugs.python.org (Mariusz Felisiak) Date: Thu, 07 Jan 2021 06:39:43 +0000 Subject: [New-bugs-announce] [issue42851] Subclassing Enum with ipaddress.IPv4Network/IPv6Network raises TypeError. Message-ID: <1610001583.18.0.772940964765.issue42851@roundup.psfhosted.org> New submission from Mariusz Felisiak : We noticed a behavior change in Python3.10.0a4 (it works properly in Python3.10.0a3) when running Django's test suite[1]. Subclassing `enum.Enum` with `ipaddress.IPv4Network/IPv6Network` raises `TypeError`, e.g. >>> import enum >>> import ipaddress >>> class NewEnum(ipaddress.IPv4Address, enum.Enum): ... pass ... >>> class NewEnum(ipaddress.IPv4Network, enum.Enum): ... pass ... Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.10/enum.py", line 239, in __new__ enum_class.__bases__ = enum_class.__bases__[1:] #or (object, ) File "/usr/local/lib/python3.10/enum.py", line 483, in __setattr__ super().__setattr__(name, value) TypeError: __bases__ assignment: 'IPv4Network' object layout differs from '_NoInitSubclass' It still works for `ipaddress.IPv4Address/IPv6Address`. [1] https://github.com/django/django/blob/102d92fc09849e1a9004dd3f9a14a0ea9ca392cd/tests/model_enums/tests.py#L225-L235 ---------- components: Library (Lib) messages: 384563 nosy: barry, eli.bendersky, ethan.furman, felixxm priority: normal severity: normal status: open title: Subclassing Enum with ipaddress.IPv4Network/IPv6Network raises TypeError. type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 01:47:34 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Thu, 07 Jan 2021 06:47:34 +0000 Subject: [New-bugs-announce] [issue42852] pprint fails in transformming non-breaking space Message-ID: <1610002054.28.0.212080312966.issue42852@roundup.psfhosted.org> New submission from Xinmeng Xia : "pprint" can transform unicode like "print". However, pprint fails to transform non-breaking space('\240') . See the following example: Python 3.10.0a2 (default, Nov 24 2020, 14:18:46) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information. Example 1(Results as expected): --------------------------------------------------------------------- >>> import pprint >>> print(u'\041 hello') ! hello >>> pprint.pprint(u'\041 hello') '! hello' Example 2(Results not as expected): --------------------------------------------------------------------- >>> print(u'\240 hello') hello >>> pprint.pprint(u'\240 hello') '\xa0 hello' Expected output: the output of pprint.pprint(u'\240 hello') should be consistent with output of print(u'\240 hello') ---------- components: Unicode messages: 384564 nosy: ezio.melotti, vstinner, xxm priority: normal severity: normal status: open title: pprint fails in transformming non-breaking space type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 03:03:09 2021 From: report at bugs.python.org (Andrew MacDonald) Date: Thu, 07 Jan 2021 08:03:09 +0000 Subject: [New-bugs-announce] [issue42853] `OverflowError: signed integer is greater than maximum` in ssl.py for files larger than 2GB Message-ID: <1610006589.59.0.311109371799.issue42853@roundup.psfhosted.org> New submission from Andrew MacDonald : When attempting to read a large file (> 2GB) over HTTPS the read fails with "OverflowError: signed integer is greater than maximum". This occurs with Python >=3.8 and I've been able to reproduce the problem with the below snippet of code on Linux, Mac OS X, and Windows (the remote file can be any HTTPS hosted file larger than 2GB, e.g. an empty file generated with `dd if=/dev/zero of=2g.img bs=1 count=0 seek=2G` will also do the job.). ``` import http.client connection = http.client.HTTPSConnection("mirror.aarnet.edu.au") connection.request("GET", "/pub/centos/8/isos/x86_64/CentOS-8.3.2011-x86_64-dvd1.iso") response = connection.getresponse() data = response.read() ``` Doing a git bisect it looks like this is the result of a change in commit d6bf6f2d0c83f0c64ce86e7b9340278627798090 (https://github.com/python/cpython/commit/d6bf6f2d0c83f0c64ce86e7b9340278627798090). Looking over the associated issue and commit message it seems like this was not an intended outcome for the change. ---------- assignee: christian.heimes components: SSL messages: 384565 nosy: amacd31, christian.heimes priority: normal severity: normal status: open title: `OverflowError: signed integer is greater than maximum` in ssl.py for files larger than 2GB type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 03:23:09 2021 From: report at bugs.python.org (Christian Heimes) Date: Thu, 07 Jan 2021 08:23:09 +0000 Subject: [New-bugs-announce] [issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex() Message-ID: <1610007789.81.0.109119647565.issue42854@roundup.psfhosted.org> New submission from Christian Heimes : SSL_read() and SSL_write() are limited to int. The new SSL_write_ex() and SSL_read_ex() APIs support size_t just like read(2) and recv(2). Also see bpo-42853. int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written); int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); Both functions return 1 for success or 0 for failure. ---------- assignee: christian.heimes components: SSL messages: 384567 nosy: christian.heimes priority: normal severity: normal status: open title: OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex() type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 04:23:21 2021 From: report at bugs.python.org (gaborjbernat) Date: Thu, 07 Jan 2021 09:23:21 +0000 Subject: [New-bugs-announce] [issue42855] pathlib.exists on Windows raises an exception on URL like/bad input Message-ID: <1610011401.69.0.814272139734.issue42855@roundup.psfhosted.org> New submission from gaborjbernat : ? py -c "from pathlib import Path; Path('http://w.org').exists()" Traceback (most recent call last): File "", line 1, in File "C:\Python39\lib\pathlib.py", line 1407, in exists self.stat() File "C:\Python39\lib\pathlib.py", line 1221, in stat return self._accessor.stat(self) OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'http:\\w.org' The above code returns correctly False on UNIX systems. ---------- components: Windows messages: 384569 nosy: gaborjbernat, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: pathlib.exists on Windows raises an exception on URL like/bad input versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 06:21:06 2021 From: report at bugs.python.org (STINNER Victor) Date: Thu, 07 Jan 2021 11:21:06 +0000 Subject: [New-bugs-announce] [issue42856] ensurepip: add configure --with-wheel-pkg-dir=PATH to get wheel packages from a system directory Message-ID: <1610018466.49.0.695886938784.issue42856@roundup.psfhosted.org> New submission from STINNER Victor : The Fedora packaging policy recommends to "unbundle" bundled dependencies. "Fedora packages SHOULD make every effort to avoid having multiple, separate, upstream projects bundled together in a single package." https://docs.fedoraproject.org/en-US/packaging-guidelines/#bundling The main motivation is to ease updates when fix serious vulnerabilities (less packaging work). The ensurepip package contains bundled wheel packages of setuptools and pip: $ ls Lib/ensurepip/_bundled/ pip-20.2.3-py2.py3-none-any.whl setuptools-47.1.0-py3-none-any.whl The Fedora python3 package doesn't contain the ensurepip._bundled package: $ python3 Python 3.9.1 (default, Dec 8 2020, 00:00:00) >>> import ensurepip._bundled ModuleNotFoundError: No module named 'ensurepip._bundled' Instead, a separated RPM package python-pip-wheel provides wheel packages in /usr/share/python-wheels/ directory: $ ls /usr/share/python-wheels/ pip-20.2.2-py2.py3-none-any.whl* setuptools-49.1.3-py3-none-any.whl* wheel-0.34.2-py2.py3-none-any.whl* Fedora has a downstream patch on ensurepip (written by Miro Hron?ok) to always use /usr/share/python-wheels/: https://src.fedoraproject.org/rpms/python3.10/blob/master/f/00189-use-rpm-wheels.patch Fedora has packages of 9 CPython versions: 2.6, 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10. https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html Having a separated package for wheel packages allows us to upgrade a single package (python-pip-wheel) for setuptools/pip bugfix or security vulnerability. -- I propose to add a new --with-wheel-pkg-dir=PATH option to the ./configure script. If used, ensurepip will only use wheel packages from this directory. Otherwise, the existing code is unchanged. In short, the behavior is unchanged, unless the option is used explicitly. If a directory is specified but wheel packages are missing, ensurepip fails. If the directory contains multiple wheel packages of different versions, the most recent version is used of each package. Note: In practice, the Fedora package only provides a single wheel package of each Python module. But I propose to make the Python upstream code as generic as possible. I'm working on a pull request to implement this. Downstream Fedora issue: https://bugzilla.redhat.com/show_bug.cgi?id=1874803 -- Fedora (Miro) already contributed to ensurepip to make ensurepip less dependent on pip internals: commit 88f82b2b9ea3514359cb6e3218121f75334063ac Author: Miro Hron?ok Date: Tue Mar 10 22:16:28 2020 +0100 bpo-38662: ensurepip invokes pip via runpy (GH-18901) The ensurepip module now invokes pip via the runpy module. Hence it is no longer tightly coupled with the internal API of the bundled pip version, allowing easier updates to a newer pip version both internally and for distributors. This way, any changes to the internal pip API won't mean ensurepip needs to be changed as well. Also, distributors can update their pip wheels independent on CPython release schedule. Co-Authored-By: Pradyun Gedam Co-Authored-By: Miro Hron?ok This change was already related to Fedora downstream change to get wheel packages from a different directory. Fedora can use a different pip version (older or more recent) than ensurepip._bundled. ---------- components: Library (Lib) messages: 384577 nosy: vstinner priority: normal severity: normal status: open title: ensurepip: add configure --with-wheel-pkg-dir=PATH to get wheel packages from a system directory versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 06:49:48 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Thu, 07 Jan 2021 11:49:48 +0000 Subject: [New-bugs-announce] [issue42857] Fails to construct paths lead to "python is likely shutting down" Message-ID: <1610020188.09.0.60258603326.issue42857@roundup.psfhosted.org> New submission from Xinmeng Xia : The attached file "test_zipfile.py" is from test directory in cPython. We delete irrelevant code. Running this code on Python 3.10 will lead to the following error messages. ---------------------------------------------------------------------------------------- Exception ignored in: Traceback (most recent call last): File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree ImportError: sys.meta_path is None, Python is likely shutting down Exception ignored in: Traceback (most recent call last): File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree ImportError: sys.meta_path is None, Python is likely shutting down ---------------------------------------------------------------------------------------- The expected output should be something like" ImportError: No module named XXX" rather than "Python is likely shutting down" ---------- components: Interpreter Core files: test_zipfile.py messages: 384581 nosy: xxm priority: normal severity: normal status: open title: Fails to construct paths lead to "python is likely shutting down" type: crash versions: Python 3.10 Added file: https://bugs.python.org/file49725/test_zipfile.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 06:54:25 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Thu, 07 Jan 2021 11:54:25 +0000 Subject: [New-bugs-announce] [issue42858] Incorrect return value for os.system() in recognizing import error Message-ID: <1610020465.58.0.34787573132.issue42858@roundup.psfhosted.org> New submission from Xinmeng Xia : Running attached "test_zipfile.py" on Python 3.10 will lead to the following error messages: ---------------------------------------------------------------------------------------------------- Exception ignored in: Traceback (most recent call last): File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree ImportError: sys.meta_path is None, Python is likely shutting down Exception ignored in: Traceback (most recent call last): File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 401, in temp_dir File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 358, in rmtree File "/usr/local/python310/lib/python3.10/test/support/os_helper.py", line 322, in _rmtree ImportError: sys.meta_path is None, Python is likely shutting down ---------------------------------------------------------------------------------------------------- However, if we run this program with os.system, the return value is 0 instead of 256. 0 represent no fails in this running! This is obviously incorrect. Reproduce: ========================================= import os scode = os.system('python310 test_zipfile.py') print("The system code of this execution is:", scode) ========================================= The expected output: "The system code of this execution is: 256" The actual output: "The system code of this execution is: 0" Version info: >>python310 -V Python 3.10.0a2 >>uname -v 16.04.1-Ubuntu SMP Fri Sep 13 09:56:18 UTC 2019 ---------- components: Library (Lib) files: test_zipfile.py messages: 384582 nosy: xxm priority: normal severity: normal status: open title: Incorrect return value for os.system() in recognizing import error versions: Python 3.10 Added file: https://bugs.python.org/file49726/test_zipfile.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 14:28:50 2021 From: report at bugs.python.org (Dmitry Goldenberg) Date: Thu, 07 Jan 2021 19:28:50 +0000 Subject: [New-bugs-announce] [issue42859] smtplib: recipe for certifying message delivery Message-ID: <1610047730.69.0.693075661816.issue42859@roundup.psfhosted.org> New submission from Dmitry Goldenberg : Is there a reliable way to certify (ensure, track) the delivery of an email message when using smtplib? For example: Disposition-Notification-To message header which enables the e-mail reader of the recipient to send confirmation e-mail when the recipient opens the message for the first time. That e-mail reader program must support this functionality. Return-Receipt-To message header which enables the e-mail server of the recipient to send confirmation e-mail when the original e-mail gets received by that server. However, most newer e-mail servers do not support Return-Receipt-To header. Are these message headers at all reliable? The request is to enhance the documentation to provide an example of how to track a message delivery. Conversely, if it's plain not possible, the request is to state that explicitly in the docs. ---------- assignee: docs at python components: Documentation messages: 384600 nosy: dgoldenberg123, docs at python priority: normal severity: normal status: open title: smtplib: recipe for certifying message delivery type: enhancement versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 16:09:27 2021 From: report at bugs.python.org (Tobias Kohn) Date: Thu, 07 Jan 2021 21:09:27 +0000 Subject: [New-bugs-announce] [issue42860] Incompatible types in Python grammar Message-ID: <1610053767.4.0.390149770714.issue42860@roundup.psfhosted.org> New submission from Tobias Kohn : There seems to be a small type error in the Python grammar in the rule `invalid_parameters`: ``` invalid_parameters: | param_no_default* (slash_with_default | param_with_default+) param_no_default ``` While the `slash_with_default` returns a single element, the `param_with_default` returns a list/sequence. ---------- messages: 384603 nosy: tobias.kohn priority: normal severity: normal status: open title: Incompatible types in Python grammar versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 19:30:51 2021 From: report at bugs.python.org (Faisal Mahmood) Date: Fri, 08 Jan 2021 00:30:51 +0000 Subject: [New-bugs-announce] [issue42861] ipaddress - add ability to get next closet subnet of any prefix size Message-ID: <1610065851.06.0.929191666424.issue42861@roundup.psfhosted.org> New submission from Faisal Mahmood : The ipaddress module in Python is an excellent tool, but I noticed it is missing a feature that I needed several months ago, which is the ability to find the next closest subnet with a specific prefix length. For example, imagine I had a IPv4Network("10.10.0.72/30"), how would I find the next possible /25 address? It is not the most straightforward thing to do, so think it would be a great enhancement to the ipaddress library. I think this can be achieved by adding in a new method to the BaseNetwork class, the method could be defined like "next_prefix(next_prefix=None)". Calling this method would return an IPv4/v6 address that is the closest possible match with the new prefix (defined as next_prefix). Example calls: v4 = IPv4Network("10.10.0.72/30") next_network = v4.next_subnet(next_prefix=25) # Output: next_network = IPv4Network("10.10.0.128/25") v4 = IPv4Network("10.10.0.72/30") next_network = v4.next_subnet(next_prefix=30) # Output: next_network = IPv4Network("10.10.0.76/30") v4 = IPv4Network("10.10.0.72/30") next_network = v4.next_subnet() # if next_prefix is not defined it will use the existing prefix of /30, so this call is exactly the same as the previous # Output: next_network = IPv4Network("10.10.0.76/30") v6 = IPv6Network("2001:db8:aaaa:aaaa:aaaa:aaaa:aaaa:0000/112") next_network = v6.next_subnet() # Output: next_network = IPv6Network("2001:db8:aaaa:aaaa:aaaa:aaaa:aaab:0/112") v6 = IPv6Network("2001:db8:aaaa:aaaa:aaaa:aaaa:aaaa:0000/112") next_network = v6.next_subnet(next_prefix=64) # Output: next_network = IPv6Network("2001:db8:aaaa:aaab::/64") I am going to be working on this and plan to raise a PR soon. This is my first time contributing to Python, so I appreciate your help / comments / suggestions / guidance as I go along. ---------- components: Library (Lib) messages: 384623 nosy: fasial.mahmood94 priority: normal severity: normal status: open title: ipaddress - add ability to get next closet subnet of any prefix size type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 19:39:03 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 08 Jan 2021 00:39:03 +0000 Subject: [New-bugs-announce] [issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module Message-ID: <1610066343.94.0.466682345605.issue42862@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : Pro: less code, less complexity, improved maintainability Con: minor performance hit PoC here: https://github.com/erlend-aasland/cpython/commits/sqlite-cache $ ./python.exe >>> import sqlite3 >>> con = sqlite3.connect(":memory:") >>> con.execute("select * from sqlite_master") >>> con.execute("select * from sqlite_master") >>> c = con.cache() >>> c.cache_info() CacheInfo(hits=1, misses=1, maxsize=128, currsize=1) The test suite runs approx. 10-20 ms slower with this change. Using _functools._lru_cache_wrapper iso. functools.lru_cache almost removes this performance regression. Berker, is it worth pursuing? ---------- components: Library (Lib) messages: 384625 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 20:10:38 2021 From: report at bugs.python.org (Jeff Moguillansky) Date: Fri, 08 Jan 2021 01:10:38 +0000 Subject: [New-bugs-announce] [issue42863] Python venv inconsistent folder structure on windows Message-ID: <1610068238.28.0.631501714908.issue42863@roundup.psfhosted.org> New submission from Jeff Moguillansky : When creating a virtual environment on windows using venv, the folder structure: "Scripts", "Include", "Lib", is inconsistent with other platforms (e.g. "include", "lib", "bin", etc). This causes various integration issues. For example, suppose we want to build a native C library, and install it to the folder structure generated by the virtual environment. The pkg-config file assumes a folder structure of "include", "lib", "bin", and the generated pkg-config files are inconsistent with the python virtual environment folder structure. Can we have a consistent folder structure across platforms? ---------- components: Windows messages: 384628 nosy: jmoguill2, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Python venv inconsistent folder structure on windows type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 22:03:30 2021 From: report at bugs.python.org (Pablo Galindo Salgado) Date: Fri, 08 Jan 2021 03:03:30 +0000 Subject: [New-bugs-announce] [issue42864] Improve error messages regarding unclosed parentheses Message-ID: <1610075010.91.0.684383999677.issue42864@roundup.psfhosted.org> New submission from Pablo Galindo Salgado : Consider this file: ``` x = ( ``` The error that we get is: ? python ../a.py File "/home/pablogsal/github/python/master/../a.py", line 6 ^ SyntaxError: unexpected EOF while parsin This is quite uninformative of the actual problem, which is the closed parentheses. The same happens with something like this: ( 1+2 File "/home/pablogsal/github/python/master/lel.py", line 3 ^ SyntaxError: unexpected EOF while parsing With some effort, we can include the location of the unclosed parentheses. ---------- messages: 384630 nosy: pablogsal priority: normal severity: normal status: open title: Improve error messages regarding unclosed parentheses versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Jan 7 23:00:38 2021 From: report at bugs.python.org (Victor Lopez) Date: Fri, 08 Jan 2021 04:00:38 +0000 Subject: [New-bugs-announce] [issue42865] sysconfig appends CFLAGS to LD Message-ID: <1610078438.84.0.384790848261.issue42865@roundup.psfhosted.org> New submission from Victor Lopez : This should not happen as some CFLAGS are exclusive to the compiler and it will break cross-compiling linkers The proposed sysconfig is attached ---------- components: Distutils files: sysconfig.py messages: 384632 nosy: Greentwip, dstufft, eric.araujo priority: normal pull_requests: 22989 severity: normal status: open title: sysconfig appends CFLAGS to LD versions: Python 3.9 Added file: https://bugs.python.org/file49728/sysconfig.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 04:28:39 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 08 Jan 2021 09:28:39 +0000 Subject: [New-bugs-announce] [issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references Message-ID: <1610098119.51.0.27659926103.issue42866@roundup.psfhosted.org> New submission from STINNER Victor : $ ./python -m test test_multibytecodec -m test.test_multibytecodec.Test_IncrementalEncoder.test_subinterp -R 3:3 (...) test_multibytecodec leaked [258, 258, 258] references, sum=774 I simplified the code. The following test leaks references: def test_subinterp(self): import _testcapi code = textwrap.dedent(""" import _codecs_jp codec = _codecs_jp.getcodec('cp932') codec = None """) _testcapi.run_in_subinterp(code) _codecs_jp.getcodec() is defined in Modules/cjkcodecs/cjkcodecs.h. Extract: cofunc = getmultibytecodec(); ... codecobj = PyCapsule_New((void *)codec, PyMultibyteCodec_CAPSULE_NAME, NULL); if (codecobj == NULL) return NULL; r = PyObject_CallOneArg(cofunc, codecobj); Py_DECREF(codecobj); getmultibytecodec() is the _multibytecodec.__create_codec() which is defined in Modules/cjkcodecs/multibytecodec.c. Simplified code: codec = PyCapsule_GetPointer(arg, PyMultibyteCodec_CAPSULE_NAME); _multibytecodec_state *state = _multibytecodec_get_state(module); self = PyObject_New(MultibyteCodecObject, state->multibytecodec_type); self->codec = codec; return (PyObject *)self; ---------- components: Library (Lib) messages: 384643 nosy: vstinner priority: normal severity: normal status: open title: test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 07:46:13 2021 From: report at bugs.python.org (John McCabe) Date: Fri, 08 Jan 2021 12:46:13 +0000 Subject: [New-bugs-announce] [issue42867] Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04 Message-ID: <1610109973.36.0.703695549775.issue42867@roundup.psfhosted.org> New submission from John McCabe : I've built an application using tkinter (see below). I'm fairly new to tkinter, despite having substantial software experience (33 years), so the layout might be a bit odd/wrong, and the example obviously doesn't follow PEP-8 guidelines, however... Basically this application (which is a bit more than minimal, but should be easy to follow) is designed to manage pairs of text values as JSON, saving/loading from a file. When it starts, the user is asked if they want to read in an existing file of data; if they select NO, a fairly empty frame with 3 buttons showing "+", "Save" and "Quit" is displayed. At this point, if "+" is pressed, a new row with two labels and two Entry widgets is added to the frame. However (and this is the problem which appears to be identical to that reported in Issue #9673), it is not possible to set focus into either of the Entry widgets on Windows 10; there is no problem doing this on Ubuntu 16.04 (although I've only got Python 3.5 on there) If the "Save" button is then pressed, a message box pops up telling the use that no changes have been saved. Once OK has been pressed on that, it becomes possible to set focus into the Entry widgets. One of the problems with Issue #9673 was that no 'minimal' example was provided showing this behaviour, and the very minimal example given in https://bugs.python.org/issue9673#msg218765 doesn't exhibit the problem, hence the example below being a bit more than minimal, while still not being particularly complicated. ==== #!/usr/bin/python3 import os import tkinter as tk from tkinter import filedialog, messagebox import json class Application(tk.Frame): def __init__(self, master): super().__init__(master) self.master = master self.grid() self.originalJson = {} self.inFileName = "" self.leftRightEntries = [] self.fileDlgOpts = { "initialdir" : os.getcwd(), "initialfile" : "file.json", "filetypes" : (("JSON File", "*.json"), ("All Files","*.*")), "defaultextension" : '.json', "title" : "Select A File" } self.createWidgets() def openInFile(self): fileName = "" reuse = tk.messagebox.askquestion("Use An Existing File", "Do you want to load and use an existing file?") if reuse == "yes": fileName = tk.filedialog.askopenfilename(**self.fileDlgOpts) if fileName is not "": try: with open(fileName, 'r') as json_file: self.originalJson = json.load(json_file) json_file.close() except Exception: tk.messagebox.showerror("Use An Existing File", "File could not be loaded; continuing without one.") fileName = "" else: tk.messagebox.showwarning("Use An Existing File", "No existing file specified; continuing without one.") return fileName def createWidgets(self): self.inFileName = self.openInFile() # We add the buttons to some huge numbered row because we might want to insert more # rows, and the layout manager will collapse everything in between. Also we # add these first because of the way the tab order is set up self.addBtn = tk.Button(self.master, text = "+", command = self.addNew) self.addBtn.grid(row = 100, column = 0, sticky = tk.W) # Save button; pretty self-explanatory self.saveBtn = tk.Button(self.master, text = "Save", command = self.save) self.saveBtn.grid(row = 100, column = 2, sticky = tk.W) # Quit button; pretty self-explanatory self.quitBtn = tk.Button(self.master, text = "QUIT", fg = "red", command = self.quit) self.quitBtn.grid(row = 100, column = 3, sticky = tk.E) # If there is original json, work through each key and put the fields on the display rowNum = 0 for leftText in sorted(self.originalJson.keys()): self.insertRow(rowNum, leftText); rowNum = rowNum + 1 self.nextEmptyRow = rowNum self.redoPadding() def redoPadding(self): for child in self.master.winfo_children(): child.grid_configure(padx = 5, pady = 5) def focusNextWidget(self, event): event.widget.tk_focusNext().focus() return("break") def insertRow(self, rowNum, initialLeft = None): tk.Label(self.master, height = 1, text = "Left: ").grid(row = rowNum, column = 0, sticky = tk.W) leftBox = tk.Entry(self.master, width = 20) leftBox.grid(row = rowNum, column = 1, sticky = tk.W) leftBox.bind("", self.focusNextWidget) if initialLeft is not None: leftBox.insert(tk.END, initialLeft) tk.Label(self.master, height = 1, text = "Right: ").grid(row = rowNum, column = 2, sticky = tk.W) rightBox = tk.Entry(self.master, width = 20) rightBox.grid(row = rowNum, column = 3, sticky = tk.W) rightBox.bind("", self.focusNextWidget) if initialLeft is not None: rightBox.insert(tk.END, initialLeft) self.leftRightEntries.append((leftBox, rightBox)) leftBox.focus_set() def addNew(self): # Add a new row before the button self.insertRow(self.nextEmptyRow) self.nextEmptyRow = self.nextEmptyRow + 1 self.redoPadding() def getCurrent(self): # Work through the rows and check stuff current = {} for (leftEntry, rightEntry) in self.leftRightEntries: leftText = leftEntry.get() rightText = rightEntry.get() if leftText == "" and rightText == "": pass elif leftText == "": print("No leftText specified for rightText [{}]".format(rightText)) elif rightText == "": print("No rightText specified for leftText [{}]".format(leftText)) else: print("lefText: {}, rightText: {}".format(leftText, rightText)) current[leftText] = rightText return current def save(self): # Get the current values, and then dump the new json to a file, if it's changed! finalResult = self.getCurrent() if finalResult != self.originalJson: if self.inFileName == "": self.inFileName = tk.filedialog.asksaveasfilename(**self.fileDlgOpts) if self.inFileName != "": with open(self.inFileName, 'w') as json_file: json.dump(finalResult, json_file, indent = 4) self.originalJson = finalResult tk.messagebox.showinfo("Save Data", "Data saved to {}".format(self.inFileName)) else: tk.messagebox.showwarning("Save Data", "Data has not been saved; no file name was supplied!") else: tk.messagebox.showwarning("Save Data", "Data has not been saved; there are no changes") def quit(self): # Deal with quitting when the file's been modified, check original vs current JSON reallyQuit = True finalResult = self.getCurrent() if finalResult != self.originalJson: answer = tk.messagebox.askquestion("Quit", "Data has changed; do you really want to quit?", icon = "warning") if answer != "yes": reallyQuit = False if reallyQuit: self.master.destroy() if __name__ == "__main__": root = tk.Tk() root.title("Inactive Entry Example") app = Application(root) root.protocol("WM_DELETE_WINDOW", app.quit) app.mainloop() ---------- components: Tkinter messages: 384655 nosy: cosimo193 priority: normal severity: normal status: open title: Entry Widget not editable on Windows 10, but is on Linux Ubuntu 16.04 type: behavior versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 09:46:35 2021 From: report at bugs.python.org (Jin-oh Kang) Date: Fri, 08 Jan 2021 14:46:35 +0000 Subject: [New-bugs-announce] [issue42868] SpooledTemporaryFile.__iter__ is not transparent to rollover Message-ID: <1610117195.08.0.928321664408.issue42868@roundup.psfhosted.org> New submission from Jin-oh Kang : In tempfile, SpooledTemporaryFile.__iter__ is defined as follows: # file protocol def __iter__(self): return self._file.__iter__() A rollover would switch the underlying _file object from a BytesIO to a TemporaryFile, thereby leaving the original iterator stale. This may be fixed by: def __iter__(self): while True: line = self._file.readline() if not line: break yield line Or perhaps: def __iter__(self): while True: file = self._file for line in file: yield line if file is not self._file: break else: break ---------- components: Library (Lib) messages: 384674 nosy: jinoh.kang.kr priority: normal severity: normal status: open title: SpooledTemporaryFile.__iter__ is not transparent to rollover type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 16:55:55 2021 From: report at bugs.python.org (Julien Palard) Date: Fri, 08 Jan 2021 21:55:55 +0000 Subject: [New-bugs-announce] [issue42869] pydoc does not append .html to documentation Message-ID: <1610142955.15.0.664460414569.issue42869@roundup.psfhosted.org> New submission from Julien Palard : Running `python3 -m pydoc ensurepip` gives me: https://docs.python.org/3.9/library/ensurepip but it should be: https://docs.python.org/3.9/library/ensurepip.html Issue is in getdocloc function on the line: docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__.lower()) But it previously worked as the nginx config for the doc server contains: # Emulate Apache's content-negotiation. Was a temporary measure, # but now people are using it like a feature. location ~ ^/((2|3)(\.[0-8])?|dev)/\w+/[\d\w\.]+(?!\.html)$ { if (-f "${request_filename}.html") { return 301 https://$host:$request_uri.html; } } (So yes "people are using it like a feature" contains pydoc :)) Notice the [0-8], which does not match for my /3.9/. I propose to fix the issue on both sides: - On psf-salt to allow 3.9 to get the "temporary" measure. - pydoc side to simplify the code ---------- assignee: docs at python components: Documentation messages: 384693 nosy: docs at python, mdk priority: normal severity: normal status: open title: pydoc does not append .html to documentation versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 18:50:53 2021 From: report at bugs.python.org (=?utf-8?q?Miro_Hron=C4=8Dok?=) Date: Fri, 08 Jan 2021 23:50:53 +0000 Subject: [New-bugs-announce] [issue42870] Document changed argparse output wrt optional arguments in What's new in Python 3.10 Message-ID: <1610149853.78.0.949568295376.issue42870@roundup.psfhosted.org> New submission from Miro Hron?ok : A followup from https://bugs.python.org/issue9694 Could the change in output please be mentioned on https://docs.python.org/3.10/whatsnew/3.10.html ? In Fedora, at least 3 packages fail tests because of the change: ipython: https://github.com/ipython/ipython/pull/12759 m2r: https://github.com/miyakogi/m2r/pull/62 sphinxcontrib-autoprogram: https://bugzilla.redhat.com/show_bug.cgi?id=1914341 Thanks. ---------- assignee: docs at python components: Documentation messages: 384699 nosy: docs at python, hroncok, paul.j3, rhettinger priority: normal severity: normal status: open title: Document changed argparse output wrt optional arguments in What's new in Python 3.10 versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Jan 8 20:25:30 2021 From: report at bugs.python.org (Renji) Date: Sat, 09 Jan 2021 01:25:30 +0000 Subject: [New-bugs-announce] [issue42871] Regex compilation crashed if I change order of alternatives under quantifier Message-ID: <1610155530.98.0.643940594728.issue42871@roundup.psfhosted.org> New submission from Renji : I can compile "((a)|b\2)*" expression and this expression successfully return captures from first repetition and second repetition in one time. But if I write (b\2|(a))* expression, I get "invalid group reference 2 at position 3" error. Either first or second behavior incorrect. python3 --version Python 3.7.3 import re text="aba" #match=re.search(r"(b\2|(a))*",text) - not worked match=re.search(r"((a)|b\2)*",text) if(match): #show aba ba a print(match.group(0)+" "+match.group(1)+" "+match.group(2)) ---------- components: Regular Expressions messages: 384703 nosy: Renji, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: Regex compilation crashed if I change order of alternatives under quantifier type: behavior versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 03:15:26 2021 From: report at bugs.python.org (Hong Xu) Date: Sat, 09 Jan 2021 08:15:26 +0000 Subject: [New-bugs-announce] [issue42872] Inconsistent exception thrown by mkdir on different OSes Message-ID: <1610180126.52.0.315552258683.issue42872@roundup.psfhosted.org> New submission from Hong Xu : Consider the following code: ------------------------- import pathlib def main(): pathlib.Path('tmp').touch() pathlib.Path('tmp/tmp_sub').mkdir(parents=True) main() ------------------------ Run the code above in an empty directory. On Linux, it throws a `NotADirectory` exception: Traceback (most recent call last): File "", line 1, in File "main.py", line 5, in main pathlib.Path('tmp/tmp_sub').mkdir(parents=True) File "/usr/lib/python3.8/pathlib.py", line 1287, in mkdir self._accessor.mkdir(self, mode) NotADirectoryError: [Errno 20] Not a directory: 'tmp/tmp_sub' ----------------------------- On Windows, it throws a FileExistsError exception: Traceback (most recent call last): File "C:\Users\hong\anaconda3\lib\pathlib.py", line 1284, in mkdir self._accessor.mkdir(self, mode) FileNotFoundError: [WinError 3] The system cannot find the path specified: 'tmp\\tmp_sub' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 7, in main() File "main.py", line 5, in main pathlib.Path('tmp/tmp_sub').mkdir(parents=True) File "C:\Users\hong\anaconda3\lib\pathlib.py", line 1288, in mkdir self.parent.mkdir(parents=True, exist_ok=True) File "C:\Users\hong\anaconda3\lib\pathlib.py", line 1284, in mkdir self._accessor.mkdir(self, mode) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'tmp ---------- components: Library (Lib), Windows messages: 384715 nosy: Hong Xu, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Inconsistent exception thrown by mkdir on different OSes versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 07:00:18 2021 From: report at bugs.python.org (Mark Dickinson) Date: Sat, 09 Jan 2021 12:00:18 +0000 Subject: [New-bugs-announce] [issue42873] Exponential time and space requirements for compilation of nested try/finally blocks Message-ID: <1610193618.87.0.555969864656.issue42873@roundup.psfhosted.org> New submission from Mark Dickinson : tl;dr - contrived (but relatively short) code involving nested try/finally blocks can produce disproportionately large bytecode. I'm not expecting or suggesting any action here, but the situation seemed at least worth noting. Feel free to close this issue as a "well don't do that, then" (a.k.a. "wont fix") Longer: Python 3.9 changed the way that bytecode was generated for try/finally (see #33387). For a "try" block body that can do any of raise, return or fall-off-the-end-of-the-block, the corresponding finally block gets three separate paths in the bytecode. If such trys are nested times, we get 3^n separate paths in the bytecode. Example code: ---------------- def f(): try: if something(): return finally: try: if something(): return finally: try: if something(): return finally: try: if something(): return finally: try: if something(): return finally: do_cleanup() import dis dis.dis(f) ---------------- On my machine, running this and counting the do_cleanup invocations gives, as expected, a result of 243 = 3**5 % python3.9 nested_finally.py | grep do_cleanup | wc -l 243 That's fairly benign, but if I scale up to 10 nested blocks, the dis.dis call takes over 10 minutes to complete (the compilation itself still only takes a fraction of a second). The bytecode object is correspondingly large: >>> len(f.__code__.co_code) 1741356 With 15 levels of nesting, compilation takes several seconds, and the generated code is (again as expected) a couple of orders of magnitude larger: >>> len(f.__code__.co_code) 533859040 I didn't try pushing this further than 15 levels of nesting. As I said above, it's not clear to me whether this is actually an issue that needs to be addressed in practice. It seems unlikely that "real code" :TM: would run into this, but the effect seemed worth noting. ---------- components: Interpreter Core messages: 384718 nosy: Mark.Shannon, mark.dickinson priority: normal severity: normal status: open title: Exponential time and space requirements for compilation of nested try/finally blocks type: performance versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 07:14:13 2021 From: report at bugs.python.org (Martin Wheatley) Date: Sat, 09 Jan 2021 12:14:13 +0000 Subject: [New-bugs-announce] [issue42874] configure errors Message-ID: <1610194453.5.0.66216438534.issue42874@roundup.psfhosted.org> New submission from Martin Wheatley : I'm installin Python 3.91. on a Solaris 10 system (I known it's 'old' but I have a legacy installation to support). Running ./configure the following errors are seen... checking PROFILE_TASK... -m test --pgo checking for --with-lto... no checking for llvm-profdata... no grep: illegal option -- q Usage: grep -hblcnsviw pattern file . . . checking for -Wextra... yes checking whether /usr/sfw/bin/gcc accepts and needs -fno-strict-aliasing... yes checking if we can turn off /usr/sfw/bin/gcc unused result warning... no checking if we can turn off /usr/sfw/bin/gcc unused parameter warning... yes and checking aligned memory access is required... yes checking for --with-hash-algorithm... default checking for --with-tzpath... grep: illegal option -- q grep: illegal option -- E Usage: grep -hblcnsviw pattern file . . . "/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo" checking for --with-address-sanitizer... no checking for --with-memory-sanitizer... no checking for --with-undefined-behavior-sanitizer... no checking for t_open in -lnsl... yes checking for socket in -lsocket... yes ---------- components: Installation messages: 384720 nosy: martin.wheatley.home priority: normal severity: normal status: open title: configure errors type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 09:34:59 2021 From: report at bugs.python.org (Pavel Ditenbir) Date: Sat, 09 Jan 2021 14:34:59 +0000 Subject: [New-bugs-announce] [issue42875] argparse incorrectly shows help string on a new line in case of long command string Message-ID: <1610202899.54.0.332342565241.issue42875@roundup.psfhosted.org> New submission from Pavel Ditenbir : Steps to reproduce. Run the attached script: $ python3 argparse-indent-sample.py --help The output is: usage: argparse-indent-sample.py [-h] CMD ... optional arguments: -h, --help show this help message and exit service: CMD command to use add add something remove remove something a-very-long-command command that does something Expected output is: usage: argparse-indent-sample.py [-h] CMD ... optional arguments: -h, --help show this help message and exit service: CMD command to use add add something remove remove something a-very-long-command command that does something ---------- components: Library (Lib) files: argparse-indent-sample.py messages: 384728 nosy: DiPaolo priority: normal severity: normal status: open title: argparse incorrectly shows help string on a new line in case of long command string type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49730/argparse-indent-sample.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 13:40:48 2021 From: report at bugs.python.org (Andreas Zeller) Date: Sat, 09 Jan 2021 18:40:48 +0000 Subject: [New-bugs-announce] [issue42876] '''"""''' != '""""' Message-ID: <1610217648.49.0.452941613308.issue42876@roundup.psfhosted.org> New submission from Andreas Zeller : The following line of code fails in Python 3.6, which I find surprising. >>> assert '''"""''' == '""""' # Fails Note that the following all pass as expected: >>> assert """'''""" == "'''" # Passes >>> assert '''""''' == '""' # Passes ---------- components: Interpreter Core messages: 384736 nosy: andreas-zeller priority: normal severity: normal status: open title: '''"""''' != '""""' type: behavior versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 14:11:00 2021 From: report at bugs.python.org (Irit Katriel) Date: Sat, 09 Jan 2021 19:11:00 +0000 Subject: [New-bugs-announce] [issue42877] TracebackException saves more data than it needs Message-ID: <1610219460.26.0.944321944788.issue42877@roundup.psfhosted.org> New submission from Irit Katriel : TracebackException saves both __cause__ and __context__ even though format() ignores the __context__ if there is __cause__. If we change the constructor to save only what format() needs, it will save space and simplify the code. ---------- components: Library (Lib) messages: 384738 nosy: iritkatriel priority: normal severity: normal status: open title: TracebackException saves more data than it needs type: performance versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 16:23:37 2021 From: report at bugs.python.org (Yair Frid) Date: Sat, 09 Jan 2021 21:23:37 +0000 Subject: [New-bugs-announce] [issue42878] urllib.request.HTTPPasswordMgr.is_suburi does not care about order Message-ID: <1610227417.16.0.538971054996.issue42878@roundup.psfhosted.org> New submission from Yair Frid : In docs, it mentions that the function returns true if the base is a 'suburi' of test, but in reality, if is_suburi(base, test) then is_suburi(test, base) which is wrong in most cases (other than where base ~= test, meaning they are the same location) I am unsure which versions of python are affected, but i suspect most of them (although we probably shouldn't backport this fix?) ---------- components: Library (Lib) messages: 384741 nosy: Fongeme priority: normal pull_requests: 23009 severity: normal status: open title: urllib.request.HTTPPasswordMgr.is_suburi does not care about order _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Jan 9 17:50:07 2021 From: report at bugs.python.org (Jason Oliver) Date: Sat, 09 Jan 2021 22:50:07 +0000 Subject: [New-bugs-announce] [issue42879] SystemError from class 'int' Message-ID: <1610232607.93.0.155495951465.issue42879@roundup.psfhosted.org> New submission from Jason Oliver : This is my first bug report so I hope that this is correctly formatted. I am learning how to use pygame and encountered the following error: SystemError: returned a result with an error set I googled the error message and came across the following answer on stackoverflow: https://stackoverflow.com/a/53796516 This stated that the problem could exist within the implementation of python and that I should file a bug report here. I am using the following software installed through pip/pip3: Python 3.8.4 pygame 2.0.1 OS Edition: Windows 10 Pro OS Version: 20H2 OS build: 19042.685 The bug can be reproduced deterministically. ---------- files: Movement.py messages: 384743 nosy: jollyoliver657 priority: normal severity: normal status: open title: SystemError from class 'int' versions: Python 3.8 Added file: https://bugs.python.org/file49731/Movement.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 02:41:58 2021 From: report at bugs.python.org (Ziqiao Kong) Date: Sun, 10 Jan 2021 07:41:58 +0000 Subject: [New-bugs-announce] [issue42880] ctypes: variadic function call still doesn't work on Apple Silicon Message-ID: <1610264518.97.0.0227668442163.issue42880@roundup.psfhosted.org> New submission from Ziqiao Kong : Hello! Thanks for your contribution on porting python to native Apple Silicon. I have noticed that there is an issue https://bugs.python.org/issue41100 and corresponding Github PR https://github.com/python/cpython/pull/22855 stating that variadic functions ABI has been corrected. However, during our test, it still doesn't work on Apple Silicon with brew-installed python 3.9.1 and python 3..10.0a4 built from sources. The details are as follows: A x86_64 Mojave Macmini with python 3.8: ``` /tmp $ python3 --version Python 3.8.6 /tmp $ uname -a Darwin *** 18.7.0 Darwin Kernel Version 18.7.0: Mon Apr 27 20:09:39 PDT 2020; root:xnu-4903.278.35~1/RELEASE_X86_64 x86_64 /tmp $ cat main.c #include #include #include void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } /tmp $ cc -shared -g main.c -o ./main.dylib /tmp $ cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) /tmp $ python3 test_main.py 34 /tmp $ ``` An M1 Macbook Pro with brew-installed python 3.9.1 ``` kabeor at kamino /tmp % python3 --version Python 3.9.1 kabeor at kamino /tmp % cat main.c #include #include #include void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } kabeor at kamino /tmp % cc -shared -g main.c -o ./main.dylib kabeor at kamino /tmp % cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) kabeor at kamino /tmp % python3 test_main.py 48144104 kabeor at kamino /tmp % ``` An M1 Macbook Pro with python 3.10.0a4 built from Github release tarball ``` kabeor at kamino cpython-3.10.0a4 % ./python.exe --version Python 3.10.0a4 kabeor at kamino cpython-3.10.0a4 % cp /tmp/main.c ./ kabeor at kamino cpython-3.10.0a4 % cp /tmp/test_main.py ./ kabeor at kamino cpython-3.10.0a4 % ./python.exe --version Python 3.10.0a4 kabeor at kamino cpython-3.10.0a4 % cat ./main.c #include #include #include void test(uint64_t end, ...){ int a; va_list valist; va_start(valist, end); a = va_arg(valist, int); va_end(valist); printf("%d\n", a); return; } kabeor at kamino cpython-3.10.0a4 % cc -shared -g main.c -o ./main.dylib kabeor at kamino cpython-3.10.0a4 % cat test_main.py from ctypes import * d = CDLL("./main.dylib") d.test.restype = None d.test(c_uint64(12), c_int(34)) kabeor at kamino cpython-3.10.0a4 % ./python.exe test_main.py 3 kabeor at kamino cpython-3.10.0a4 % ``` Thanks in advance! ---------- components: ctypes messages: 384756 nosy: lawrence-danna-apple, lazymio priority: normal severity: normal status: open title: ctypes: variadic function call still doesn't work on Apple Silicon versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 06:29:52 2021 From: report at bugs.python.org (Larry Hastings) Date: Sun, 10 Jan 2021 11:29:52 +0000 Subject: [New-bugs-announce] [issue42881] Should typing.get_type_hints change None annotations? Message-ID: <1610278192.15.0.512262305909.issue42881@roundup.psfhosted.org> New submission from Larry Hastings : PEP 484 says: (Note that the return type of __init__ ought to be annotated with -> None. The reason for this is subtle. [...] https://www.python.org/dev/peps/pep-0484/#the-meaning-of-annotations If you follow this advice, then call typing.get_type_hints() on your __init__ function, you'll find it has turned "None" into "type(None)". git blame suggests get_type_hints' behavior was in the initial checkin of typing.py (46dbb7d1032c19163f37785509b8f5b3004416e8). So it's always behaved this way. Is "None" still considered the correct return annotation of an __init__? If so, should typing.get_type_hints() really be changing it to type(None)? ---------- components: Library (Lib) messages: 384760 nosy: eric.smith, gvanrossum, larry priority: low severity: normal stage: test needed status: open title: Should typing.get_type_hints change None annotations? type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 08:00:18 2021 From: report at bugs.python.org (Yannick Jadoul) Date: Sun, 10 Jan 2021 13:00:18 +0000 Subject: [New-bugs-announce] [issue42882] Restarting the interpreter causes UB on 3.10.0a4 Message-ID: <1610283618.64.0.475556781159.issue42882@roundup.psfhosted.org> New submission from Yannick Jadoul : Issue detected in the embedding tests of pybind11, running on the latest alpha of 3.10: https://github.com/pybind/pybind11/issues/2774 I have reduced the weird issue/crash to a minimal reproducer, which consistently reproduces the crash on my Linux machine: ``` #include int main() { Py_InitializeEx(1); Py_Finalize(); Py_InitializeEx(1); PyRun_SimpleString("class Widget: pass\n" "class DerivedWidget(Widget):\n" " def __init__(self):\n" " super().__init__()\n"); Py_Finalize(); printf("Works\n"); return 0; } ``` Removing the two lines in the middle that restart the interpreter makes the example work. I've also bisected CPython to find the issue (3.10.0a3 is fine, 3.10.0a4 is not), and arrived at https://github.com/python/cpython/pull/20058 (ba3d67c2fb04a7842741b1b6da5d67f22c579f33 being the first commit that breaks the example above). But I am not entirely sure where to start debugging. The reproducing example above consistently crashes on my local machine (SIGABRT, exit code 134): ``` Fatal Python error: compiler_make_closure: lookup '__class__' in DerivedWidget 5 -1 freevars of __init__: ('__class__',) Python runtime state: initialized Current thread 0x00007f036485b680 (most recent call first): Aborted (core dumped) ``` But note that in the pybind11 tests, the underlying issue causes a different error (Python throwing a weird, seemingly unrelated exception). So something seems to be messed up in the interpreter internals, and the above example just triggers it. ---------- components: Interpreter Core messages: 384761 nosy: YannickJadoul priority: normal severity: normal status: open title: Restarting the interpreter causes UB on 3.10.0a4 versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 09:43:44 2021 From: report at bugs.python.org (Haoyang) Date: Sun, 10 Jan 2021 14:43:44 +0000 Subject: [New-bugs-announce] [issue42883] __init__ function may incur an incorrect behavior if passing a list as a parameter and set its default value as empty Message-ID: <1610289824.57.0.574510344597.issue42883@roundup.psfhosted.org> New submission from Haoyang : Here is the bug-triggered code snippet in the file uploaded class A: def __init__(self, b=[]): print('b = ', b) self.a = b for i in range(3): a = A() a.a.append(1) print(a.a) It seems that when I pass a list "b" to __init__ function with default value empty list. Every time I create a new instance of this class and append one new variable to "self.a", the default value of "b" changed at the next time I create another instance of class A. The outcome of this code snippet is a = [] [1] a = [1] [1, 1] a = [1, 1] [1, 1, 1] I am new to python. Is it a legal behavior in python? If yes, what is the principle beneath it? Thanks in advance! ---------- files: test.py messages: 384765 nosy: haoyang9804 priority: normal severity: normal status: open title: __init__ function may incur an incorrect behavior if passing a list as a parameter and set its default value as empty type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49732/test.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 14:51:50 2021 From: report at bugs.python.org (Daniel Nicorici) Date: Sun, 10 Jan 2021 19:51:50 +0000 Subject: [New-bugs-announce] [issue42884] array.index() missing start and end Message-ID: <1610308310.47.0.185082010282.issue42884@roundup.psfhosted.org> New submission from Daniel Nicorici : Add support for array.index(x [,start [,end]]). Adding start and end would allow to loop thru the entire array (and not start all the time from 0). Currently, is array.index(x) (and it returns the smallest i such that i is the index of the first occurrence of x in the array). For example, bytearray.index() has start and end and list.index() has also start and end, but for some reason start and end are missing from array.index. ---------- messages: 384775 nosy: daniel.nicorici priority: normal severity: normal status: open title: array.index() missing start and end type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 16:58:21 2021 From: report at bugs.python.org (Arnim Rupp) Date: Sun, 10 Jan 2021 21:58:21 +0000 Subject: [New-bugs-announce] [issue42885] Regex performance problem with ^ aka AT_BEGINNING Message-ID: <1610315901.41.0.467379667553.issue42885@roundup.psfhosted.org> New submission from Arnim Rupp : The re lib needs 7 seconds to check if a billion As start with an x. So e.g. this statement takes this long: re.search(r'^x', 'A' * 1000000000) It takes longer, the longer the string is. The string handling is not the problem, checking if it starts which an A takes just 0.00014 seconds. See output and code below: 3.10.0a4+ (heads/master:d16f617, Jan 9 2021, 13:24:45) [GCC 7.5.0] testing string len: 100000 re_test_false: 0.0008246829966083169 testing string len: 1000000000 re_test_false: 7.317708015005337 testing string len: 1000000000 re_test_true: 0.00014710200048284605 import re, timeit, functools, sys def re_test_true(string): print("testing string len: ", len(string)) re.search(r'^A', string) def re_test_false(string): print("testing string len: ", len(string)) re.search(r'^x', string) print(sys.version) huge_string = 'A' * 100000 print('re_test_false: ', timeit.timeit(functools.partial(re_test_false, huge_string), number=1)) huge_string = 'A' * 1000000000 print('re_test_false: ', timeit.timeit(functools.partial(re_test_false, huge_string), number=1)) print('re_test_true: ', timeit.timeit(functools.partial(re_test_true, huge_string), number=1)) ---------- components: Library (Lib) files: regex_timeit.py messages: 384782 nosy: another_try priority: normal severity: normal status: open title: Regex performance problem with ^ aka AT_BEGINNING type: performance versions: Python 3.10 Added file: https://bugs.python.org/file49733/regex_timeit.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Jan 10 17:44:43 2021 From: report at bugs.python.org (Camion) Date: Sun, 10 Jan 2021 22:44:43 +0000 Subject: [New-bugs-announce] [issue42886] math.log and math.log10 domain error on very large Fractions Message-ID: <1610318683.55.0.0487505722004.issue42886@roundup.psfhosted.org> New submission from Camion : Python is able to computer the logarithms of very large integers and fractions (by using log(num)-log(denom)), However the fractions.Fraction class fails to do it and raises a math domain error exception. >>> import math, fractions >>> f=fractions.Fraction(math.factorial(10000), math.factorial(20000)+1) >>> math.log(f.numerator)-math.log(f.denominator) -95966.69390038431 >>> math.log(f) Traceback (most recent call last): File "", line 1, in math.log(f) ValueError: math domain error >>> math.log10(f.numerator)-math.log10(f.denominator) -41677.80560743537 >>> math.log10(f) Traceback (most recent call last): File "", line 1, in math.log10(f) ValueError: math domain error ---------- components: Library (Lib) messages: 384783 nosy: Camion priority: normal severity: normal status: open title: math.log and math.log10 domain error on very large Fractions versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 02:38:04 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Mon, 11 Jan 2021 07:38:04 +0000 Subject: [New-bugs-announce] [issue42887] Multiple assignments of attribute "__sizeof__" will cause a segfault Message-ID: <1610350684.08.0.491719857036.issue42887@roundup.psfhosted.org> New submission from Xinmeng Xia : In the following program 1? method "__sizeof__()" is called and assigned multiple times. The program can work well on Python 3.10. However if I change "__sizeof__()" to "__sizeof__". Then a segmentation fault is reported. I think something wrong for the parser when dealing build-in attribute assignment. program 1: ========================= mystr = "hello123" for x in range(1000000): mystr = mystr.__sizeof__() print(mystr) ========================= 56 28 28 ....... 28 28 Output: work well as expected. program 2: ========================== mystr = "hello123" for x in range(1000000): mystr = mystr.__sizeof__ print(mystr) ========================== ...... Segmentation fault (core dumped) Expected output: no segfault. ---------- components: Interpreter Core messages: 384797 nosy: xxm priority: normal severity: normal status: open title: Multiple assignments of attribute "__sizeof__" will cause a segfault type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 02:40:22 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Mon, 11 Jan 2021 07:40:22 +0000 Subject: [New-bugs-announce] =?utf-8?q?=5Bissue42888=5D_Not_installed_?= =?utf-8?b?4oCcbGliZ2NjX3Muc28uMeKAnSBjYXVzZXMgcGFyc2VyIGNyYXNoLg==?= Message-ID: <1610350822.34.0.431759793604.issue42888@roundup.psfhosted.org> New submission from Xinmeng Xia : The following thread program will cause Python3.10 parser "core dump" due to missing ?libgcc_s.so.1?. "pthread_cancel" cannot work correctly. I am wondering is there any possible to install or link to libgcc_s.so.1 during Python installation? =================================== import socket from threading import Thread class thread(Thread): def run(self): for res in socket.getaddrinfo('www.google.com',8080): sock = socket.socket() sock.connect(res[4]) for i in range(2000): thread().start() ==================================== Error message: --------------------------------------------------------------- ........ Exception in thread Thread-1346: Traceback (most recent call last): File "/usr/local/python310/lib/python3.10/threading.py", line 960, in _bootstrap_inner File "/usr/local/python310/lib/python3.10/threading.py", line 960, in _bootstrap_inner Exception in thread Thread-1172: Traceback (most recent call last): ....... Exception in thread Thread-1509: Exception in thread Thread-1510: libgcc_s.so.1 must be installed for pthread_cancel to work Exception in thread Thread-1511: Traceback (most recent call last): Aborted (core dumped) --------------------------------------------------------------- ---------- components: Interpreter Core messages: 384798 nosy: xxm priority: normal severity: normal status: open title: Not installed ?libgcc_s.so.1? causes parser crash. type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 02:45:39 2021 From: report at bugs.python.org (Xinmeng Xia) Date: Mon, 11 Jan 2021 07:45:39 +0000 Subject: [New-bugs-announce] [issue42889] Incorrect behavior of Python parser after ast node of test program being modified Message-ID: <1610351139.91.0.540037450972.issue42889@roundup.psfhosted.org> New submission from Xinmeng Xia : The following program will lead to a incorrect behavior of Python parser. We change all variable to integer( forcely transformed to string) via ast.NodeTransformer. Then we compile the new code and execute it. It's surprising that code like "1=2; print(1)" can be compiled without error message. And more surprisingly, the execution result of "print(1)" is 2 ! ! ==================================== import ast class RewriteName(ast.NodeTransformer): def visit_Name(self, node): if node.id != "print": node.id = str(node.lineno) return node code = "a = 2;print(a)" myast = ast.parse(code) transformer = RewriteName() newast = transformer.visit(myast) # print(ast.dump(newast)) print("new code:","------------") print(ast.unparse(newast)) print("------------") c = compile(newast,'','exec') exec(c) ================================= output result: new code: ------------ 1 = 2 print(1) ------------ 2 Expected result: (1). Syntax error during compilation. "1" should not be the correct identifier of program, even if it's forcely transformed to string. (2). The output of execution should be "1" , since the parameter of "print()" in the new code is string "1". This incorrect behaviors exists on all version of Python(from Python2 to Python 3). ---------- components: Interpreter Core messages: 384799 nosy: xxm priority: normal severity: normal status: open title: Incorrect behavior of Python parser after ast node of test program being modified type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 05:26:19 2021 From: report at bugs.python.org (Wlodek) Date: Mon, 11 Jan 2021 10:26:19 +0000 Subject: [New-bugs-announce] [issue42890] bug float to int Message-ID: <1610360779.86.0.614039765509.issue42890@roundup.psfhosted.org> New submission from Wlodek : Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> f=0.1234/100 >>> f2= f*10**8 >>> i2= int(f2) >>> print("float=%f, float_2=%f, int(float_2)=%d" % (f, f2, int(f2))) float=0.001234, float_2=123400.000000, int(float_2)=123399 ---------- components: Library (Lib) messages: 384807 nosy: wlodek priority: normal severity: normal status: open title: bug float to int versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 09:48:27 2021 From: report at bugs.python.org (Amirouche Boubekki) Date: Mon, 11 Jan 2021 14:48:27 +0000 Subject: [New-bugs-announce] [issue42891] segfault with gunicorn and a library made with cython bindings Message-ID: <1610376507.28.0.240401298439.issue42891@roundup.psfhosted.org> New submission from Amirouche Boubekki : Here is a simple way to reproduce: from lsm import LSM db = LSM('db.sqlite') def app(environ, start_response): """Simplest possible application object""" for (index, (key, value)) in enumerate(db[b'\x00':b'\xFF']): pass start_response(b'200', {}) return b'' db.close() In my real program, if I add 'global db' in the function `app`, it does not segfault. program: https://git.sr.ht/~amirouche/segfault trace: https://wyz.fr/0I-MO ---------- messages: 384836 nosy: amirouche priority: normal severity: normal status: open title: segfault with gunicorn and a library made with cython bindings type: crash versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 11:45:57 2021 From: report at bugs.python.org (Xavier Hausherr) Date: Mon, 11 Jan 2021 16:45:57 +0000 Subject: [New-bugs-announce] [issue42892] AttributeError in email.message.get_body() Message-ID: <1610383557.89.0.290771399006.issue42892@roundup.psfhosted.org> New submission from Xavier Hausherr : Following this issue: https://bugs.python.org/issue33972 Same bug apply to email.message.get_body() with attached email example and the following code: from email.policy import default import email with open('email_bad_formatted.eml', 'rb') as fp: msg = email.message_from_binary_file(fp, policy=default) body = msg.get_body() > Result: E AttributeError: 'str' object has no attribute 'is_attachment' /usr/local/lib/python3.9/email/message.py:978: AttributeError ---------- components: email files: email_bad_formatted.eml messages: 384847 nosy: barry, iritkatriel, r.david.murray, xavier2 priority: normal severity: normal status: open title: AttributeError in email.message.get_body() versions: Python 3.9 Added file: https://bugs.python.org/file49734/email_bad_formatted.eml _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Jan 11 12:12:45 2021 From: report at bugs.python.org (robpats) Date: Mon, 11 Jan 2021 17:12:45 +0000 Subject: [New-bugs-announce] [issue42893] Strange XPath search behavior of xml.etree.ElementTree.Element.find Message-ID: <1610385165.69.0.550442509332.issue42893@roundup.psfhosted.org> New submission from robpats : Python 3.6.8 / 3.7.9 / 3.8.7 >>> import xml.etree.ElementTree >>> e = xml.etree.ElementTree.fromstring('