From report at bugs.python.org Mon Feb 1 06:37:39 2021 From: report at bugs.python.org (Livio Bencik) Date: Mon, 01 Feb 2021 11:37:39 +0000 Subject: [New-bugs-announce] [issue43090] parseaddr (from email.utils) returns invalid input string instead of ('', '') Message-ID: <1612179459.91.0.769211579588.issue43090@roundup.psfhosted.org> New submission from Livio Bencik : ``` from email.utils import parseaddr parseaddr('randomstring') ``` returns ('', 'randomstring'), instead of ('', '') as the documentation says. ---------- components: email messages: 386062 nosy: barry, lbenc135, r.david.murray priority: normal severity: normal status: open title: parseaddr (from email.utils) returns invalid input string instead of ('', '') type: behavior versions: Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 09:15:27 2021 From: report at bugs.python.org (twoone3) Date: Mon, 01 Feb 2021 14:15:27 +0000 Subject: [New-bugs-announce] [issue43091] console encode is not utf-8!! Message-ID: <1612188927.24.0.642164421259.issue43091@roundup.psfhosted.org> New submission from twoone3 <3197653242 at qq.com>: https://docs.python.org/3/c-api/init_config.html?highlight=pypreconfig_initpythonconfig#c.PyPreConfig When I use this api,The coding of the console has not changed,utf8_mode is 1. This is my code. PyPreConfig_InitPythonConfig(&cfg); cfg.utf8_mode = -1; Py_PreInitialize(&cfg); ---------- messages: 386069 nosy: twoone3 priority: normal severity: normal status: open title: console encode is not utf-8!! type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 10:51:40 2021 From: report at bugs.python.org (Daniel Colascione) Date: Mon, 01 Feb 2021 15:51:40 +0000 Subject: [New-bugs-announce] [issue43092] Python installation fails to install pip3 if pip, setuptools in ~/.local Message-ID: <1612194700.53.0.93300728958.issue43092@roundup.psfhosted.org> New submission from Daniel Colascione : The ensurepip module in the Python distribution bootstraps the pip package manager. The Python build system runs this module during installation so that the resulting Python installation is ready to install packages. Right now, the pip command that ensurepip installs the pip and setuptools packages only if it doesn't find them installed already. The problem is that the pip run by ensurepip checks for its bootstrap packages in ~/.local, and if it finds them there, it concludes it doesn't need to install these packages as part of bootstrap. But in various situations (e.g., installing Python into an isolated environment), these packages need to be installed anyway. ensurepip should ignore packages in ~/.local, at least when as part of the Python build system ---------- components: Installation messages: 386079 nosy: quotemstr priority: normal severity: normal status: open title: Python installation fails to install pip3 if pip, setuptools in ~/.local versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 14:17:44 2021 From: report at bugs.python.org (Arusekk) Date: Mon, 01 Feb 2021 19:17:44 +0000 Subject: [New-bugs-announce] [issue43093] Make modules picklable Message-ID: <1612207064.95.0.494686404563.issue43093@roundup.psfhosted.org> New submission from Arusekk : Currently pickling functions and types stores modules by their name. So I believe it is possible to support pickling module objects with the following code (based on the logic in PyPy, which supports pickling modules): import copyreg import types import pickle import sys def picklemod(mod): if mod.__name__ in sys.modules: # real modules return (__import__, (mod.__name__, None, None, ('',))) # module objects created manually: return (types.ModuleType, (mod.__name__,), mod.__dict__) copyreg.pickle(types.ModuleType, picklemod) pickle.loads(pickle.dumps(sys)) # works import http.server pickle.loads(pickle.dumps(http.server)) # works for nested modules fakemod = types.ModuleType('fakemod') fakemod.field1 = 'whatever' # This fake type is used instead of types.ModuleType in order to re-confuse pickle back on track. # Should not have been necessary in the first place, # but types.ModuleType has misconfigured fields according to pickle # (and they are read-only). class _types_ModuleType(types.ModuleType): __module__ = 'types' __name__ = __qualname__ = 'ModuleType' _orig_types_ModuleType = types.ModuleType # bad monkey-patching, but needed for the confusion to work types.ModuleType = _types_ModuleType dump = pickle.dumps(fakemod) # not necessary, but to show unpickling is regardless correct types.ModuleType = _orig_types_ModuleType pickle.loads(dump).field1 # works Disclaimer: I do not see any specific use for this, I was just surprised while trying to port snakeoil library to PyPy, which (snakeoil) uses sys module as an example of an unpicklable object (they should switch to a traceback for instance, but that is not the scope of this issue). ---------- components: Library (Lib) messages: 386090 nosy: Arusekk priority: normal severity: normal status: open title: Make modules picklable type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 15:10:10 2021 From: report at bugs.python.org (Nicholas Chammas) Date: Mon, 01 Feb 2021 20:10:10 +0000 Subject: [New-bugs-announce] [issue43094] sqlite3.create_function takes parameter named narg, not num_params Message-ID: <1612210210.19.0.0751315887137.issue43094@roundup.psfhosted.org> New submission from Nicholas Chammas : The doc for sqlite3.create_function shows the signature as follows: https://docs.python.org/3.9/library/sqlite3.html#sqlite3.Connection.create_function ``` create_function(name, num_params, func, *, deterministic=False) ``` But it appears that the parameter name is `narg`, not `num_params`. Trying `num_params` yields: ``` TypeError: function missing required argument 'narg' (pos 2) ``` ---------- assignee: docs at python components: Documentation messages: 386100 nosy: docs at python, nchammas priority: normal severity: normal status: open title: sqlite3.create_function takes parameter named narg, not num_params versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 15:16:33 2021 From: report at bugs.python.org (Jairo Llopis) Date: Mon, 01 Feb 2021 20:16:33 +0000 Subject: [New-bugs-announce] [issue43095] Windows does not raise IsADirectoryError Message-ID: <1612210593.79.0.943479970127.issue43095@roundup.psfhosted.org> New submission from Jairo Llopis : Trying to read a directory on Linux raises the expected exception: Python 3.9.1 (default, Jan 20 2021, 00:00:00) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pathlib >>> pathlib.Path(".venv").read_text() Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.9/pathlib.py", line 1255, in read_text with self.open(mode='r', encoding=encoding, errors=errors) as f: File "/usr/lib64/python3.9/pathlib.py", line 1241, in open return io.open(self, mode, buffering, encoding, errors, newline, IsADirectoryError: [Errno 21] Is a directory: '.venv' Doing the same on Windows raises a misleading permission error instead: >>> import pathlib >>> pathlib.Path(".venv").read_text() Traceback (most recent call last): File "", line 1, in File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1255, in read_text with self.open(mode='r', encoding=encoding, errors=errors) as f: File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1241, in open return io.open(self, mode, buffering, encoding, errors, newline, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1109, in _opener return self._accessor.open(self, flags, mode) PermissionError: [Errno 13] Permission denied: '.venv' ---------- components: Windows messages: 386103 nosy: Jairo Llopis, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Windows does not raise IsADirectoryError versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 16:14:14 2021 From: report at bugs.python.org (jakirkham) Date: Mon, 01 Feb 2021 21:14:14 +0000 Subject: [New-bugs-announce] [issue43096] Adding `read_into` method to `asyncio.StreamReader` Message-ID: <1612214054.71.0.664238583626.issue43096@roundup.psfhosted.org> New submission from jakirkham : To allow reading into a provided buffer without copying, it would be useful to have a `read_into` method on `asyncio.StreamReader`, which takes a buffer supporting the buffer protocol and fills it. ---------- components: asyncio messages: 386114 nosy: asvetlov, jakirkham, yselivanov priority: normal severity: normal status: open title: Adding `read_into` method to `asyncio.StreamReader` type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 23:07:52 2021 From: report at bugs.python.org (wyz23x2) Date: Tue, 02 Feb 2021 04:07:52 +0000 Subject: [New-bugs-announce] [issue43097] IndexError msg of random.choice() not helpful Message-ID: <1612238872.93.0.407149232495.issue43097@roundup.psfhosted.org> New submission from wyz23x2 : When you apply `random.choice` on empty sequences: >>> import random >>> random.choice([]) Traceback (most recent call last): File "", line 2, in return seq[self._randbelow(len(seq))] IndexError: list index out of range This message doesn't clearly state the real problem -- an empty seq. Meanwhile, many other methods give messages. >>> [].pop() Traceback (most recent call last): File "", line 3, in IndexError: pop from empty list >>> import collections >>> collections.deque().popleft() Traceback (most recent call last): File "", line 5, in IndexError: pop from an empty deque >>> random.randrange(0, 0) Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python39\lib\random.py", line 316, in randrange raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (0, 0, 0) P.S. Both are empty sequences/ranges, randrange() raises ValueError, while choice() raises IndexError. ---------- components: Library (Lib) messages: 386128 nosy: wyz23x2 priority: normal severity: normal status: open title: IndexError msg of random.choice() not helpful versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 1 23:35:47 2021 From: report at bugs.python.org (Val Shkolnikov) Date: Tue, 02 Feb 2021 04:35:47 +0000 Subject: [New-bugs-announce] [issue43098] tarfile list() method does not show file type Message-ID: <1612240547.16.0.611621491067.issue43098@roundup.psfhosted.org> New submission from Val Shkolnikov : The list() method of TarFile tarfile object shows question mark in place of file type in verbose mode. For instance python3 -m tarfile -v -l my.tar ?rwxr-xr-x vals/users 0 2021-01-16 18:28:30 bin/ ?rwxr-x--- vals/users 266 2021-01-16 18:28:30 bin/backmine.sh ?rwxr-xr-x vals/users 950 2018-01-02 10:39:18 bin/tm.sh ?rwxrwxrwx vals/users 0 2021-01-16 11:49:36 bin/source-highlight -> ../source-highlight/bin/source-highlight ?rwxr-xr-x vals/users 435 2011-03-27 15:38:06 bin/dd.sh This is because the call stat.filemode(tarinfo.mode) does not pass tarinfo.type to stat.filemode. The type needs to be properly encoded and added to the argument. My patch is attached. Verified under Linux, Cygwin and Windows. ---------- files: patch messages: 386129 nosy: val.shkolnikov priority: normal severity: normal status: open title: tarfile list() method does not show file type type: behavior versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file49786/patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 03:06:03 2021 From: report at bugs.python.org (iqanansoft) Date: Tue, 02 Feb 2021 08:06:03 +0000 Subject: [New-bugs-announce] [issue43099] Deleted positions lists Message-ID: <1612253163.41.0.307973043012.issue43099@roundup.psfhosted.org> New submission from iqanansoft : Hello, in a list, when using the slice notation, if a higher rank is placed than the new data, the positions of the list are removed list_test=[0,1,2,3,4,5,6] list_test[2:4]=["two","three"] result-->[0,1,'two','three',4,5,6] this is correct, but this list_test=[0,1,2,3,4,5,6] list_test[2:21]=["two","three"] result-->[0,1,'two','three'] deleted last positions ---------- messages: 386130 nosy: iqanansoft priority: normal severity: normal status: open title: Deleted positions lists type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 05:49:04 2021 From: report at bugs.python.org (Divyanshu) Date: Tue, 02 Feb 2021 10:49:04 +0000 Subject: [New-bugs-announce] [issue43100] Python fails to execute shiv pyz files greater than 2 GB Message-ID: <1612262944.94.0.282319257878.issue43100@roundup.psfhosted.org> New submission from Divyanshu : Issue with shiv packages greater than 2GBs. Any shiv package(.pyz) greater than 2 GB fails to execute on python. Getting the below error with a simple shiv package that contains a main file that prints Hello World, and some random data files crossing the 2GB mark (can be a data file, a zip file or whatever unrelated) Error - cannot find 'main' module in abc.pyz On removing some of the redundant data files so that the size becomes less than 2 GB, the package becomes functional again. ---------- messages: 386135 nosy: divyanshurastogi4 priority: normal severity: normal status: open title: Python fails to execute shiv pyz files greater than 2 GB type: behavior versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 07:52:41 2021 From: report at bugs.python.org (Gereon Kremer) Date: Tue, 02 Feb 2021 12:52:41 +0000 Subject: [New-bugs-announce] [issue43101] Add deprecation of float limits for resource to documentation Message-ID: <1612270361.12.0.132616199639.issue43101@roundup.psfhosted.org> New submission from Gereon Kremer : While the documentation always (as in: at least since 3.5) required to pass "a tuple (soft, hard) of two integers" to resource.setrlimit(), passing floats worked just fine until 3.9. This behavior was deprecated in 3.8 and removed in 3.10. I see that the implementation was merely fixed to do what the documentation says. Nevertheless, I think this change of behavior should be mentioned in the documentation. In my use-case for resource (within preexec_fn of subprocess.Popen), this deprecation warning only showed up in 3.9 for some reason (as you can see here: https://github.com/nafur/python-playground/runs/1814573503) and is now hidden by a generic "subprocess.SubprocessError: Exception occurred in preexec_fn." message. A hint in the documentation would have helped significantly... ---------- messages: 386139 nosy: nafur priority: normal severity: normal status: open title: Add deprecation of float limits for resource to documentation versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 09:46:44 2021 From: report at bugs.python.org (Douglas Raillard) Date: Tue, 02 Feb 2021 14:46:44 +0000 Subject: [New-bugs-announce] [issue43102] namedtuple's __new__.__globals__['__builtins__'] is None Message-ID: <1612277204.9.0.79430264778.issue43102@roundup.psfhosted.org> New submission from Douglas Raillard : When creating a namedtuple such as this one: from collections import namedtuple class C(namedtuple('C', ('hello', 'world'))): pass print(C.__new__.__globals__) The globals' dict of __new__ contains a "__builtins__" key which is set to None in collections/__init__.py: namespace = { '_tuple_new': tuple_new, '__builtins__': None, '__name__': f'namedtuple_{typename}', } When such globals are used with eval(), it will raise a TypeError such as: >>> eval('X', {'__builtins__': None}) Traceback (most recent call last): File "", line 1, in File "", line 1, in TypeError: 'NoneType' object is not subscriptable If an empty dict was used instead, we get the expected exception: >>> eval('X', {'__builtins__': {}}) Traceback (most recent call last): File "", line 1, in File "", line 1, in NameError: name 'X' is not defined Given that both ways allow preventing references to any builtin, please consider switching to an empty dict. Also, even though this is documented as implementation detail, this would agree more with the current documentation stating: The value of __builtins__ is normally either this module or the value of this module?s __dict__ attribute https://docs.python.org/3/library/builtins.html ---------- components: Library (Lib) messages: 386145 nosy: douglas-raillard-arm priority: normal severity: normal status: open title: namedtuple's __new__.__globals__['__builtins__'] is None type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 10:23:47 2021 From: report at bugs.python.org (STINNER Victor) Date: Tue, 02 Feb 2021 15:23:47 +0000 Subject: [New-bugs-announce] [issue43103] Add configure option to disable build libpython.a and don't install python.o Message-ID: <1612279427.78.0.51879378101.issue43103@roundup.psfhosted.org> New submission from STINNER Victor : Currently, "make install" copies Programs/python.o to $prefix/lib/python3.10/config-3.10-x86_64-linux-gnu/: see bpo-42307. This file is only useful to build a static Python executable with libpython3.10.a. libpython3.10.a is also copied to $prefix/lib/python3.10/config-3.10-x86_64-linux-gnu/. Most users don't build a static Python executable, so I propose to no longer build "static Python" by default and add --with-static-python option to the configure script. --- Fedora has a downstream patch to not build libpythonX.Y.a for 11 years: https://src.fedoraproject.org/rpms/python3.10/blob/master/f/00111-no-static-lib.patch It is needed to respect the Fedora packaging guideline. The patch was introduced in Fedora to fix "python : does not adhere to Static Library Packaging Guideline" issue: https://bugzilla.redhat.com/show_bug.cgi?id=556092 """ The package is in need of an update because it does not adhere to the guidelines for packaging static libraries: http://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries The -devel package contains both the shared and the static build of a library. That makes it possible to link statically with the -devel package as a build requirement instead of having to build-require a special-purpose -static subpackage. Correct would be to either disable/delete the static libraries at build-time, or to %exclude them in the %files section, or to split off a -static subpackage (if there is a compelling reason as why the static libs should be made available). Please consult the guidelines for the details. [...] python-devel /usr/lib/python2.6/config/libpython2.6.so <=> /usr/lib/python2.6/config/libpython2.6.a """ ---------- components: Build messages: 386149 nosy: vstinner priority: normal severity: normal status: open title: Add configure option to disable build libpython.a and don't install python.o versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 10:51:43 2021 From: report at bugs.python.org (=?utf-8?q?Tobias_M=C3=BCllner?=) Date: Tue, 02 Feb 2021 15:51:43 +0000 Subject: [New-bugs-announce] [issue43104] csv package in class Message-ID: <1612281103.22.0.0770164385179.issue43104@roundup.psfhosted.org> New submission from Tobias M?llner : Hello I want to use the csv package in a class. If I use the writer instance as local variable in the class it works perfectly but if I use it as class-variable (self.writer) it does not work anymore. Does anyone have the same behaviour? Yours Toby By the way, sorry for my bad English :( ---------- messages: 386151 nosy: tobias.muellner250502 priority: normal severity: normal status: open title: csv package in class type: behavior versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 12:03:00 2021 From: report at bugs.python.org (Simon Munday) Date: Tue, 02 Feb 2021 17:03:00 +0000 Subject: [New-bugs-announce] [issue43105] Can't import extension modules resolved via relative paths in sys.path on Windows don't don't Message-ID: <1612285380.24.0.495785451269.issue43105@roundup.psfhosted.org> New submission from Simon Munday : If I attempt to import an extension module via something like this: from pkg import extmodule and it happens that "pkg" is found in a folder that is given in sys.path as a relative path, then the import fails, with ImportError: DLL load failed while importing extmodule: The parameter is incorrect. This only happens with 3.8 and later. AFAICS the reason is that if the module resolution is done via a relative path, it results in dynload_win.c:_PyImport_FindSharedFuncptrWindows attempting to feed LoadLibraryExW a relative path for the .pyd file. But LoadLibraryExW treats relative paths completely differently from absolute ones, in that it searches for the given path relative to the library search path entries rather than simply loading the DLL at that path. But as of 3.8 the current directory is removed from the search path, so the .pyd is never found. Since Python knows the specific file it wants LoadLibraryExW to load, having just resolved it via the import mechanism, I guess it ought to ensure it only ever calls LoadLibraryExW with an absolute path. (I'm assuming use of relative paths in sys.path is officially supported, since nothing I've found in the docs says otherwise.) ---------- components: Extension Modules messages: 386155 nosy: smunday priority: normal severity: normal status: open title: Can't import extension modules resolved via relative paths in sys.path on Windows don't don't type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 14:26:29 2021 From: report at bugs.python.org (Ronald Oussoren) Date: Tue, 02 Feb 2021 19:26:29 +0000 Subject: [New-bugs-announce] [issue43106] Some macOS open flags are missing from posixmodule.c Message-ID: <1612293989.13.0.0432139377352.issue43106@roundup.psfhosted.org> New submission from Ronald Oussoren : The following O_* flags are present in the macOS 11 SDK, but aren't provided by posixmodule.c: O_FSYNC (alias for O_SYNC) O_EVTONLY O_SYMLINK O_NOFOLLOW_ANY ---------- components: Extension Modules, macOS keywords: easy (C) messages: 386159 nosy: ned.deily, ronaldoussoren priority: normal severity: normal stage: needs patch status: open title: Some macOS open flags are missing from posixmodule.c type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 14:58:28 2021 From: report at bugs.python.org (Yotam Medini) Date: Tue, 02 Feb 2021 19:58:28 +0000 Subject: [New-bugs-announce] [issue43107] RotatingFileHandler with multi processes creates too small backup files Message-ID: <1612295908.37.0.851347106037.issue43107@roundup.psfhosted.org> New submission from Yotam Medini : Using RotatingFileHandler by multi-processes when they reach a point for rotation (roll-over) they continue on separate files. Two problems: 1. Eventually some backup files are left with sizes much less than the maxBytes configuration. 2. Intertwining events are not logged together, but separated by processes. ---------- components: Library (Lib) messages: 386165 nosy: yotam priority: normal severity: normal status: open title: RotatingFileHandler with multi processes creates too small backup files type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 15:02:14 2021 From: report at bugs.python.org (Pablo Galindo Salgado) Date: Tue, 02 Feb 2021 20:02:14 +0000 Subject: [New-bugs-announce] [issue43108] test_curses is leaking references Message-ID: <1612296134.53.0.710661977317.issue43108@roundup.psfhosted.org> New submission from Pablo Galindo Salgado : ? ./python -m test test_curses -uall -R : 0:00:00 load avg: 3.77 Run tests sequentially 0:00:00 load avg: 3.77 [1/1] test_curses beginning 9 repetitions 123456789 . test_curses leaked [4, 4, 4, 4] references, sum=16 test_curses failed == Tests result: FAILURE == 1 test failed: test_curses Total duration: 2.5 sec Tests result: FAILURE https://buildbot.python.org/all/#/builders/75/builds/168/steps/5/logs/stdio ---------- components: Tests messages: 386166 nosy: pablogsal priority: normal severity: normal status: open title: test_curses is leaking references versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 2 17:52:49 2021 From: report at bugs.python.org (Andrew C. Morrow) Date: Tue, 02 Feb 2021 22:52:49 +0000 Subject: [New-bugs-announce] [issue43109] When using Apple Clang, --with-lto builds should not check for llvm-ar Message-ID: <1612306369.28.0.04507829507.issue43109@roundup.psfhosted.org> New submission from Andrew C. Morrow : When building with `--with-lto`, an explicit check for `llvm-ar` is performed as part of the configure step. However, Apple does not ship `llvm-ar` as part of Xcode, so when building with Apple Clang this check fails and prevents using `--with-lto`. However, using the builtin `ar` seems to work just fine, and it can be selected by passing `LLVM_AR=/path/to/ar` to `configure`. It would be nice to see the `configure` script updated to know that system `ar` is sufficient when using Apple Clang on macOS. Please see https://github.com/Homebrew/homebrew-core/pull/70177 for additional background. ---------- components: Build messages: 386174 nosy: acmorrow priority: normal severity: normal status: open title: When using Apple Clang, --with-lto builds should not check for llvm-ar type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 03:31:31 2021 From: report at bugs.python.org (Giovanni Wijaya) Date: Wed, 03 Feb 2021 08:31:31 +0000 Subject: [New-bugs-announce] [issue43110] import aiohttp crash closes Python from Windows Installer Message-ID: <1612341091.34.0.557735217217.issue43110@roundup.psfhosted.org> New submission from Giovanni Wijaya : Since Python 3.10.0a4, importing aiohttp crash closes Python, only on Python installed from Windows Installer x64. Python installed in Debian (both from source and otherwise) does not produce this issue. ---------- components: Windows messages: 386180 nosy: giovanniwijaya, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: import aiohttp crash closes Python from Windows Installer versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 04:21:34 2021 From: report at bugs.python.org (hans.meine) Date: Wed, 03 Feb 2021 09:21:34 +0000 Subject: [New-bugs-announce] [issue43111] webbrowser.py triggers unwanted XQuartz startup Message-ID: <1612344094.48.0.0202402812851.issue43111@roundup.psfhosted.org> New submission from hans.meine : For a long time, I wondered why opening Jupyter notebooks through nbopen always led to XQuartz starting. Now, I found the reason: nbopen uses webbrowser.py to open a web page, and webbrowser.py sees the `DISPLAY` variable being set and calls xdg-settings (which I installed via the xdg-utils port / MacPorts). Apparently, in order to be able to fire up XQuartz on demand and to allow people starting X11 applications, `DISPLAY` is set to a string like `/private/tmp/com.apple.launchd./org.xquartz:0`. I am using Safari and find this starting of XQuartz undesirable (causes a delay, uses system resources, leads to a new running program in the Dock / task switcher). On the other hand I can totally understand that the code makes sense. As a workaround, I can unset DISPLAY, or uninstall xdg-utils (although it is useful, and may be a dependency of other ports), but I thought I should also bring it up here for discussion. ---------- components: Library (Lib), macOS messages: 386182 nosy: hans-meine, ned.deily, ronaldoussoren priority: normal severity: normal status: open title: webbrowser.py triggers unwanted XQuartz startup type: resource usage versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 04:26:13 2021 From: report at bugs.python.org (Natanael Copa) Date: Wed, 03 Feb 2021 09:26:13 +0000 Subject: [New-bugs-announce] [issue43112] SOABI on Linux does not distinguish between GNU libc and musl libc Message-ID: <1612344373.45.0.663786135841.issue43112@roundup.psfhosted.org> New submission from Natanael Copa : The SOABI does not make any difference between GNU libc and musl libc. Using official docker images: # debian build with GNU libc $ docker run --rm python:slim python -c 'import sysconfig;print(sysconfig.get_config_var("SOABI"))' cpython-39-x86_64-linux-gnu # alpine build with musl libc $ docker run --rm python:alpine python -c 'import sysconfig;print(sysconfig.get_config_var("SOABI"))' cpython-39-x86_64-linux-gnu Both ends with `-gnu`, while it would be expected that with musl it would end with `-musl` This affects the extension suffix: $ docker run --rm python:slim python-config --extension-suffix .cpython-39-x86_64-linux-gnu.so $ docker run --rm python:alpine python-config --extension-suffix .cpython-39-x86_64-linux-gnu.so Which again affects the pre-compiled binary wheels, and binary modules built with musl libc gets mixed up with the GNU libc modules due to the -gnu.so suffix. The source of the problem is that the `configure.ac` file assumes that all defined(__linux__) is -gnu when detecting the PLATFORM_TRIPLET. ``` ... #if defined(__ANDROID__) # Android is not a multiarch system. #elif defined(__linux__) # if defined(__x86_64__) && defined(__LP64__) x86_64-linux-gnu # elif defined(__x86_64__) && defined(__ILP32__) x86_64-linux-gnux32 # elif defined(__i386__) ... ``` So when building python with musl libc the PLATFORM_TRIPLET always sets `*-linux-gnu`. output from configure run on musl system: ``` ... checking for a sed that does not truncate output... /bin/sed checking for --with-cxx-main=... no checking for the platform triplet based on compiler characteristics... x86_64-linux-gnu ... ``` A first step in fixing this would be to make sure that we only set -gnu when __GLIBC__ is defined: ```diff diff --git a/configure.ac b/configure.ac index 1f5a008388..1b4690c90f 100644 --- a/configure.ac +++ b/configure.ac @@ -726,7 +726,7 @@ cat >> conftest.c < _______________________________________ From report at bugs.python.org Wed Feb 3 05:43:04 2021 From: report at bugs.python.org (Tomas Orsava) Date: Wed, 03 Feb 2021 10:43:04 +0000 Subject: [New-bugs-announce] [issue43113] os.posix_spawn errors with wrong information when shebang does not exist Message-ID: <1612348984.98.0.934369937347.issue43113@roundup.psfhosted.org> New submission from Tomas Orsava : os.posix_spawn fails with a wrong error information when executing an existing file with shebang pointing to a non-existing file. $ cat demo #!/usr/bin/hugo $ ./demo bash: ./demo: /usr/bin/hugo: bad interpreter: No such file or directory $ cat repro.py import os os.posix_spawn("./demo", ["./demo"], {}) $ python3.10 repro.py Traceback (most recent call last): File "/home/torsava/mess-old/2021-02/python-popen/repro.py", line 2, in os.posix_spawn("./demo", ["./demo"], {}) FileNotFoundError: [Errno 2] No such file or directory: './demo' The same problem exists when `demo` is on the PATH. $ export PATH=".:$PATH" $ demo bash: ./demo: /usr/bin/hugo: bad interpreter: No such file or directory $ cat repro_path.py import os os.posix_spawn("demo", ["demo"], {}) $ python3.10 repro_path.py Traceback (most recent call last): File "/home/torsava/mess-old/2021-02/python-popen/repro_path.py", line 2, in os.posix_spawn("demo", ["demo"], {}) FileNotFoundError: [Errno 2] No such file or directory: 'demo' ---------- components: Library (Lib) messages: 386187 nosy: torsava priority: normal severity: normal status: open title: os.posix_spawn errors with wrong information when shebang does not exist type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 07:00:36 2021 From: report at bugs.python.org (hpant) Date: Wed, 03 Feb 2021 12:00:36 +0000 Subject: [New-bugs-announce] [issue43114] Python 3.6 MSI Installer for Windows Message-ID: <1612353636.85.0.649798003305.issue43114@roundup.psfhosted.org> New submission from hpant : Hi Team, We would lie to have python 3.6 MSI Installer for Azure VDI. so that it will be applicablefor all users in azure. Please provide installation file ---------- components: Installation messages: 386198 nosy: hpant priority: normal severity: normal status: open title: Python 3.6 MSI Installer for Windows type: enhancement versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 08:42:50 2021 From: report at bugs.python.org (Anders Munch) Date: Wed, 03 Feb 2021 13:42:50 +0000 Subject: [New-bugs-announce] [issue43115] locale.getlocale fails if locale is set Message-ID: <1612359770.32.0.137300123748.issue43115@roundup.psfhosted.org> New submission from Anders Munch : getlocale fails with an exception when the string returned by _setlocale is already an RFC 1766 language tag. Example: Python 3.10.0a4 (tags/v3.10.0a4:445f7f5, Jan 4 2021, 19:55:53) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> locale.setlocale(locale.LC_ALL, 'en-US') 'en-US' >>> locale.getlocale() Traceback (most recent call last): File "", line 1, in File "C:\flonidan\env\Python310\lib\locale.py", line 593, in getlocale return _parse_localename(localename) File "C:\flonidan\env\Python310\lib\locale.py", line 501, in _parse_localename raise ValueError('unknown locale: %s' % localename) ValueError: unknown locale: en-US Expected result: ('en-US', None) See https://github.com/wxWidgets/Phoenix/issues/1637 for an example of the ensuing problems. wx.Locale calls C setlocale directly, but, as far as I can see, correctly, using dashes in the language code which is consistent with not only RFC 1766 but also the examples in Microsoft's documentation (https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160). CPython seems to assume underscored names such as 'en_US' instead, as shown by getdefaultlocale inserting an underscore. ---------- components: Library (Lib), Windows messages: 386203 nosy: AndersMunch, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: locale.getlocale fails if locale is set versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 08:49:36 2021 From: report at bugs.python.org (Johannes) Date: Wed, 03 Feb 2021 13:49:36 +0000 Subject: [New-bugs-announce] [issue43116] Integer division numerical error Message-ID: <1612360176.06.0.161858956958.issue43116@roundup.psfhosted.org> New submission from Johannes : I'm a bit confused because this seems to be too obvious to be a bug: [code] >>> -2094820900 // 1298 -1613884 >>> -2094820900 // -1298 1613883 [/code] Obviously there is a +/- 1 difference in the result. Tested with Python 3.7, 3.8 and 3.9 on Debian Bullseye. Am I missing something? ---------- messages: 386204 nosy: jfu33.4 priority: normal severity: normal status: open title: Integer division numerical error type: behavior versions: Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 09:12:16 2021 From: report at bugs.python.org (chen-y0y0) Date: Wed, 03 Feb 2021 14:12:16 +0000 Subject: [New-bugs-announce] [issue43117] Translation Mistakes Message-ID: <1612361536.13.0.0607210393018.issue43117@roundup.psfhosted.org> New submission from chen-y0y0 : A example in this picture: In the red circles, the texts should not be translated. They should be their original states. Because these texts are options that programmers will input into their programs. If these texts are translated and input by that, the program will raise an error. In the green circke, the texts are not translated. ---------- assignee: docs at python components: Documentation files: 1E42294E-CA8F-4CAC-9AA7-79F3B05EE9D1.jpeg messages: 386209 nosy: docs at python, prasechen priority: normal severity: normal status: open title: Translation Mistakes type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49787/1E42294E-CA8F-4CAC-9AA7-79F3B05EE9D1.jpeg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 10:04:12 2021 From: report at bugs.python.org (Komiya Takeshi) Date: Wed, 03 Feb 2021 15:04:12 +0000 Subject: [New-bugs-announce] [issue43118] inspect.signature() raises RuntimeError on failed to resolve the default argument value Message-ID: <1612364652.22.0.413597788447.issue43118@roundup.psfhosted.org> New submission from Komiya Takeshi : inspect.signature() raises RuntimeError on failed to resolve the default argument value. For example, it fails to inspect a subclass of io.BufferedReader: Example: ``` import inspect import io class MyBufferedReader(io.BufferedReader): """buffer reader class.""" inspect.signature(MyBufferedReader) ``` Result: ``` Traceback (most recent call last): File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2042, in wrap_value value = eval(s, module_dict) File "", line 1, in NameError: name 'DEFAULT_BUFFER_SIZE' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2045, in wrap_value value = eval(s, sys_module_dict) File "", line 1, in NameError: name 'DEFAULT_BUFFER_SIZE' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/tkomiya/work/tmp/doc/example.py", line 9, in inspect.signature(MyBufferedReader) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 3130, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2879, in from_callable return _signature_from_callable(obj, sigcls=cls, File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2397, in _signature_from_callable return _signature_fromstr(sigcls, obj, text_sig) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2095, in _signature_fromstr p(name, default) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2077, in p default_node = RewriteSymbolics().visit(default_node) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/ast.py", line 407, in visit return visitor(node) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2069, in visit_Name return wrap_value(node.id) File "/Users/tkomiya/.pyenv/versions/3.9.1/lib/python3.9/inspect.py", line 2047, in wrap_value raise RuntimeError() RuntimeError ``` In my investigation, inspect.signature() tries to evaluate the default argument value of the class constructor. But it fails to evaluate because of the 2nd argument of the constructor takes a constant; `DEFAULT_BUFFER_SIZE`, but it is not found on the current context. I think it would be better to search the constants for the modules of the base classes. I just made a simple patch to resolve this bug. ---------- components: Library (Lib) files: inspect.patch keywords: patch messages: 386212 nosy: i.tkomiya priority: normal severity: normal status: open title: inspect.signature() raises RuntimeError on failed to resolve the default argument value versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49788/inspect.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 14:41:22 2021 From: report at bugs.python.org (Spencer Nelson) Date: Wed, 03 Feb 2021 19:41:22 +0000 Subject: [New-bugs-announce] [issue43119] asyncio.Queue.put never yields if the queue is unbounded Message-ID: <1612381282.49.0.371079618361.issue43119@roundup.psfhosted.org> New submission from Spencer Nelson : I am writing some software that reads records from a very large file (~hundreds of GB), putting them in an `asyncio.Queue` as it goes, and a chain of consumers handle each record and do stuff over the network. To my surprise, my program runs out of memory because the Queue producer coroutine never yields control. I think (but am not sure) that the asyncio.Queue.put method has no preemption point if the queue is not full; I was using an unbounded Queue, so it was _never_ full, so my coroutine was never unscheduled. I have attached a file with a minimal reproducer. It creates an unbounded queue. A 'publish' task calls `queue.put` from an infinite sequence. A 'subscribe' task calls `queue.get`, and prints each item. Nothing gets printed if I run this, because the `queue.put` never blocks. I would expect that `await queue.put` would occasionally cede execution to any other runnable coroutines, even if the queue is unbounded. ---------- components: asyncio files: never_yields.py messages: 386454 nosy: asvetlov, spenczar, yselivanov priority: normal severity: normal status: open title: asyncio.Queue.put never yields if the queue is unbounded type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file49789/never_yields.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 15:17:43 2021 From: report at bugs.python.org (Ronald Oussoren) Date: Wed, 03 Feb 2021 20:17:43 +0000 Subject: [New-bugs-announce] [issue43120] Some OSX syslog facilities are missing from syslog module Message-ID: <1612383463.54.0.705802596515.issue43120@roundup.psfhosted.org> New submission from Ronald Oussoren : The following syslog facility constants on macOS are missing from the syslog module: * LOG_FTP * LOG_NETINFO * LOG_REMOTEAUTH * LOG_INSTALL * LOG_RAS * LOG_LAUNCHD I'm working on a PR ---------- components: Extension Modules, macOS messages: 386456 nosy: ned.deily, ronaldoussoren priority: normal severity: normal stage: needs patch status: open title: Some OSX syslog facilities are missing from syslog module type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 16:05:50 2021 From: report at bugs.python.org (Andre Roberge) Date: Wed, 03 Feb 2021 21:05:50 +0000 Subject: [New-bugs-announce] [issue43121] Incorrect SyntaxError message for missing comma (3.10.a5) Message-ID: <1612386350.35.0.116114193403.issue43121@roundup.psfhosted.org> New submission from Andre Roberge : A missing comma between list items results in an incorrect message. Python 3.10.0a5 (tags/v3.10.0a5:b0478d7, Feb 3 2021, 01:44:54) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a = [1, 2 3] File "", line 1 a = [1, 2 3] ^ SyntaxError: did you forget parentheses around the comprehension target? ---------- messages: 386457 nosy: aroberge priority: normal severity: normal status: open title: Incorrect SyntaxError message for missing comma (3.10.a5) type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 3 20:03:35 2021 From: report at bugs.python.org (Kevin) Date: Thu, 04 Feb 2021 01:03:35 +0000 Subject: [New-bugs-announce] [issue43122] Python Launcher doesn't open a terminal window Message-ID: <1612400615.64.0.789800326005.issue43122@roundup.psfhosted.org> New submission from Kevin : Machine: new MacBook Air with M1 chip, running Big Sur Downloaded: Python versions 2.7, 3.8, and 3.9 Situation: Programs run just fine IF I run them out of a terminal window (/usr/local/bin/python name-of-python-program). Also programs that use Tkinter windows and don't require a terminal window for input or output run properly. Problem: Can't launch programs by double-clicking on them. When I try, Python Launcher starts and displays its preferences and there is a microsecond flash of something on the screen that appears to descend into the program icon that was clicked on. Note: Playing with a shebang in the program made no difference. Everything works fine when the programs are opened and run in IDLE. ---------- messages: 386473 nosy: kjw priority: normal severity: normal status: open title: Python Launcher doesn't open a terminal window type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 07:48:46 2021 From: report at bugs.python.org (Martin Ortner) Date: Thu, 04 Feb 2021 12:48:46 +0000 Subject: [New-bugs-announce] [issue43123] email MIME splitting Message-ID: <1612442926.7.0.976451859836.issue43123@roundup.psfhosted.org> New submission from Martin Ortner : // reported via PSRT email (see timeline) // external reference: https://consensys.net/diligence/vulnerabilities/private/jcchhpke7usq8wo45vloy282phwpd9fj41imumhb8varxahz2bf9afw5mcno84gx/ cve: vendor: python vendorUrl: https://www.python.org/ authors: tintinweb affectedVersions: [at least <= 3.8.3, <=3.7.7, <=2.7.18] vulnClass: CWE-93 # Vulnerability Note ## Summary >Python is a programming language that lets you work more quickly and integrate your systems more effectively. The python `email.mime` package fails to properly encode or reject `CR-LF` control sequences in MIME header values allowing for MIME splitting and header injection attacks. * `MIMEText[headerKey] = headerValue` - `headerValue` accepts `CR-LF` in the value, allowing an attacker in control of part of the header value to perform a MIME splitting attack. * `MIMEText[headerKey] = headerValue` - `headerKey` is not checked for `CR-LF` allowing an attacker in control of part of a header key to inject arbitrary MIME headers. * `MIMEText.add_header(headerKey, headerValue)` - `headerKey` is not checked for `CR-LF` allowing an attacker in control of part of a header key to inject arbitrary MIME headers. ## Details ### MIME-Splitting with `CR-LF` in header value: * Note: `CR-LF` injection in `To` header pushes an invalid header and may force a MIME split (depending on the parsing library) pushing following header values into the body when being parsed with the `email.message_from_string()` method. ```python # Import the email modules we'll need from email.mime.text import MIMEText # Open a plain text file for reading. For this example, assume that # the text file contains only ASCII characters. msg = MIMEText("REAL_MSG_BODY_BEGIN\n...\nREAL_MSG_BODY_END") msg['Subject'] = 'The contents of is this...' msg['To'] = "TO toAddress at oststrom.com\r\nX-SPLIT-MSG-TO-BODY\r\n" msg['From'] = "FROM fromAddress at oststrom.com" msg['MyHEader'] = "hi :: hi" print(msg) print(repr(msg)) print("=========================") import email msg = email.message_from_string(str(msg)) print(msg) print("-> FROM: %s" % msg.get("From")) print("-> TO: %s" % msg["To"]) print("-> MSG: " + repr(msg.get_payload())) ``` Output: * Output before the `===========` is the constructed message * Output after the `===========` is the parsed message * Note: that after parsing the message some headers end up in the body (`from`, `myheader`). Note that `msg[from]` is empty. ``` ? python3 a.py Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: The contents of is this... To: TO toAddress at oststrom.com X-SPLIT-MSG-TO-BODY From: FROM fromAddress at oststrom.com MyHEader: hi :: hi REAL_MSG_BODY_BEGIN ... REAL_MSG_BODY_END ========================= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: The contents of is this... To: TO toAddress at oststrom.com X-SPLIT-MSG-TO-BODY From: FROM fromAddress at oststrom.com MyHEader: hi :: hi REAL_MSG_BODY_BEGIN ... REAL_MSG_BODY_END -> FROM: None -> TO: TO toAddress at oststrom.com -> MSG: 'X-SPLIT-MSG-TO-BODY\nFrom: FROM fromAddress at oststrom.com\nMyHEader: hi :: hi\n\nREAL_MSG_BODY_BEGIN\n...\nREAL_MSG_BODY_END' ``` ### `CR-LF` injection in header keys. Note: this is unlikely to be exploited, however, there might be scenarios where part of the header key is exposed to user input. A `CR-LF` character in the header key should throw instead. ```python # Import the email modules we'll need from email.mime.text import MIMEText # Open a plain text file for reading. For this example, assume that # the text file contains only ASCII characters. msg = MIMEText("REAL_MSG_BODY_BEGIN\n...\nREAL_MSG_BODY_END") # me == the sender's email address # you == the recipient's email address msg['Subject'] = 'The contents of is this...' msg['To'] = "TO toAddress at oststrom.com" msg['From'] = "FROM fromAddress at oststrom.com" msg['MyHEader'] = "hi :: hi" msg["m\r\nh"] = "yo" print(msg) print(repr(msg)) print("=========================") import email msg = email.message_from_string(str(msg)) msg.add_header("CUSTOM-HEADER: yo\r\n\nX-INJECTED: injected-header\r\naa","data") print(msg) print("-> FROM: %s" % msg.get("From")) print("-> TO: %s" % msg["To"]) print("-> MSG: " + repr(msg.get_payload())) ``` Output: `h: yo` and `X-INJECTED:` are injected ``` ? python3 a.py Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: The contents of is this... To: TO toAddress at oststrom.com From: FROM fromAddress at oststrom.com MyHEader: hi :: hi m h: yo REAL_MSG_BODY_BEGIN ... REAL_MSG_BODY_END ========================= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: The contents of is this... To: TO toAddress at oststrom.com From: FROM fromAddress at oststrom.com MyHEader: hi :: hi CUSTOM-HEADER: yo X-INJECTED: injected-header aa: data m h: yo REAL_MSG_BODY_BEGIN ... REAL_MSG_BODY_END -> FROM: FROM fromAddress at oststrom.com -> TO: TO toAddress at oststrom.com -> MSG: 'm\r\nh: yo\n\nREAL_MSG_BODY_BEGIN\n...\nREAL_MSG_BODY_END' ``` ## Proposed Fix - reject `\n` in header keys - encode `\n` in header values to `\n\s+...` to signal a continuation of the header value. reject `\n+` ## Vendor Response Vendor response: ``` I discussed the vulnerability in private with one of the email module maintainers and he considers that it's not a vulnerability. Would you mind opening a public issue at https://bugs.python.org/ so the discussion can be recorded in public? Victor ``` ### Timeline ``` JUL/02/2020 - contact psrt; provided details, PoC, proposed patch AUG/20/2020 - vendor response: forwarded to maintainer of module SEP/15/2020 - vendor response: not a security issue ``` ## References * [1] https://www.python.org/ * [2] https://www.python.org/downloads/ ---------- components: email messages: 386479 nosy: barry, martin.ortner, r.david.murray priority: normal severity: normal status: open title: email MIME splitting type: security 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 Feb 4 08:05:34 2021 From: report at bugs.python.org (Martin Ortner) Date: Thu, 04 Feb 2021 13:05:34 +0000 Subject: [New-bugs-announce] [issue43124] smtplib multiple CRLF injection Message-ID: <1612443934.09.0.696762333019.issue43124@roundup.psfhosted.org> New submission from Martin Ortner : // reported via PSRT email (see timeline; last contact: Alex/PSRT) // external reference: http://consensys.net/diligence/vulnerabilities/private/z5kxjgfmja4offxbrw1miuxwezggajjfswlz9g2hfuh77we5dy727hqy5x9ii43e/ cve: vendor: python vendorUrl: https://www.python.org/ authors: tintinweb affectedVersions: [at least 3.8.3, <=3.7.8, <=3.6.11, <=3.5.9, <=2.7.18] vulnClass: CWE-93 # Vulnerability Note ## Summary >Python is a programming language that lets you work more quickly and integrate your systems more effectively. Two CR-LF injection points have been discovered in the Python standard library for `SMTP` interaction (client perspective) named `smtplib` that may allow a malicious user with direct access to `smtplib.SMTP(..., local_hostname, ..)` or `smtplib.SMTP(...).mail(..., options)` to inject a CR-LF control sequence to inject arbitrary `SMTP` commands into the protocol stream. The root cause of this is likely to be found in the design of the `putcmd(cmd, args)` method, that fails to validate that `cmd` nor `args` contains any protocol control sequences (i.e. `CR-LF`). It is recommended to reject or encode `\r\n` in `putcmd()` and enforce that potential multi-line commands call `putcmd()` multiple times to avoid that malicious input breaks the expected context of the method and hence cause unexpected behavior. For reference, the `DATA` command (multi-line) would not be affected by this change as it calls `putcmd()` only once and continues with directly interacting with the socket to submit the body. ## Details ### Description The root cause of this (and probably also some earlier reported CR-LF injections) is the method `putcmd()` in `lib/smtplib.py`[3]. The method is called by multiple commands and does not validate that neither `cmd` nor `args` contains any `CRLF` sequences. ```python def putcmd(self, cmd, args=""): """Send a command to the server.""" if args == "": str = '%s%s' % (cmd, CRLF) else: str = '%s %s%s' % (cmd, args, CRLF) self.send(str) ``` However, the issue was initially found in `mail(..., options)` [4] which fails to ensure that none of the provided `options` contains `CRLF` characters. The method only ensures that provides mail addresses are quoted, `optionslist` is untouched: ```python self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender), optionlist)) ``` A similar issue was found with `smtplib.SMTP(...,local_hostname)` (and `helo(name)`, `ehlo(name)`) which may potentially contain `CRLF` sequences and, therefore, can be used to inject `SMTP` commands. Here's a snipped of `helo` [5] ```python def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ self.putcmd("helo", name or self.local_hostname) (code, msg) = self.getreply() self.helo_resp = msg return (code, msg) ``` We highly recommend, fixing this issue once and for all directly in `putcmd()` and enforce that the interface can only send one command at a time, rejecting arguments that contain `CRLF` sequences or properly encoding them to avoid injection. ## Proof of Concept 1. set-up a local tcp listener `? nc -l 10001` 2. run the following PoC and replay the server part as outline in 3. ```python import smtplib server = smtplib.SMTP('localhost', 10001, "hi\nX-INJECTED") # localhostname CRLF injection server.set_debuglevel(1) server.sendmail("hi at me.com", "you at me.com", "wazzuuup\nlinetwo") server.mail("hi at me.com",["X-OPTION\nX-INJECTED-1","X-OPTION2\nX-INJECTED-2"]) # options CRLF injection ``` 3. interact with `smtplib`, check for `X-INJECTED` ``` ? nc -l 10001 nc -l 10001 220 yo ehlo hi X-INJECTED 250-AUTH PLAIN 250 mail FROM: 250 ok rcpt TO: 250 ok data 354 End data with . wazzuuup linetwo . 250 ok mail FROM: X-OPTION X-INJECTED-1 X-OPTION2 X-INJECTED-2 250 ok quit 250 ok ``` ### Proposed Fix * enforce that `putcmd` emits exactly one command at a time and encode `\n -> \\n`. ```diff diff --git a/Lib/smtplib.py b/Lib/smtplib.py index e2dbbbc..9c16e7d 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -365,10 +365,10 @@ class SMTP: def putcmd(self, cmd, args=""): """Send a command to the server.""" if args == "": - str = '%s%s' % (cmd, CRLF) + str = cmd else: - str = '%s %s%s' % (cmd, args, CRLF) - self.send(str) + str = '%s %s' % (cmd, args) + self.send('%s%s' % (str.replace('\n','\\n'), CRLF)) ``` ## Vendor Response Vendor response: gone silent ### Timeline ``` JUL/02/2020 - contact psrt; provided details, PoC, proposed patch JUL/04/2020 - confirmed that vulnerability note was received SEP/10/2020 - requested status update. ``` ## References * [1] https://www.python.org/ * [2] https://www.python.org/downloads/ * [3] https://github.com/python/cpython/blob/1da648aceb2496c672aff82ba37ee071ac6054ac/Lib/smtplib.py#L365-L371 * [4] https://github.com/python/cpython/blob/1da648aceb2496c672aff82ba37ee071ac6054ac/Lib/smtplib.py#L520 * [5] https://github.com/python/cpython/blob/1da648aceb2496c672aff82ba37ee071ac6054ac/Lib/smtplib.py#L428-L445 ---------- components: email messages: 386481 nosy: barry, martin.ortner, r.david.murray priority: normal severity: normal status: open title: smtplib multiple CRLF injection type: security 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 Feb 4 08:23:28 2021 From: report at bugs.python.org (Michael L. Boom) Date: Thu, 04 Feb 2021 13:23:28 +0000 Subject: [New-bugs-announce] [issue43125] Trying To Concatenate Bytes and String in SMTPLIB Message-ID: <1612445008.73.0.955251739992.issue43125@roundup.psfhosted.org> New submission from Michael L. Boom : The space is string, and either mechanism and/or response are bytes. smtplib.py:634 response = encode_base64(initial_response.encode('ascii'), eol='') (code, resp) = self.docmd("AUTH", mechanism + " " + response) import smtplib, ssl port = 587 smtp_server = "---------------" smtpserver = smtplib.SMTP(smtp_server, port) smtpserver.set_debuglevel(2) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login("", "") ----------------------------------------------------- 12:40:37.614737 send: 'ehlo [10.60.69.196]\r\n' 12:40:37.665528 reply: b'250-MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\r\n' 12:40:37.665666 reply: b'250-SIZE 157286400\r\n' 12:40:37.665761 reply: b'250-PIPELINING\r\n' 12:40:37.665788 reply: b'250-DSN\r\n' 12:40:37.665806 reply: b'250-ENHANCEDSTATUSCODES\r\n' 12:40:37.665825 reply: b'250-STARTTLS\r\n' 12:40:37.665842 reply: b'250-8BITMIME\r\n' 12:40:37.665859 reply: b'250-BINARYMIME\r\n' 12:40:37.665876 reply: b'250-CHUNKING\r\n' 12:40:37.665893 reply: b'250 SMTPUTF8\r\n' 12:40:37.665919 reply: retcode (250); Msg: b'MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\nSIZE 157286400\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nSTARTTLS\n8BITMIME\nBINARYMIME\nCHUNKING\nSMTPUTF8' 12:40:37.666440 send: 'STARTTLS\r\n' 12:40:37.716214 reply: b'220 2.0.0 SMTP server ready\r\n' 12:40:37.716265 reply: retcode (220); Msg: b'2.0.0 SMTP server ready' 12:40:37.878320 send: 'ehlo [10.60.69.196]\r\n' 12:40:37.928198 reply: b'250-MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\r\n' 12:40:37.928259 reply: b'250-SIZE 157286400\r\n' 12:40:37.928285 reply: b'250-PIPELINING\r\n' 12:40:37.928304 reply: b'250-DSN\r\n' 12:40:37.928323 reply: b'250-ENHANCEDSTATUSCODES\r\n' 12:40:37.928437 reply: b'250-AUTH LOGIN XOAUTH2\r\n' 12:40:37.928461 reply: b'250-8BITMIME\r\n' 12:40:37.928494 reply: b'250-BINARYMIME\r\n' 12:40:37.928511 reply: b'250-CHUNKING\r\n' 12:40:37.928528 reply: b'250 SMTPUTF8\r\n' 12:40:37.928552 reply: retcode (250); Msg: b'MWHPR20CA0007.outlook.office365.com Hello [65.54.12.68]\nSIZE 157286400\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nAUTH LOGIN XOAUTH2\n8BITMIME\nBINARYMIME\nCHUNKING\nSMTPUTF8' Traceback (most recent call last): File "mail9.py", line 18, in smtpserver.login("", "") File "/aae/msio_install_release1.9/scoring_engine.20201201.3.8.3/lib/python3.8/smtplib.py", line 723, in login (code, resp) = self.auth( File "/aae/msio_install_release1.9/scoring_engine.20201201.3.8.3/lib/python3.8/smtplib.py", line 635, in auth (code, resp) = self.docmd("AUTH", mechanism + " " + response) TypeError: can only concatenate str (not "bytes") to str ---------- components: Interpreter Core messages: 386482 nosy: boom0192 priority: normal severity: normal status: open title: Trying To Concatenate Bytes and String in SMTPLIB type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 09:28:07 2021 From: report at bugs.python.org (Martin Larralde) Date: Thu, 04 Feb 2021 14:28:07 +0000 Subject: [New-bugs-announce] [issue43126] IOBase.readlines(0) behaviour is inconsistent with documentation Message-ID: <1612448887.77.0.51336599468.issue43126@roundup.psfhosted.org> New submission from Martin Larralde : The documentation for `IOBase.readlines` states that the `hint` optional argument should be used like so (https://docs.python.org/3/library/io.html#io.IOBase.readlines): > Read and return a list of lines from the stream. hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint. So in the case where `hint` is null, I would expect `readlines` to return an empty list. However, this is neither the case for `io.BytesIO` nor for `io.FileIO`: ``` import io io.BytesIO(b"abc\ndef\nghi\n").readlines(0) # this evaluates to [b"abc\n", b"def\n", b"ghi\n"] ``` If this is the intended behaviour, the documentation should be updated, otherwise the code from the `io` module should be fixed. ---------- assignee: docs at python components: Documentation messages: 386484 nosy: althonos2, docs at python priority: normal severity: normal status: open title: IOBase.readlines(0) behaviour is inconsistent with documentation type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 11:53:25 2021 From: report at bugs.python.org (Adrian Lloyd) Date: Thu, 04 Feb 2021 16:53:25 +0000 Subject: [New-bugs-announce] [issue43127] Unable to install Python 3.9.1 - Windows 10 Message-ID: <1612457605.05.0.029864468293.issue43127@roundup.psfhosted.org> New submission from Adrian Lloyd : I get the following error when I try to install Python 3.9.1 on windows 10 0x80070659 The installation is forbidden by system policy. The log gives more information: [13A0:0FC0][2021-02-04T16:41:04]e000: Error 0x80070659: Failed to install MSI package. [13A0:0FC0][2021-02-04T16:41:04]e000: Error 0x80070659: Failed to configure per-user MSI package. [13A0:0FC0][2021-02-04T16:41:04]i319: Applied execute package: core_JustForMe, result: 0x80070659, restart: None [13A0:0FC0][2021-02-04T16:41:04]e000: Error 0x80070659: Failed to execute MSI package. I have looked on earlier posts and stack overflow and all suggest a registry fix to set DisableMSI = 0 in the registry, but according to windows documentation this doesn't apply to windows 10. Also the Installer folder which would contain this parameter doesn't exist. Can you help? ---------- messages: 386485 nosy: adrian.e.d.lloyd priority: normal severity: normal status: open title: Unable to install Python 3.9.1 - Windows 10 versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 13:02:38 2021 From: report at bugs.python.org (Alex Osterman) Date: Thu, 04 Feb 2021 18:02:38 +0000 Subject: [New-bugs-announce] [issue43128] make test fails Lib/test/test_httpservers.py on 3.9.1 Message-ID: <1612461758.14.0.954062785063.issue43128@roundup.psfhosted.org> New submission from Alex Osterman : While compiling 3.9.1 on CentOS 8, test_httpservers.py throws multiple errors in the vein of "OSError: [Errno 39] Directory not empty: '/tmp/tmp70ip355o'" from line 707, in teardown. Examining the directories I see that they all contain only a gmon.out. Adding this code to teardown() before "os.rmdir(self.parent_dir)" seems to resolve the issue and should not introduce any issues on other platforms: if os.path.isfile(pathlib.Path(self.parent_dir).joinpath('gmon.out')): os.remove(pathlib.Path(self.parent_dir).joinpath('gmon.out')) ---------- components: Tests files: Python3 Makefile.txt messages: 386489 nosy: ostermana priority: normal severity: normal status: open title: make test fails Lib/test/test_httpservers.py on 3.9.1 type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49790/Python3 Makefile.txt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 16:25:49 2021 From: report at bugs.python.org (Matthieu Dartiailh) Date: Thu, 04 Feb 2021 21:25:49 +0000 Subject: [New-bugs-announce] [issue43129] Number of object on stack required by opcode Message-ID: <1612473949.46.0.297177775699.issue43129@roundup.psfhosted.org> New submission from Matthieu Dartiailh : When constructing bytecode object manually as can be done using the bytecode library (https://github.com/MatthieuDartiailh/bytecode which was first developed by V Stinner), one can use dis.stack_effect to compute the required stack size, thus avoiding stack overflows. However it can be interesting for those manually built bytecode object to also check that no underflow can occur. This computation is straightforward once one knows the number of element on the stack a specific opcode expects. This works has been done manually in the bytecode project, but it may interesting to provide a way in the dis module to access this information with an interface similar to dis.stack_effect. If there is an interest in such a feature I would be happy to contribute it. I would however like some opinion on how to do that in an optimal manner. I assume it would require to add the implementation in https://github.com/python/cpython/blob/master/Python/compile.c and expose it in a similar manner to stack_effect. ---------- components: Library (Lib) messages: 386494 nosy: mdartiailh priority: normal severity: normal status: open title: Number of object on stack required by opcode type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 16:52:27 2021 From: report at bugs.python.org (Tony Ladd) Date: Thu, 04 Feb 2021 21:52:27 +0000 Subject: [New-bugs-announce] [issue43130] Should this construct throw an exception? Message-ID: <1612475547.01.0.970042498842.issue43130@roundup.psfhosted.org> New submission from Tony Ladd : The expression "1 and 2" evaluates to 2. Actually for most combinations of data type it returns the second object. Of course its a senseless construction (a beginning student made it) but why no exception? ---------- components: Interpreter Core messages: 386496 nosy: tladd priority: normal severity: normal status: open title: Should this construct throw an exception? type: behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 17:45:15 2021 From: report at bugs.python.org (Paul Swirhun) Date: Thu, 04 Feb 2021 22:45:15 +0000 Subject: [New-bugs-announce] [issue43131] MMAP duplicate reads and writes on ARM64 platform Message-ID: <1612478715.17.0.31458005009.issue43131@roundup.psfhosted.org> New submission from Paul Swirhun : mmap (example, as used in python-periphery) duplicates writes, compared to devmem and a c-periphery on an ARM64 platform (Zynq/Petalinux/Yocto). There are various other reports of duplicated writes using mmap suggesting it is a bug. Example: fd = os.open("/dev/mem", os.O_RDWR | os.O_SYNC) mapping = mmap.mmap(fd, 4096, flags=mmap.MAP_SHARED, prot=(mmap.PROT_READ | mmap.PROT_WRITE), offset=0x80000000) mapping.write(bytearray([0x0,]* 4)) # results in 2 writes, should be 1 mapping.write(bytearray([0x0,]* 8)) # results in 4 writes, should be 1-2 depending on bus width (32b vs 64b) # OR: mapping[0:4] = struct.pack("=L", 0x0) # results in 2 writes, should be 1 ---------- components: Library (Lib) messages: 386501 nosy: psswirhun priority: normal severity: normal status: open title: MMAP duplicate reads and writes on ARM64 platform versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 18:48:01 2021 From: report at bugs.python.org (Zackery Spytz) Date: Thu, 04 Feb 2021 23:48:01 +0000 Subject: [New-bugs-announce] [issue43132] Incorrect handling of PyObject_RichCompareBool() in the _zoneinfo module Message-ID: <1612482481.94.0.955863254817.issue43132@roundup.psfhosted.org> New submission from Zackery Spytz : PyObject_RichCompareBool() returns -1 on error, but this case is not handled by the find_in_strong_cache() function. ---------- components: Extension Modules messages: 386503 nosy: ZackerySpytz priority: normal severity: normal status: open title: Incorrect handling of PyObject_RichCompareBool() in the _zoneinfo module versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 4 23:36:25 2021 From: report at bugs.python.org (Nick Coghlan) Date: Fri, 05 Feb 2021 04:36:25 +0000 Subject: [New-bugs-announce] [issue43133] Accept file mode "rw" to open-or-create a file and seek to the start Message-ID: <1612499785.75.0.541398375839.issue43133@roundup.psfhosted.org> New submission from Nick Coghlan : After yet again trying to use "rw" to open a file in read/write mode, having it fail, and then having to look up the docs to remind myself that the correct spelling is "r+", I'm finally filing this to suggest we make the obvious "rw" spelling actually work. Rather than making it an alias for any of the existing modes, I'd suggest that it combine the features of "r+" and "a+": * like "r+" it would start the file pointer at the beginning of the file * like "a+" it would create the file if it didn't exist, while leaving existing files alone ---------- messages: 386510 nosy: ncoghlan priority: low severity: normal status: open title: Accept file mode "rw" to open-or-create a file and seek to the start type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 5 05:20:50 2021 From: report at bugs.python.org (Masoud Azizi) Date: Fri, 05 Feb 2021 10:20:50 +0000 Subject: [New-bugs-announce] [issue43134] (list have item) instate (item in list) Message-ID: <1612520450.63.0.525292396869.issue43134@roundup.psfhosted.org> New submission from Masoud Azizi : Please append a code to reverse check?like that? print([input() for i in'_'*10] have input()) Instade of: print(input() in [input() for i in'_'*10] ) i want to check that: is last input in the inputs or not! ---------- messages: 386522 nosy: mablue priority: normal severity: normal status: open title: (list have item) instate (item in list) 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 Fri Feb 5 05:43:07 2021 From: report at bugs.python.org (Marusoftware) Date: Fri, 05 Feb 2021 10:43:07 +0000 Subject: [New-bugs-announce] [issue43135] Can't input Japanese. Message-ID: <1612521787.32.0.923503717653.issue43135@roundup.psfhosted.org> New submission from Marusoftware : Can't input Japanese text to idle on MacOS. I think this caused by "https://core.tcl-lang.org/tk/tktview?name=39de9677aa". So, builtin tk&tcl upgrade is required. ---------- assignee: terry.reedy components: IDLE, Tkinter messages: 386523 nosy: Marusoftware, terry.reedy priority: normal severity: normal status: open title: Can't input Japanese. type: behavior versions: Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 5 07:03:06 2021 From: report at bugs.python.org (Louis Sautier) Date: Fri, 05 Feb 2021 12:03:06 +0000 Subject: [New-bugs-announce] [issue43136] multiprocessing.Queue.get(block=False) can raise queue.Empty on non-empty queue Message-ID: <1612526586.24.0.699070484965.issue43136@roundup.psfhosted.org> New submission from Louis Sautier : Hello, I have noticed that when multiple processes try to simultaneously get items from a multiprocessing queue with block=False, it will raise queue.Empty even though there are still items in it. Adding a multiprocessing lock around calls to Queue.get fixes the problem. Please consider the attached reproducer script and its output: $ ./queue_test.py using processes 2021-02-05T12:48:21.742728 worker 0 got 0, queue size was 100 2021-02-05T12:48:21.743702 worker 1 got 1, queue size was 99 2021-02-05T12:48:21.744059 worker 2 got 2, queue size was 98 2021-02-05T12:48:21.745352 worker 3 got 3, queue size was 97 2021-02-05T12:48:22.743905 worker 1 queue is EMPTY, size was 96 2021-02-05T12:48:22.744064 worker 0 got 4, queue size was 96 2021-02-05T12:48:22.746525 worker 3 queue is EMPTY, size was 95 2021-02-05T12:48:22.749573 worker 2 got 5, queue size was 95 2021-02-05T12:48:23.744474 worker 0 got 6, queue size was 94 2021-02-05T12:48:23.750728 worker 2 got 7, queue size was 93 2021-02-05T12:48:24.745852 worker 0 got 8, queue size was 92 2021-02-05T12:48:24.751827 worker 2 got 9, queue size was 91 [?] I have been able to reproduce this problem with Python 2.7 and 3.5 through 3.9 (3.10 untested). When using threads and queue.Queue instead of their multiprocessing counterparts, the problem is not present ("./queue_test.py thread" ? no spurious exceptions until the queue is actually empty). ---------- components: Library (Lib) files: queue_test.py messages: 386525 nosy: sbraz priority: normal severity: normal status: open title: multiprocessing.Queue.get(block=False) can raise queue.Empty on non-empty queue type: behavior versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49791/queue_test.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 5 07:26:34 2021 From: report at bugs.python.org (Matthias Klose) Date: Fri, 05 Feb 2021 12:26:34 +0000 Subject: [New-bugs-announce] [issue43137] webbrowser to support "gio open " Message-ID: <1612527994.14.0.364284995735.issue43137@roundup.psfhosted.org> New submission from Matthias Klose : [forwarded from https://bugs.debian.org/969776] """ rust-webbrowser tries to open URLs via "gvfs-open $URL" and "gnome-open $URL". Both are obsolete; the replacement is "gio open $URL", using the gio(1) tool from the libglib2.0-bin package. The gvfs-open tool was superseded by gio(1) in 2015, and removed from upstream GNOME in 2018. The version in Debian is currently a Debian-specific patch, which we would like to remove before Debian 11. The gnome-open tool was superseded by gvfs-open in 2008, ceased to be part of GNOME releases after about 2011, most recently appeared in a Debian stable release as part of Debian 9, and was finally removed from Debian in 2019. """ The current list of browser could need some cleanup, e.g.: - remove "The Netscape and old Mozilla browsers" - remove grail? - remove gvfs-open - gnome-open? - can't find galeon anymore, but epiphany ---------- components: Library (Lib) messages: 386526 nosy: doko priority: normal severity: normal status: open title: webbrowser to support "gio open " versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 5 12:33:30 2021 From: report at bugs.python.org (Dirk Herrmann) Date: Fri, 05 Feb 2021 17:33:30 +0000 Subject: [New-bugs-announce] [issue43138] [doc] Inconsistent / confusing documentation regarding importing submodules Message-ID: <1612546411.0.0.965001930731.issue43138@roundup.psfhosted.org> New submission from Dirk Herrmann : In the language reference, section "7.11 The import statement" is is explained in the example section: import foo.bar.baz # foo.bar.baz imported, foo bound locally When looking at "5.3. Searching", it is stated that regarding foo.bar.baz: In this case, Python first tries to import foo, then foo.bar, and finally foo.bar.baz. I find this confusing. Assuming that 5.3 is correct, the examples in 7.11 could be improved, like, for the sample line mentioned above: import foo.bar.baz # foo, foo.bar and foo.bar.baz imported, foo bound locally ---------- assignee: docs at python components: Documentation messages: 386532 nosy: Dirk Herrmann, docs at python priority: normal severity: normal status: open title: [doc] Inconsistent / confusing documentation regarding importing submodules type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 5 14:08:12 2021 From: report at bugs.python.org (Felix Yan) Date: Fri, 05 Feb 2021 19:08:12 +0000 Subject: [New-bugs-announce] [issue43139] test_ttk test_compound and test_tk test_type fails with Tk 8.6.11.1 Message-ID: <1612552092.14.0.798552929042.issue43139@roundup.psfhosted.org> New submission from Felix Yan : ====================================================================== FAIL: test_compound (tkinter.test.test_ttk.test_widgets.ButtonTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/build/python/src/Python-3.9.1/Lib/tkinter/test/test_ttk/test_widgets.py", line 173, in test_compound self.checkEnumParam(widget, 'compound', File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 152, in checkEnumParam self.checkInvalidParam(widget, name, '', File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 75, in checkInvalidParam widget[name] = value AssertionError: TclError not raised ===================================================================== FAIL: test_type (tkinter.test.test_tkinter.test_widgets.MenuTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/build/python/src/Python-3.9.1/Lib/tkinter/test/test_tkinter/test_widgets.py", line 1245, in test_type self.checkEnumParam(widget, 'type', File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 152, in checkEnumParam self.checkInvalidParam(widget, name, '', File "/build/python/src/Python-3.9.1/Lib/tkinter/test/widget_tests.py", line 75, in checkInvalidParam widget[name] = value AssertionError: TclError not raised ---------------------------------------------------------------------- ---------- components: Tests messages: 386538 nosy: felixonmars priority: normal severity: normal status: open title: test_ttk test_compound and test_tk test_type fails with Tk 8.6.11.1 type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 00:16:14 2021 From: report at bugs.python.org (Cake Xu) Date: Sat, 06 Feb 2021 05:16:14 +0000 Subject: [New-bugs-announce] [issue43140] build-in open() doesn't use whatever locale.getpreferredencoding() returns as default encoding. Message-ID: <1612588574.22.0.21834147948.issue43140@roundup.psfhosted.org> New submission from Cake Xu : In the document about build-in function open() https://docs.python.org/3/library/functions.html#open, it says that "encoding is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent (whatever locale.getpreferredencoding() returns), but any text encoding supported by Python can be used. See the codecs module for the list of supported encodings. " But as I tried, I found that after I set locale using locale.setlocale(), the default encoding used by open() was changed and thus sometimes led to a UnicodeDecodeError. So I think that the default encoding used by open() is the second element of whatever locale returned by locale.getlocale(). ---------- assignee: docs at python components: Documentation messages: 386544 nosy: docs at python, smallbigcake priority: normal severity: normal status: open title: build-in open() doesn't use whatever locale.getpreferredencoding() returns as default encoding. versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 00:46:54 2021 From: report at bugs.python.org (Evgeny Naumov) Date: Sat, 06 Feb 2021 05:46:54 +0000 Subject: [New-bugs-announce] [issue43141] `asdict` fails with frozen dataclass keys; tries to use raw dict form as key Message-ID: <1612590414.63.0.106701107905.issue43141@roundup.psfhosted.org> New submission from Evgeny Naumov : A simple example is documented here: https://github.com/samuelcolvin/pydantic/issues/2233 but it doesn't look like it was actually filed as a bug against CPython... Copy paste of the minimal reproducing example: from dataclasses import asdict, dataclass @dataclass(eq=True, frozen=True) class A: a: str @dataclass(eq=True, frozen=True) class B: b: dict[A, str] asdict(B({A("x"):"y"})) The offending code are these lines in dataclasses.py: elif isinstance(obj, dict): return type(obj)((_asdict_inner(k, dict_factory), _asdict_inner(v, dict_factory)) The _asdict_inner(k, dict_factory) [correctly] turns dataclasses into dicts... which are not hashable. I assume there is a good reason the _asdict_inner function is called on the key, but its failure in this case looks like a (rather annoying!) error. ---------- components: Library (Lib) messages: 386545 nosy: enaumov priority: normal severity: normal status: open title: `asdict` fails with frozen dataclass keys; tries to use raw dict form as key type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 00:50:31 2021 From: report at bugs.python.org (Sanchit) Date: Sat, 06 Feb 2021 05:50:31 +0000 Subject: [New-bugs-announce] [issue43142] Do not add duplicate FDs to list in duplicate_for_child() Message-ID: <1612590631.17.0.238793980684.issue43142@roundup.psfhosted.org> New submission from Sanchit : While spawning, if a process having code built on top of Python's multiprocessing module calls multiprocessing.reduction.DupFd() (in /Lib/multiprocessing/reduction.py) multiple times on the same File descriptor by mistake, then it ends up invoking duplicate_for_child(fd)) of the class Popen, which, in turn, adds a duplicate FD to a list. This list is then used in spawnv_passfds() in /Lib/multiprocessing/util.py, which uses that list as an argument in a call of _posixsubprocess.fork_exec(). In Modules/_posixsubprocess.c, checks exist to ensure that all the FDs in the list are unique, positive, and in a sorted order. If duplicate entries are found, a ValueError: bad value(s) in fds_to_keep exception is raised, and the execution is terminated. Even if this exception were somehow handled, a developer can't change the aforementioned FD list in Python without breaking modularity. It's better to let developers get away with calling multiprocessing.reduction.DupFd() (in /Lib/multiprocessing/reduction.py) on by not accepting duplicate entries in the first place, so that spawning a process can be successful. ---------- components: Library (Lib) messages: 386546 nosy: sanchit priority: normal severity: normal status: open title: Do not add duplicate FDs to list in duplicate_for_child() 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 Sat Feb 6 03:13:07 2021 From: report at bugs.python.org (Paul Sokolovsky) Date: Sat, 06 Feb 2021 08:13:07 +0000 Subject: [New-bugs-announce] [issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator Message-ID: <1612599187.49.0.372598222393.issue43143@roundup.psfhosted.org> New submission from Paul Sokolovsky : Currently (CPython 3.10.0a4) having a tuple on left-hand side of assignment expression/operator (aka walrus operator) is not allowed: >>> ((a, b) := (1, 2)) File "", line 1 ((a, b) := (1, 2)) ^ SyntaxError: cannot use assignment expressions with tuple As far as can tell, there's no explicit consideration of this case in the PEP572. There closest it has is under the https://www.python.org/dev/peps/pep-0572/#differences-between-assignment-expressions-and-assignment-statements section, "Iterable packing and unpacking (both regular or extended forms) are not supported". But note that the usecase presented above is better seen as "parallel assignment", not as "iterable unpacking". Next issue: PEP572 puts heavy emphasis on the "named expression" usecase. I would like to emphasize, that "naming an expression" seems like *just one of usecases* for assignment operator. First and foremost assignment operator is, well, assignment. With that in mind, ((a, b) := (1, 2)) is compatible with "naming expressions" idea, it "gives names" to multiple expressions at once. There's a temptation to suggest that the above could be rewritten as: ((a := 1), (b := 2)) , and for the "naming" usecase, that would be true. But as noted above, "naming" is just *one* of the usecases. Following can't be "sequentialized" like that: ((b, a) := (a, b)) And for as long as someone considers the following acceptable: func(a := val) There's little point to prohibit the following: min((b, a) := (a, b)) And that's the main argument - consistency between assignment statement and assignment operator. For as long as this is allowed: a, b = b, c it makes sense to allow: ((a, b) := (b,c)) (Extra parens account for different in grammar and precedence for the operator). This issue is posted to capture discussion initially posted to python-ideas/python-dev: https://mail.python.org/archives/list/python-ideas at python.org/thread/6IFDG7PAFPHVPGULANOQDAHP2X743HCE/ https://mail.python.org/archives/list/python-ideas at python.org/thread/X3LNCCO6PHTLAQXHEAP6T3FFW5ZW5GR5/ https://mail.python.org/archives/list/python-dev at python.org/thread/6IFDG7PAFPHVPGULANOQDAHP2X743HCE/ , to serve as a reference to whoever may be searching the bugtracker for this case. ---------- components: Interpreter Core messages: 386551 nosy: pfalcon priority: normal severity: normal status: open title: Allow multiple assignment (i.e. tuple on LHS) in walrus operator _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 05:48:06 2021 From: report at bugs.python.org (=?utf-8?q?Arkadiusz_Mi=C5=9Bkiewicz?=) Date: Sat, 06 Feb 2021 10:48:06 +0000 Subject: [New-bugs-announce] [issue43144] test_unicodedata: test_normalization uses network but doesn't depend on network resource Message-ID: <1612608486.69.0.149718284588.issue43144@roundup.psfhosted.org> New submission from Arkadiusz Mi?kiewicz : Hello. test_normalization uses network but doesn't depend on network resource, so it tries to run even when network is disabled when running tests (-u-network) FAIL: test_normalization (test.test_unicodedata.NormalizationTest) socket.gaierror: [Errno -3] Temporary failure in name resolution urllib.error.URLError: AssertionError: Could not retrieve http://www.pythontest.net/unicode/13.0.0/NormalizationTest.txt ---------- components: Tests messages: 386554 nosy: arekm priority: normal severity: normal status: open title: test_unicodedata: test_normalization uses network but doesn't depend on network resource type: compile error versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 08:02:37 2021 From: report at bugs.python.org (Boris Staletic) Date: Sat, 06 Feb 2021 13:02:37 +0000 Subject: [New-bugs-announce] [issue43145] Leak of locks in a subprocess Message-ID: <1612616557.31.0.756365409942.issue43145@roundup.psfhosted.org> New submission from Boris Staletic : The following C code leaks 7 locks allocated with PyThread_allocate_lock: #include int main() { Py_Initialize(); PyObject* multiprocessing = PyImport_ImportModule("multiprocessing"); PyObject* Process = PyObject_GetAttrString(multiprocessing, "Process"); PyObject* args = PyTuple_New(0); PyObject* kw = PyDict_New(); PyDict_SetItemString(kw, "target", Process); PyObject* p = PyObject_Call(Process, args, kw); PyObject* start = PyObject_GetAttrString(p, "start"); PyObject* join = PyObject_GetAttrString(p, "join"); PyObject_CallNoArgs(start); PyObject_CallNoArgs(join); Py_DECREF(join); Py_DECREF(start); Py_DECREF(p); Py_DECREF(kw); Py_DECREF(args); Py_DECREF(Process); Py_DECREF(multiprocessing); Py_Finalize(); } The following locks are leaked: 1. https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L78 2. https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L84 3. https://github.com/python/cpython/blob/196d4deaf4810a0bba75ba537dd40f2d71a5a634/Python/pystate.c#L90 4. https://github.com/python/cpython/blob/master/Python/ceval.c#L810 5. https://github.com/python/cpython/blob/master/Python/import.c#L126 6. and 7. https://github.com/python/cpython/blob/master/Modules/_threadmodule.c#L597 In the attachment is valgrind's output. ---------- components: C API files: log messages: 386558 nosy: bstaletic priority: normal severity: normal status: open title: Leak of locks in a subprocess type: resource usage versions: Python 3.10, Python 3.9 Added file: https://bugs.python.org/file49793/log _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 10:54:16 2021 From: report at bugs.python.org (Florian Bruhin) Date: Sat, 06 Feb 2021 15:54:16 +0000 Subject: [New-bugs-announce] [issue43146] 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py Message-ID: <1612626856.83.0.902540623753.issue43146@roundup.psfhosted.org> New submission from Florian Bruhin : After upgrading to 3.10a5, calling logging.exception("test") results in: --- Logging error --- Traceback (most recent call last): File "/usr/lib/python3.10/logging/__init__.py", line 1094, in emit msg = self.format(record) File "/usr/lib/python3.10/logging/__init__.py", line 938, in format return fmt.format(record) File "/usr/lib/python3.10/logging/__init__.py", line 682, in format record.exc_text = self.formatException(record.exc_info) File "/usr/lib/python3.10/logging/__init__.py", line 632, in formatException traceback.print_exception(ei[0], ei[1], tb, None, sio) File "/usr/lib/python3.10/traceback.py", line 113, in print_exception te = TracebackException(type(value), value, tb, limit=limit, compact=True) File "/usr/lib/python3.10/traceback.py", line 531, in __init__ need_context = cause is None and not e.__suppress_context__ AttributeError: 'NoneType' object has no attribute '__suppress_context__' That method is documented as "This function should only be called from an exception handler.", but the same also happens when e.g. calling traceback.print_exc() (without a current exception) or traceback.print_exception(None, None, None). Both worked fine before 3.10 Alpha 5, the code seems to do None-checks in other places, and typeshed also marks those arguments as Optional. This seems to have been introduced in https://github.com/python/cpython/pull/24179 for bpo-42877. ---------- components: Library (Lib) messages: 386562 nosy: The Compiler, iritkatriel, vinay.sajip priority: normal severity: normal status: open title: 3.10a5 regression: AttributeError: 'NoneType' object has no attribute '__suppress_context__' in traceback.py type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 14:35:44 2021 From: report at bugs.python.org (Raymond Hettinger) Date: Sat, 06 Feb 2021 19:35:44 +0000 Subject: [New-bugs-announce] [issue43147] Remove mention of "subcontrary mean" from the docs Message-ID: <1612640144.35.0.427315747662.issue43147@roundup.psfhosted.org> New submission from Raymond Hettinger : Let's improve the readability of the docs by removing the archaic term "subcontrary mean". That is a bit saying that capacitors are sometimes called condensers. I checked with a stats professor and he had never heard of the term. Likewise, there was no mention in any of my stats books or math references (such as the CRC). The docs for scipy.stats.hmean() do not use the term. Googling for "subcontrary mean" only turns up a cross-reference in Wolfram Alpha". ---------- assignee: steven.daprano components: Documentation messages: 386567 nosy: rhettinger, steven.daprano priority: normal severity: normal status: open title: Remove mention of "subcontrary mean" from the docs versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 15:55:56 2021 From: report at bugs.python.org (Julian Berman) Date: Sat, 06 Feb 2021 20:55:56 +0000 Subject: [New-bugs-announce] [issue43148] Call sys.unraisablehook in the REPL when sys.excepthook is broken Message-ID: <1612644956.56.0.525565389562.issue43148@roundup.psfhosted.org> New submission from Julian Berman : At the REPL, when sys.excepthook is broken (below by setting it to a non-callable), one sees: ``` ? python3.9 julian at Airm Python 3.9.1 (default, Feb 2 2021, 22:54:59) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys; sys.excepthook = object(); asdf Error in sys.excepthook: TypeError: 'object' object is not callable Original exception was: Traceback (most recent call last): File "", line 1, in NameError: name 'asdf' is not defined ``` The implementation (https://github.com/python/cpython/blob/5f18c223391eef8c7d01241b51a7b2429609dd84/Python/pythonrun.c#L805-L817) seems to do so by reimplementing something like 3.8+'s sys.unraisablehook (well, technically it predates sys.unraisablehook by quite a while). Seems like now that it exists, that code should now call sys.unraisablehook. ---------- messages: 386569 nosy: Julian, vstinner priority: normal severity: normal status: open title: Call sys.unraisablehook in the REPL when sys.excepthook is broken versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 17:54:08 2021 From: report at bugs.python.org (Andre Roberge) Date: Sat, 06 Feb 2021 22:54:08 +0000 Subject: [New-bugs-announce] [issue43149] Misleading error message for except with missing parens (3.10.a5) Message-ID: <1612652048.28.0.775062089825.issue43149@roundup.psfhosted.org> New submission from Andre Roberge : The following: try: pass except ValueError, NameError as err: pass results in: except ValueError, NameError as err: ^ SyntaxError: expected ':' However, what is missing here are some parentheses surrounding the exception types. ---------- messages: 386570 nosy: aroberge priority: normal severity: normal status: open title: Misleading error message for except with missing parens (3.10.a5) type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 21:16:14 2021 From: report at bugs.python.org (Kumar Makala) Date: Sun, 07 Feb 2021 02:16:14 +0000 Subject: [New-bugs-announce] [issue43150] Last empty string not removed in a list Message-ID: <1612664174.69.0.83130833391.issue43150@roundup.psfhosted.org> New submission from Kumar Makala : # Last empty string not removed from the list str_list = ["Emma", "Jon", "", "Kelly","Eric", "", "","KXN",""] for item in str_list: if len(item) == 0: str_list.remove(item) print(len(str_list[-1])) #Output ['Emma', 'Jon', 'Kelly', 'Eric', 'KXN', ''] ---------- messages: 386571 nosy: kumarmakala priority: normal severity: normal status: open title: Last empty string not removed in a list type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 6 23:40:13 2021 From: report at bugs.python.org (Gary Litvin) Date: Sun, 07 Feb 2021 04:40:13 +0000 Subject: [New-bugs-announce] [issue43151] is with literals in 3.8 release Message-ID: <1612672813.96.0.169918993587.issue43151@roundup.psfhosted.org> New submission from Gary Litvin : >>> x = 'a' >>> x is 'a' True >>> if x is 'a': print(x) SyntaxError: "is" with a literal. Did you mean "=="? How come? ---------- messages: 386575 nosy: garylitvin priority: normal severity: normal status: open title: is with literals in 3.8 release versions: Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 02:17:02 2021 From: report at bugs.python.org (Dong-hee Na) Date: Sun, 07 Feb 2021 07:17:02 +0000 Subject: [New-bugs-announce] [issue43152] warning: unused variable 'code' Message-ID: <1612682222.13.0.322888481152.issue43152@roundup.psfhosted.org> New submission from Dong-hee Na : Python/ceval.c:4747:19: warning: unused variable 'code' [-Wunused-variable] PyCodeObject *code = (PyCodeObject *)_co; Very nit compiler warning but should be fixed ;) ---------- components: Interpreter Core messages: 386583 nosy: Mark.Shannon, corona10 priority: normal severity: normal status: open title: warning: unused variable 'code' versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 04:52:44 2021 From: report at bugs.python.org (Oleg Navolotsky) Date: Sun, 07 Feb 2021 09:52:44 +0000 Subject: [New-bugs-announce] [issue43153] tempfile seems to treat a file as a directory when processing an exception in the onerror() Message-ID: <1612691564.38.0.627288937354.issue43153@roundup.psfhosted.org> New submission from Oleg Navolotsky : >>> import sys, tempfile, os >>> sys.version '3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]' >>> folder = tempfile.TemporaryDirectory() >>> file = open(os.path.join(folder.name, "example.txt"), 'wb') >>> folder.cleanup() Traceback (most recent call last): File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 616, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] ??????? ?? ????? ???????? ?????? ? ?????, ??? ??? ???? ???? ????? ?????? ?????????: 'C:\\Users\\user0\\AppData\\Local\\Temp\\tmpin8xeb9b\\example.txt' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\tempfile.py", line 801, in onerror _os.unlink(path) PermissionError: [WinError 32] ??????? ?? ????? ???????? ?????? ? ?????, ??? ??? ???? ???? ????? ?????? ?????????: 'C:\\Users\\user0\\AppData\\Local\\Temp\\tmpin8xeb9b\\example.txt' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\tempfile.py", line 830, in cleanup self._rmtree(self.name) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\tempfile.py", line 812, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 740, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 618, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\tempfile.py", line 804, in onerror cls._rmtree(path) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\tempfile.py", line 812, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 740, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 599, in _rmtree_unsafe onerror(os.scandir, path, sys.exc_info()) File "C:\Users\user0\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 596, in _rmtree_unsafe with os.scandir(path) as scandir_it: NotADirectoryError: [WinError 267] ??????? ?????? ??? ?????: 'C:\\Users\\user0\\AppData\\Local\\Temp\\tmpin8xeb9b\\example.txt' ---------- components: Library (Lib) messages: 386587 nosy: mehwhatever0 priority: normal severity: normal status: open title: tempfile seems to treat a file as a directory when processing an exception in the onerror() type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 11:26:30 2021 From: report at bugs.python.org (Carl Friedrich Bolz-Tereick) Date: Sun, 07 Feb 2021 16:26:30 +0000 Subject: [New-bugs-announce] [issue43154] code.InteractiveConsole can crash if sys.excepthook is broken Message-ID: <1612715190.56.0.748623074825.issue43154@roundup.psfhosted.org> New submission from Carl Friedrich Bolz-Tereick : When using code.InteractiveConsole to implement a Python shell (like PyPy is doing), having a broken sys.excepthook set can crash the console (see attached terminal log). Instead, it should catch errors and report then ignore them (using sys.unraisablehook I would think, but right now it's not that simple to call unraisablehook from python code). Related to https://bugs.python.org/issue43148 ---------- files: crash.log messages: 386593 nosy: Carl.Friedrich.Bolz priority: normal severity: normal status: open title: code.InteractiveConsole can crash if sys.excepthook is broken Added file: https://bugs.python.org/file49797/crash.log _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 13:05:58 2021 From: report at bugs.python.org (Barry Alan Scott) Date: Sun, 07 Feb 2021 18:05:58 +0000 Subject: [New-bugs-announce] [issue43155] PyCMethod_New not defined in python3.lib Message-ID: <1612721158.76.0.287250699598.issue43155@roundup.psfhosted.org> New submission from Barry Alan Scott : When using the limited API PyCMethod_New is not defined in python3.lib. This leads to a link error. This error is in 3.9 and 3.10a5 Discovered when I improved the PyCXX test suite. Example output: Link obj\simple.pyd cl /nologo /W4 /LD /Zi /MT /EHsc /Zi /MT /EHsc -I. -ISrc -IC:\Python310.win64\include -D_CRT_NONSTDC_NO_DEPRECATE -U_DEBUG -DNDEBUG -DPy_LIMITED_API=0x3090000 /Feobj\simple.pyd /Fdobj\simple.pdf obj\simple.obj obj\cxxsupport.obj obj\cxx_extensions.obj obj\cxx_exceptions.obj obj\cxxextensions.obj obj\IndirectPythonInterface.obj C:\Python310.win64\libs\python3.lib Creating library obj\simple.lib and object obj\simple.exp simple.obj : error LNK2019: unresolved external symbol __imp_PyCMethod_New referenced in function "protected: virtual class Py::Object __cdecl Py::PythonExtension::getattr_methods(char const *)" (?getattr_methods@?$PythonExtension at Vold_style_class@@@Py@@MEAA?AVObject at 2@PEBD at Z) obj\simple.pyd : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.EXE"' : return code '0x2' Stop. ---------- messages: 386595 nosy: barry-scott priority: normal severity: normal status: open title: PyCMethod_New not defined in python3.lib versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 13:15:28 2021 From: report at bugs.python.org (Barry Alan Scott) Date: Sun, 07 Feb 2021 18:15:28 +0000 Subject: [New-bugs-announce] [issue43156] Python windows installer has a confusing name - add setup to its name Message-ID: <1612721728.1.0.320173776813.issue43156@roundup.psfhosted.org> New submission from Barry Alan Scott : New users of Python on Windows frequently confuse the Python installation program with Python itself. They also can end up with the wrong 32 or 64 bit version. I suggest that the installation program name is changed to include "setup" in its name. This seems to be the usually convention many Windows installation programs use. Further users may know they are need windows 64 bit or windows 32 bit compatible software. The python installer naming is not obvious. The windows 32 installer has no additional text to show it is targeted at windows 32. The windows 64 uses amd64 - does not mean not for Intel CPU's for example? Examples with both suggestions: python-3.10.0a5.exe becomes python-setup-win32-3.10.0a5.exe python-3.10.0a5-amd64.exe becomes python-setup-win64-3.10.0a5.exe Barry ---------- messages: 386598 nosy: barry-scott priority: normal severity: normal status: open title: Python windows installer has a confusing name - add setup to its name _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 14:08:50 2021 From: report at bugs.python.org (sandeep kumar) Date: Sun, 07 Feb 2021 19:08:50 +0000 Subject: [New-bugs-announce] [issue43157] Bug in methods of creating the list Message-ID: <1612724930.5.0.70990671335.issue43157@roundup.psfhosted.org> New submission from sandeep kumar : def generateMatrix(A): d=A-1 data=1 B=[[0]*A]*A for l in range(int(A/2)): i=l j=l for a in range(d): B[i][j]=data print("{0}:{1}:{2}".format(i,j,B[i][j]),end=" ") data+=1 j+=1 print() for a in range(d): B[i][j]=data print("{0}:{1}:{2}".format(i,j,B[i][j]),end=" ") data+=1 i+=1 print() for a in range(d): B[i][j]=data print("{0}:{1}:{2}".format(i,j,B[i][j]),end=" ") data+=1 j-=1 print() for a in range(d): B[i][j]=data print("{0}:{1}:{2}".format(i,j,B[i][j]),end=" ") data+=1 i-=1 print() d=d-2 print(d) print(B) if d==0: B[int(A/2)][int(A/2)]=data print(B[int(A/2)][int(A/2)]) print(B) return B ##if i'm using different approach to create 2d list . Then i'm getting right output . in above code i used B=[[0]*A]*A and getting wrong output . A is positive integer. ##If i'm using for i in range(A-1): B.append([0]*A) then i'm getting correct output. but the 2d list generated using both the approach are same. 2d list from approach 1== 2d list from approach 2 ------->it is true ---------- messages: 386602 nosy: samrajput1143 priority: normal severity: normal status: open title: Bug in methods of creating the list versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 15:44:19 2021 From: report at bugs.python.org (Larry Hastings) Date: Sun, 07 Feb 2021 20:44:19 +0000 Subject: [New-bugs-announce] [issue43158] uuid won't build when libuuid is installed in a non-standard place Message-ID: <1612730659.9.0.347520018019.issue43158@roundup.psfhosted.org> New submission from Larry Hastings : I'm building Python for a mildly-embedded ARM system. The system is running Linux, but doesn't have a native toolchain installed. So I'm building in a Docker container using a native toolchain (virtualizing the CPU). The toolchain I'm given has a bunch of stuff preinstalled, but not "util-linux", so it doesn't have /usr/include/uuid/uuid.h or /usr/include/uuid.h . I built and installed it myself in my PREFIX directory. But Python's build process has *two* bugs that prevented me from building the uuid module: * configure doesn't look in PREFIX for uuid/uuid.h or uuid.h. I assume it's only looking in /usr/include. This means it doesn't define any of the HAVE_UUID_* defines. * detect_uuid() in setup.py, which actually builds the module, *does* seem to check the prefix directory, but only for $PREFIX/uuid.h, not for $PREFIX/uuid/uuid.h. I hacked both of these manually and was rewarded with the uuid module building and working fine on the embedded system. So I assert this is a bug in Python's build process, if a minor one. ---------- components: Build messages: 386607 nosy: larry priority: low severity: normal stage: needs patch status: open title: uuid won't build when libuuid is installed in a non-standard place type: compile error versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 21:09:56 2021 From: report at bugs.python.org (JiKwon Kim) Date: Mon, 08 Feb 2021 02:09:56 +0000 Subject: [New-bugs-announce] [issue43159] pathlib with_suffix() should accept suffix not start with dot Message-ID: <1612750196.13.0.830563915902.issue43159@roundup.psfhosted.org> New submission from JiKwon Kim : Currently pathlib with_suffix() function only accepts suffix starts with dot("."). Consider this code; some_pathlib_path.with_suffix("jpg") This should change suffix to ".jpg", not raising ValueError. ---------- components: Library (Lib) messages: 386612 nosy: elbarkwon priority: normal severity: normal status: open title: pathlib with_suffix() should accept suffix not start with dot versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 7 23:12:31 2021 From: report at bugs.python.org (Tony Lykke) Date: Mon, 08 Feb 2021 04:12:31 +0000 Subject: [New-bugs-announce] [issue43160] argparse: add extend_const action Message-ID: <1612757551.9.0.453042152988.issue43160@roundup.psfhosted.org> New submission from Tony Lykke : I submitted this to the python-ideas mailing list early last year: https://mail.python.org/archives/list/python-ideas at python.org/thread/7ZHY7HFFQHIX3YWWCIJTNB4DRG2NQDOV/. Recently I had some time to implement it (it actually turned out to be pretty trivial), so thought I'd put forward a PR. Here's the summary from the mailing list submission: I have found myself a few times in a position where I have a repeated argument that uses the append action, along with some convenience arguments that append a specific const to that same dest (eg: --filter-x being made equivalent to --filter x via append_const). This is particularly useful in cli apps that expose some kind of powerful-but-verbose filtering capability, while also providing shorter aliases for common invocations. I'm sure there are other use cases, but this is the one I'm most familiar with. The natural extension to this filtering idea are convenience args that set two const values (eg: --filter x --filter y being equivalent to --filter-x-y), but there is no extend_const action to enable this. While this is possible (and rather straight forward) to add via a custom action, I feel like this should be a built-in action instead. append has append_const, it seems intuitive and reasonable to expect extend to have extend_const too (my anecdotal experience the first time I came across this need was that I simply tried using extend_const without checking the docs, assuming it already existed). Here's an excerpt from the docs I drafted for this addition that hopefully convey the intent and use case clearly. +* ``'extend_const'`` - This stores a list, and extends each argument value to the list. + The ``'extend_const'`` action is typically useful when you want to provide an alias + that is the combination of multiple other arguments. For example:: + + >>> parser = argparse.ArgumentParser() + >>> parser.add_argument('--str', dest='types', action='append_const', const=str) + >>> parser.add_argument('--int', dest='types', action='append_const', const=int) + >>> parser.add_argument('--both', dest='types', action='extend_const', const=(str, int)) + >>> parser.parse_args('--str --int'.split()) + Namespace(types=[, ]) + >>> parser.parse_args('--both'.split()) + Namespace(types=[, ]) ---------- components: Library (Lib) messages: 386614 nosy: rhettinger, roganartu priority: normal severity: normal status: open title: argparse: add extend_const action type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 01:23:08 2021 From: report at bugs.python.org (George) Date: Mon, 08 Feb 2021 06:23:08 +0000 Subject: [New-bugs-announce] [issue43161] Taking sum of massive list comprehension results in total system crash. Message-ID: <1612765388.88.0.878759110904.issue43161@roundup.psfhosted.org> New submission from George : I tried running the following command in the interpreter, and without fail it will completely crash my entire computer. Python 3.8.7 (default, Jan 20 2021, 00:00:00) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> sum([i for i in range(10**8 + 10**9)]) My kernel is 5.10.12-100 I am running on Fedora 32 with Cinnamon Desktop if it helps. Let me know if you need any other information. I eagerly await resolution of this bug, as I want to know the result of the computation. Unless, of course it is harebrained, then we should ignore because Guido already discussed such computations. George ---------- messages: 386615 nosy: U9dB37BPZx priority: normal severity: normal status: open title: Taking sum of massive list comprehension results in total system crash. type: crash versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 07:22:59 2021 From: report at bugs.python.org (=?utf-8?q?Miro_Hron=C4=8Dok?=) Date: Mon, 08 Feb 2021 12:22:59 +0000 Subject: [New-bugs-announce] [issue43162] Enum regression: AttributeError when accessing class variables on instances Message-ID: <1612786979.73.0.896348338765.issue43162@roundup.psfhosted.org> New submission from Miro Hron?ok : I believe I found a regression in Enum in Python 3.10.0a5. This is Python 3.9: >>> import enum >>> class C(enum.Enum): ... A = 0 ... B = 1 ... >>> C.A >>> C.B >>> C(0).A >>> C(0).B >>> The Enum instances can access class-attributes via dot, like normal instances do. While in Python 3.10.0a5: >>> import enum >>> class C(enum.Enum): ... A = 0 ... B = 1 ... >>> C.A >>> C.B >>> C(0).A Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.10/enum.py", line 146, in __get__ raise AttributeError( AttributeError: C: no attribute 'A' >>> C(0).B Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.10/enum.py", line 146, in __get__ raise AttributeError( AttributeError: C: no attribute 'B' In real word situations, it breaks meson: https://github.com/mesonbuild/meson/blob/398df5629863e913fa603cbf02c525a9f501f8a8/mesonbuild/backend/backends.py#L52-L78 The __str__ method does: if self is self.EXITCODE: ... And it fails with: AttributeError: TestProtocol: no attribute 'EXITCODE' This worked with 3.10.0a4. If this is a deliberate backwards incompatible change of behavior, I don't think it is documented in the changelog or what's new in Python 3.10, nor that it was deprecated in Python 3.9 and 3.8. ---------- components: Library (Lib) messages: 386626 nosy: hroncok priority: normal severity: normal status: open title: Enum regression: AttributeError when accessing class variables on instances type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 09:42:40 2021 From: report at bugs.python.org (Xie Jingyi) Date: Mon, 08 Feb 2021 14:42:40 +0000 Subject: [New-bugs-announce] [issue43163] code.interact() unexpected raises exception when there may be more code Message-ID: <1612795360.14.0.727480587245.issue43163@roundup.psfhosted.org> Change by Xie Jingyi : ---------- nosy: hsfzxjy priority: normal severity: normal status: open title: code.interact() unexpected raises exception when there may be more code type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 10:36:27 2021 From: report at bugs.python.org (Charalampos Stratakis) Date: Mon, 08 Feb 2021 15:36:27 +0000 Subject: [New-bugs-announce] [issue43164] test_nntplib.NetworkedNNTP_SSLTests fails on "AMD64 RHEL8 FIPS Only Blake2 Builtin Hash" buildbot Message-ID: <1612798587.66.0.557577709319.issue43164@roundup.psfhosted.org> New submission from Charalampos Stratakis : This is one of the unstable buildbots, running under FIPS mode. One of the tests is failing at the moment. ====================================================================== ERROR: setUpClass (test.test_nntplib.NetworkedNNTP_SSLTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/test/test_nntplib.py", line 321, in setUpClass cls.server = cls.NNTP_CLASS(cls.NNTP_HOST, File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/nntplib.py", line 1025, in __init__ super().__init__(host, port, user, password, readermode, File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/nntplib.py", line 334, in __init__ self.sock = self._create_socket(timeout) File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/nntplib.py", line 1031, in _create_socket sock = _encrypt_on(sock, self.ssl_context, self.host) File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/nntplib.py", line 292, in _encrypt_on return context.wrap_socket(sock, server_hostname=hostname) File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/ssl.py", line 1040, in _create self.do_handshake() File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: BAD_DH_VALUE] bad dh value (_ssl.c:1122) ---------------------------------------------------------------------- ---------- assignee: christian.heimes components: SSL, Tests messages: 386631 nosy: christian.heimes, cstratak priority: normal severity: normal status: open title: test_nntplib.NetworkedNNTP_SSLTests fails on "AMD64 RHEL8 FIPS Only Blake2 Builtin Hash" buildbot versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 12:32:01 2021 From: report at bugs.python.org (Milan Balazs) Date: Mon, 08 Feb 2021 17:32:01 +0000 Subject: [New-bugs-announce] [issue43165] Support the same files with new param in shutil.copyfile Message-ID: <1612805521.88.0.931585192254.issue43165@roundup.psfhosted.org> New submission from Milan Balazs : The "shutil.copyfile" raises a "SameFileError" exception if the src and dts files are the same. There is no option to allow the same files(like in case of shutil.copytree(dirs_exist_ok=False)). For example: import shutil shutil.copyfile("test.txt", "test.txt") Output: >>> python3 test.py Traceback (most recent call last): File "test.py", line 3, in shutil.copyfile("test.txt", "test.txt") File "/usr/lib/python3.6/shutil.py", line 104, in copyfile raise SameFileError("{!r} and {!r} are the same file".format(src, dst)) shutil.SameFileError: 'test.txt' and 'test.txt' are the same file ---------- components: Library (Lib) messages: 386634 nosy: milanbalazs priority: normal severity: normal status: open title: Support the same files with new param in shutil.copyfile type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 14:48:37 2021 From: report at bugs.python.org (Guido van Rossum) Date: Mon, 08 Feb 2021 19:48:37 +0000 Subject: [New-bugs-announce] [issue43166] Unused letters in Windows-specific pragma optimize Message-ID: <1612813717.65.0.159919254593.issue43166@roundup.psfhosted.org> New submission from Guido van Rossum : A coworker happened to look at our use of #pragma optimize() for Windows (VS 2017) and noticed: unless there?s something I?m missing, the ?a? and ?w? portions of the string being passed to the optimize pragma are not doing anything; I?m pretty sure they?ve been useless for 10+ years. The ?g? means turn on global optimizations and the ?t? means optimize for ?time? (i.e. speed). See the documentation at https://docs.microsoft.com/en-us/cpp/preprocessor/optimize?view=msvc-160 ---------- messages: 386646 nosy: gvanrossum priority: normal severity: normal status: open title: Unused letters in Windows-specific pragma optimize versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 14:48:49 2021 From: report at bugs.python.org (Barry Alan Scott) Date: Mon, 08 Feb 2021 19:48:49 +0000 Subject: [New-bugs-announce] [issue43167] macOS python install need mechanism to prevent editing shell profile files Message-ID: <1612813729.04.0.380298765117.issue43167@roundup.psfhosted.org> New submission from Barry Alan Scott : By default the python macOS installer will edit .bash_profile and .zsh_profile to add Python to the path. For many users this is a problem that requires the added lines to be removed after each install. I suggest that there is a mechanism that the user can use to tell the installer to leave the files as is. Once option could be to add a marker in the profile files that when present turns off the editing. For example a comment like: # python: no-path-edit Another possiblity is for the user to create a marker file that is checked for: touch ~/Library/Preferences/org.python.no-path.edit Any reasonable mechinism would be a great help. ---------- components: Installation messages: 386647 nosy: barry-scott priority: normal severity: normal status: open title: macOS python install need mechanism to prevent editing shell profile files versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 14:57:04 2021 From: report at bugs.python.org (Barry Alan Scott) Date: Mon, 08 Feb 2021 19:57:04 +0000 Subject: [New-bugs-announce] [issue43168] macOS python install shares /usr/local with homebrew and can conflict Message-ID: <1612814224.94.0.081336615563.issue43168@roundup.psfhosted.org> New submission from Barry Alan Scott : The popular homebrew system installs its binaries into /usr/local/bin. The macOS python install also defaults to /usr/local/bin where it puts symlinks to Python like: % ls -l /usr/local/bin/python3.10 lrwxr-xr-x 1 root 73 8 Feb 19:45:50 2021 /usr/local/bin/python3.10@ -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 I understand that there are issues when homebrew installed code requires home brew's python but finds the python.org version. Having installation options to control both where the symlinks are installed or not having any symlinks installed would help. This would make it easier to work with both python.org and homebrew. >From researching it seems that homebrew cannot be configure to use another folder for its installation. ---------- components: Installation messages: 386649 nosy: barry-scott priority: normal severity: normal status: open title: macOS python install shares /usr/local with homebrew and can conflict versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 15:40:56 2021 From: report at bugs.python.org (pkkm) Date: Mon, 08 Feb 2021 20:40:56 +0000 Subject: [New-bugs-announce] [issue43169] argparse: support options similar to find's -exec Message-ID: <1612816856.78.0.546559572107.issue43169@roundup.psfhosted.org> New submission from pkkm : This is a feature request for options that would work like the "find" program's "-exec" option, which takes the arguments following it unconditionally until it encounters a ";" or a "+". There are multiple ways to achieve this, but I think a good general solution would be to let "nargs" take a function. This function would receive a list of all arguments following the current one and return the number of arguments that the current one should take. An example usage would be: def command_nargs(args_after): for i, arg in enumerate(args_after): if arg in [';', '+']: return i + 1 raise argparse.ArgumentTypeError( 'Expected a command terminated with `;` or `+`.') parser = argparse.ArgumentParser() parser.add_argument('--command', nargs=command_nargs) parser.add_argument('--option') parser.parse_args(['--command', 'echo', 'hello', ';', '--option', 'value']) # => Namespace(command=['echo', 'hello', ';'], option='value') parser.parse_args(['--command', 'program', '--option', '+']) # => Namespace(command=['program', '--option', '+'], option=None) The crucial difference between this and the current behavior of "nargs" is that the requested number of arguments would be taken unconditionally, even if the arguments looked like options: parser = argparse.ArgumentParser() parser.add_argument('--nargs-function', nargs=lambda _: 1) parser.add_argument('--nargs-number', nargs=1) parser.add_argument('--option') parser.parse_args(['--nargs-function', '--option']) # => Namespace(nargs_function=['--option'], option=None) parser.parse_args(['--nargs-number', '--option']) # => error: argument --nargs-number: expected 1 argument Alternatively, if the difference between the behavior of "nargs=number" and "nargs=function" is judged to be too large, an optional argument "greedy" could be added to "ArgumentParser" and "add_argument". With "greedy=False" (the default), argparse would behave like it currently does. With "greedy=True", options would be processed left to right and would be assigned values unconditionally, even if these values looked like other options. An option with "nargs='*', greedy=True" or "nargs='+', greedy=True" would take all arguments to its right. An option with "nargs=function, greedy=False" would stop taking arguments when it encountered an option, while with "greedy=True" it would have the behavior proposed in the previous paragraphs. An example usage would then be: parser = argparse.ArgumentParser() parser.add_argument('--nargs-function', nargs=lambda _: 1) parser.add_argument('--nargs-number', nargs=1) parser.add_argument('--option') parser.parse_args(['--nargs-function', '--option']) # => error: argument --nargs-function: expected 1 argument parser.parse_args(['--nargs-number', '--option']) # => error: argument --nargs-number: expected 1 argument #################### parser = argparse.ArgumentParser() parser.add_argument('--nargs-function', nargs=lambda _: 1, greedy=True) parser.add_argument('--nargs-number', nargs=1, greedy=True) parser.add_argument('--option') parser.parse_args(['--nargs-function', '--option']) # => Namespace(nargs_function=['--option'], option=None) parser.parse_args(['--nargs-number', '--option']) # => Namespace(nargs_number=['--option'], option=None) and: parser = argparse.ArgumentParser() parser.add_argument('--command', nargs=command_nargs) parser.add_argument('--option') parser.add_argument('arg', nargs='?') parser.parse_args(['--command', 'program', '--option', 'value', '+']) # => Namespace(arg='+', command=['program'], option='value') #################### parser = argparse.ArgumentParser(greedy=True) parser.add_argument('--command', nargs=command_nargs) parser.add_argument('--option') parser.add_argument('arg', nargs='?') parser.parse_args(['--command', 'program', '--option', 'value', '+']) # => Namespace(arg=None, command=['program', '--option', 'value', '+'], option=None) Both of the alternatives in this feature request have the upside of making the behaviors requested in #9334 and #14364 possible. ---------- components: Library (Lib) messages: 386662 nosy: pkkm priority: normal severity: normal status: open title: argparse: support options similar to find's -exec type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 16:02:02 2021 From: report at bugs.python.org (Noah Steinberg) Date: Mon, 08 Feb 2021 21:02:02 +0000 Subject: [New-bugs-announce] [issue43170] wintypes.SIZE is 8bytes on 32 bit machines Message-ID: <1612818122.48.0.291280714647.issue43170@roundup.psfhosted.org> New submission from Noah Steinberg : Noticed while debugging a problem with a test running on Windows 10 x86 that sizeof(wintypes.SIZE)==8 when I believe it should be 4. While using kernel32.CreateRemoteThread.argtypes = [wintypes.HANDLE, wintypes.LPCVOID, wintypes.DWORD, wintypes.LPCVOID, wintypes.LPCVOID, wintypes.DWORD, wintypes.LPDWORD] and kernel32.CreateRemoteThread(h_process, 0, 0, 0xbadadd, 0, 4, byref(thread_id)) It caused CreateRemoteThread to recieve 4 as the last argument, resulting in an access denied ---------- components: ctypes messages: 386666 nosy: nnstein priority: normal severity: normal status: open title: wintypes.SIZE is 8bytes on 32 bit machines type: behavior versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 16:11:25 2021 From: report at bugs.python.org (Frank AK) Date: Mon, 08 Feb 2021 21:11:25 +0000 Subject: [New-bugs-announce] [issue43171] Counter not supported add in Python 3.x Message-ID: <1612818685.55.0.0888259271118.issue43171@roundup.psfhosted.org> New submission from Frank AK : In python 3.10, you couldn't plus two Counter instance, you will got the below tip: ``` >>> from collections import Counter >>> x={1:['a','b','c']} >>> y={1:['d','e','f'],2:['g']} >>> Counter(y) + Counter(x) Traceback (most recent call last): File "", line 1, in File "/Users/frank/github.com/cpython/Lib/collections/__init__.py", line 797, in __add__ if newcount > 0: TypeError: '>' not supported between instances of 'list' and 'int' ``` But in Python 2, you got the desire result like : ``` >>> from collections import Counter >>> x={1:['a','b','c']} >>> y={1:['d','e','f'],2:['g']} >>> Counter(x) + Counter(y) Counter({2: ['g'], 1: ['a', 'b', 'c', 'd', 'e', 'f']}) ``` ---------- messages: 386667 nosy: landpack priority: normal severity: normal status: open title: Counter not supported add in Python 3.x versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 20:40:34 2021 From: report at bugs.python.org (Gregory P. Smith) Date: Tue, 09 Feb 2021 01:40:34 +0000 Subject: [New-bugs-announce] [issue43172] Fix test_readline when compiled using --with-readline=edit Message-ID: <1612834834.05.0.814516616916.issue43172@roundup.psfhosted.org> New submission from Gregory P. Smith : https://bugs.python.org/issue13501 added configure --with-readline=edit support so that the readline module can build and link against libedit on any platform instead of only using libreadline. Building Python that way on Debian Linux and running test_readline results in a variety of test failure for me: ``` == CPython 3.10.0a5+ (heads/master-dirty:e1f7769513, Feb 9 2021, 01:20:59) [GCC 10.2.1 20210110] == cwd: /home/gps/oss/cpython/b/build/test_python_1681021? == CPU count: 16 == encodings: locale=UTF-8, FS=utf-8 0:00:00 load avg: 0.47 Run tests sequentially 0:00:00 load avg: 0.47 [1/1] test_readline readline version: 0x402 readline runtime version: 0x402 readline library version: 'EditLine wrapper' use libedit emulation? True testHistoryUpdates (test.test_readline.TestHistoryManipulation) ... ERROR test_nonascii_history (test.test_readline.TestHistoryManipulation) ... FAIL test_write_read_append (test.test_readline.TestHistoryManipulation) ... FAIL test_auto_history_disabled (test.test_readline.TestReadline) ... ok test_auto_history_enabled (test.test_readline.TestReadline) ... ok test_history_size (test.test_readline.TestReadline) ... skipped 'this readline version does not support history-size' test_init (test.test_readline.TestReadline) ... ok test_nonascii (test.test_readline.TestReadline) ... FAIL ====================================================================== ERROR: testHistoryUpdates (test.test_readline.TestHistoryManipulation) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/gps/oss/cpython/gpshead/Lib/test/test_readline.py", line 59, in testHistoryUpdates readline.replace_history_item(0, "replaced line") ValueError: No history item at position 0 ====================================================================== FAIL: test_nonascii_history (test.test_readline.TestHistoryManipulation) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/gps/oss/cpython/gpshead/Lib/test/test_readline.py", line 127, in test_nonascii_history self.assertEqual(readline.get_history_item(1), "entr?e 1") AssertionError: 'entr?e 22' != 'entr?e 1' - entr?e 22 ? ^^ + entr?e 1 ? ^ ====================================================================== FAIL: test_write_read_append (test.test_readline.TestHistoryManipulation) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/gps/oss/cpython/gpshead/Lib/test/test_readline.py", line 98, in test_write_read_append self.assertEqual(readline.get_current_history_length(), 3) AssertionError: 4 != 3 ====================================================================== FAIL: test_nonascii (test.test_readline.TestReadline) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/gps/oss/cpython/gpshead/Lib/test/test_readline.py", line 231, in test_nonascii self.assertIn(b"indexes 11 13\r\n", output) AssertionError: b'indexes 11 13\r\n' not found in bytearray(b"^A^B^B^B^B^B^B^B\t\tx\t\r\n[\xc3\xafnserted]|t\xc3\xab[after]\x08\x08\x08\x08\x08\x08\x08text \'t\\xeb\'\r\nline \'[\\xefnserted]|t\\xeb[after]\'\r\nindexes 10 12\r\n\x07\r\x1b[14Gtext \'t\\xeb\'\r\nline \'[\\xefnserted]|t\\xeb[after]\'\r\nindexes 10 12\r\n\r\nt\xc3\xabnt t\xc3\xabxt\r\n\r\x1b[K[\xc3\xafnserted]|t\xc3\xab[after]\x1b[14G\r\x1b[14G\x1b[1 at x[\x08\x07\r\x1b[15G\x1b[1 at t[\x08\r\nresult \'[\\xefnserted]|t\\xebxt[after]\'\r\nhistory \'[\\xefnserted]|t\\xebxt[after]\'\r\n") ---------------------------------------------------------------------- Ran 8 tests in 0.123s FAILED (failures=3, errors=1, skipped=1) ``` I suspect these are just behavior differences in the library and some tests need to be skipped or test alternate behavior in this situation? ---------- assignee: gregory.p.smith components: Library (Lib), Tests messages: 386681 nosy: gregory.p.smith priority: normal severity: normal stage: needs patch status: open title: Fix test_readline when compiled using --with-readline=edit type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 21:45:38 2021 From: report at bugs.python.org (Jeff Moguillansky) Date: Tue, 09 Feb 2021 02:45:38 +0000 Subject: [New-bugs-announce] [issue43173] Python Windows DLL search paths Message-ID: <1612838738.77.0.220121925422.issue43173@roundup.psfhosted.org> New submission from Jeff Moguillansky : Hi, What's the correct way to set the DLL search path when running a python script? It seems that it doesn't search the directories specified in PATH environment variable. FYI: For debugging the DLL loading issues, I'm using "Process Monitor" from sysinternals: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon, but please share any tips if you have a better approach. Also, the Python error message is not very informative: when loading a python module (built using Cython), if it fails to load a specific DLL, it says "import module failed, DLL not found" but it doesn't say the name of the actual DLL that is not found. It would be helpful if it listed the actual name of the DLL that it cannot find. ---------- components: Windows messages: 386688 nosy: jmoguill2, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Python Windows DLL search paths type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 8 21:59:02 2021 From: report at bugs.python.org (Inada Naoki) Date: Tue, 09 Feb 2021 02:59:02 +0000 Subject: [New-bugs-announce] [issue43174] Windows: Use /utf-8 compiler flag Message-ID: <1612839542.96.0.0701004170388.issue43174@roundup.psfhosted.org> New submission from Inada Naoki : When building Python on Windows Japanese environment, several warnings are shown. ``` C:\Users\songo\source\repos\cpython\Modules\_sha3\kcp\KeccakSponge.h(1,1): warning C4819: ???????????? ??? (932) ??????????????????????????????????? Unicode ???????????? [C:\Users\songo\source\repos\cpython\PCbuild\pythoncore.vcxproj] C:\Users\songo\source\repos\cpython\Modules\_statisticsmodule.c(1,1): warning C4819: ???????????? ??? (932) ????????????? ?????????????????????? Unico de ???????????? [C:\Users\songo\source\repos\cpython\PCbuild\pythoncore.vcxproj] C:\Users\songo\source\repos\cpython\Modules\_zoneinfo.c(1,1): warning C4819: ???????????? ??? (932) ????????????????? ?????????????????? Unicode ????? ??????? [C:\Users\songo\source\repos\cpython\PCbuild\_zoneinfo.vcxproj] C:\Users\songo\source\repos\cpython\Modules\_zoneinfo.c(1028,1): warning C4819: ???????????? ??? (932) ??????????????????????????????????? Unicode ?? ?????????? [C:\Users\songo\source\repos\cpython\PCbuild\_zoneinfo.vcxproj] C:\Users\songo\source\repos\cpython\Modules\_zoneinfo.c(1970,1): warning C4819: ???????????? ??? (932) ??????????????????????????????????? Unicode ?? ?????????? [C:\Users\songo\source\repos\cpython\PCbuild\_zoneinfo.vcxproj] C:\Users\songo\source\repos\cpython\Modules\expat\xmltok.c(1,1): warning C4819: ???????????? ??? (932) ??????????????????????????????????? Unicode ?? ?????????? [C:\Users\songo\source\repos\cpython\PCbuild\_elementtree.vcxproj] C:\Users\songo\source\repos\cpython\Modules\expat\xmltok.c(1,1): warning C4819: ???????????? ??? (932) ??????????????????????????????????? Unicode ?? ?????????? [C:\Users\songo\source\repos\cpython\PCbuild\pyexpat.vcxproj] C:\Users\songo\source\repos\cpython\Modules\_lzmamodule.c(1,1): warning C4819: ???????????? ??? (932) ???????????????? ??????????????????? Unicode ??? ????????? [C:\Users\songo\source\repos\cpython\PCbuild\_lzma.vcxproj] ``` These warnings are shown because source code is written in UTF-8 but compiler assume it's encoded in current code page. I don't know what is the best way to fix the warning, but I can fix it by adding /utf-8 flag. ``` diff --git a/PCbuild/_zoneinfo.vcxproj b/PCbuild/_zoneinfo.vcxproj index 6e6389c377..4602e45ce5 100644 --- a/PCbuild/_zoneinfo.vcxproj +++ b/PCbuild/_zoneinfo.vcxproj @@ -91,6 +91,11 @@ <_ProjectFileVersion>10.0.30319.1 + + + /utf-8 %(AdditionalOptions) + + ``` ---------- components: Build messages: 386689 nosy: methane priority: normal severity: normal status: open title: Windows: Use /utf-8 compiler flag versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 00:36:37 2021 From: report at bugs.python.org (suresh) Date: Tue, 09 Feb 2021 05:36:37 +0000 Subject: [New-bugs-announce] [issue43175] filecmp is not working for UTF-8 BOM file. Message-ID: <1612848997.29.0.320825258569.issue43175@roundup.psfhosted.org> New submission from suresh : Python base package filecmp is not working properly for 'UTF-8 BOM' css files. I am using python version 3.6 and windows 10 OS. while running the below code getting as False always.However the file content are same. Code : import filecmp filecmp.clear_cache() boolfile=filecmp.cmp(r'C:\Users\suresh.n\python\RPA\Page\Sowmiya\downloads\destination.txt',r'C:\Users\suresh.n\python\RPA\Page\Sowmiya\source\source,r'C:\Users\suresh.n\python\RPA\Page\Sowmiya\downloads.txt',shallow=False) print(boolfile) ---------- components: Windows files: source.txt hgrepos: 397 messages: 386692 nosy: paul.moore, steve.dower, suresh, tim.golden, zach.ware priority: normal severity: normal status: open title: filecmp is not working for UTF-8 BOM file. type: behavior versions: Python 3.6 Added file: https://bugs.python.org/file49798/source.txt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 02:12:39 2021 From: report at bugs.python.org (Iurii Kemaev) Date: Tue, 09 Feb 2021 07:12:39 +0000 Subject: [New-bugs-announce] [issue43176] Dataclasses derived from empty frozen bases skip immutability checks Message-ID: <1612854759.36.0.400211114548.issue43176@roundup.psfhosted.org> New submission from Iurii Kemaev : Dataclasses derived from empty frozen bases skip immutability checks. Repro snippet: ``` import dataclasses @dataclasses.dataclass(frozen=True) class Base: pass @dataclasses.dataclass class Derived(Base): a: int d = Derived(2) # OK ``` Usecase: sometimes developers define an empty frozen base dataclass with detailed docs and require other dataclasses to inherit from it as a code contract to avoid accidental in-place modifications. This bug makes this strategy ineffective. Affects all versions of Python that support dataclasses (including the backport for py3.6). ---------- components: Library (Lib) messages: 386695 nosy: hbq1 priority: normal pull_requests: 23278 severity: normal status: open title: Dataclasses derived from empty frozen bases skip immutability checks 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 Feb 9 03:40:00 2021 From: report at bugs.python.org (Ganesh Kathiresan) Date: Tue, 09 Feb 2021 08:40:00 +0000 Subject: [New-bugs-announce] [issue43177] How to use `long double` as a PyObject? Message-ID: <1612860000.51.0.99318031959.issue43177@roundup.psfhosted.org> New submission from Ganesh Kathiresan : I wanted to know if there is a way to parse and store c `long double`. I only found `PyFloat_FromDouble` and in the same page, `PyFloat_GetMax` returns: > Return the maximum representable finite float DBL_MAX as C double. Meaning, there is no scope of `long double`. Can you please tell me how I can do something like `PyFloat_FromLongDouble` ---------- components: ctypes messages: 386698 nosy: ganesh3597 priority: normal severity: normal status: open title: How to use `long double` as a PyObject? type: enhancement versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 03:40:30 2021 From: report at bugs.python.org (Peleg Shilo) Date: Tue, 09 Feb 2021 08:40:30 +0000 Subject: [New-bugs-announce] [issue43178] Redundant method overrides in queue Message-ID: <1612860030.43.0.826526861331.issue43178@roundup.psfhosted.org> New submission from Peleg Shilo : PriorityQueue and LIFOQueue override the _qsize method without actually changing it. They should just inherit it normally. ---------- components: Library (Lib) messages: 386699 nosy: peleg2 priority: normal severity: normal status: open title: Redundant method overrides in queue type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 06:41:13 2021 From: report at bugs.python.org (Christian Heimes) Date: Tue, 09 Feb 2021 11:41:13 +0000 Subject: [New-bugs-announce] [issue43179] Remove s390 support Message-ID: <1612870873.59.0.718960539942.issue43179@roundup.psfhosted.org> New submission from Christian Heimes : configure.ac contains triplet definitions for s390 and s390x mainframes. While s390x (Linux on IBM Z) is still widely supported, s390 is not. s390 was released in 1990 and discontinued in 1998, https://en.wikipedia.org/wiki/IBM_System/390 Ariadne Conill from Alpine pointed out that: Linux has not supported booting on traditional 31-bit s390 since Linux 4.1 in 2015. If you can't boot s390 (not s390x) with a modern kernel, it is absurd to demand that other projects support s390. https://github.com/pyca/cryptography/issues/5771#issuecomment-775872483 I propose to remove check for __s390__ from configure.ac and configure. We might also want to remove __alpha__, __hppa__, and __m68k__ at a later point. DEC hasn't been around for a long time. ---------- components: Interpreter Core messages: 386709 nosy: christian.heimes priority: normal severity: normal status: open title: Remove s390 support versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 11:02:17 2021 From: report at bugs.python.org (Mike Siegel) Date: Tue, 09 Feb 2021 16:02:17 +0000 Subject: [New-bugs-announce] [issue43180] Lists without commas? Message-ID: <1612886537.53.0.750473306106.issue43180@roundup.psfhosted.org> New submission from Mike Siegel : Perhaps I'm missing something here but this behavior seems unexpected to me. "Lists The items of a list are arbitrary Python objects. Lists are formed by placing a *comma-separated* list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.)" >>> import sys >>> print(sys.version) 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] >>> test = [ "foo" "bar" ] >>> type(test) >>> print(test) ['foobar'] >>> import json >>> json.dumps({ "foo": test }) '{"foo": ["foobar"]}' >>> In a complex dict structure this is an easy way to shoot yourself in the foot. ---------- messages: 386725 nosy: mikesiegel priority: normal severity: normal status: open title: Lists without commas? _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 17:05:50 2021 From: report at bugs.python.org (Vitaliy) Date: Tue, 09 Feb 2021 22:05:50 +0000 Subject: [New-bugs-announce] =?utf-8?q?=5Bissue43181=5D_Python_macros_don?= =?utf-8?q?=E2=80=99t_shield_arguments?= Message-ID: <1612908350.59.0.954965139249.issue43181@roundup.psfhosted.org> New submission from Vitaliy : There is a lot of macros like: #define PyObject_TypeCheck(ob, tp) \ (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) These work fine until an argument happen to contain a comma. That?s possible as a result of other macro?s expansion. E.g. if U(x) is defined as x, PyObject_TypeCheck(ob, U(f(c))) expands to (Py_IS_TYPE(ob, f(c)) || ...) but < and > aren?t treated as brackets by the preprocessor so Py_IS_TYPE is now invoked with 3 arguments instead of just 2, breaking module compilation. As arguments are expected to be values, surrounding each with parentheses solves the problem. But there are many such macros so that?s not an one-line fix. Note: the example is from PyGLM (simplified), it doesn?t compile on 3.9 due to this issue. ---------- components: C API messages: 386746 nosy: numberZero priority: normal severity: normal status: open title: Python macros don?t shield arguments versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 9 19:36:45 2021 From: report at bugs.python.org (Bruce Fuda) Date: Wed, 10 Feb 2021 00:36:45 +0000 Subject: [New-bugs-announce] [issue43182] TURTLE: Default values for basic Turtle commands Message-ID: <1612917405.69.0.155307623071.issue43182@roundup.psfhosted.org> New submission from Bruce Fuda : Since Python is being taught to students of all ages and in particular younger kids (i.e. 6 - 10 yo) who are learning not just python, but many related things for the first time, the need to include values as arguments to basic Turtle functions like: forward() backward() left() right() adds additional complexity. The natural starting point for these types of activities with kids is a transition from the physical world of devices such as the Bee-bot (https://www.tts-international.com/bee-bot-programmable-floor-robot/1015268.html) which have pre-defined lengths (i.e. 15cm) and turn angles (i.e. 90 degrees) so that they can focus primarily on sequencing and learning commands without the cognitive load of additional information. It would be an ideal starting point for the forward(), backward(), left() and right() commands to be overloaded such that there is a default value. This reduces the cognitive load for young students, because it instead means they can focus on learning basic commands, sequencing and syntax without also needing to understand angles and relative lengths. Suggestion would be to set a default value for movement (i.e. forward and backward) of 50, and default angles for turning (left and right) of 90 degrees. This simple (and trivial) change would massively help thousands of students get started with Python, without in any way impacting existing use of Turtle. ---------- components: Library (Lib) messages: 386750 nosy: Bruce1979 priority: normal severity: normal status: open title: TURTLE: Default values for basic Turtle commands type: enhancement 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 Feb 9 20:42:49 2021 From: report at bugs.python.org (Bob) Date: Wed, 10 Feb 2021 01:42:49 +0000 Subject: [New-bugs-announce] [issue43183] Asyncio can't close sockets properly on Linux cause CLOSE_WAIT Message-ID: <1612921369.93.0.425645131908.issue43183@roundup.psfhosted.org> Change by Bob : ---------- components: asyncio nosy: Bob_2021, asvetlov, yselivanov priority: normal severity: normal status: open title: Asyncio can't close sockets properly on Linux cause CLOSE_WAIT type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 03:37:11 2021 From: report at bugs.python.org (Yoav Palti) Date: Wed, 10 Feb 2021 08:37:11 +0000 Subject: [New-bugs-announce] [issue43184] Missing docs for LoggerAdapter manager and name property Message-ID: <1612946231.77.0.582069652374.issue43184@roundup.psfhosted.org> New submission from Yoav Palti : I found the following issue which added manager and name properties to logging.LoggerAdapter on version 3.6: https://bugs.python.org/issue31457 However the current docs don't have them documented: https://docs.python.org/3.6/library/logging.html#logging.LoggerAdapter ---------- assignee: docs at python components: Documentation messages: 386762 nosy: docs at python, yoavp10 priority: normal severity: normal status: open title: Missing docs for LoggerAdapter manager and name property 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 Feb 10 04:00:08 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:00:08 +0000 Subject: [New-bugs-announce] [issue43185] AssertRaises() causes core dump in handling recursion Message-ID: <1612947608.83.0.497141724591.issue43185@roundup.psfhosted.org> New submission from Yang Feng : Seeing the following program, in the second assertRaises(), function "test_invalid_adpcm_state()" is recursively called. Then a fatal Python error shows up and the Python interpreter crashes. ++++++++++++++++++++++++++++++++++++++ import unittest import audioop class TestAudioop(unittest.TestCase): pass def test_invalid_adpcm_state(): TestAudioop.assertRaises(TypeError, audioop.lin2adpcm, b'\x00', 1, 555) TestAudioop.assertRaises(test_invalid_adpcm_state(), audioop.adpcm2lin, b'\x00', 1, (0, (- 1))) TestAudioop = TestAudioop() test_invalid_adpcm_state() +++++++++++++++++++++++++++++++++++++++ System Info: Ubuntu 16.04 Python Version: Python 3.9.1 ---------- components: Library (Lib) messages: 386763 nosy: CharlesFengY priority: normal severity: normal status: open title: AssertRaises() causes core dump in handling recursion type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 04:14:27 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:14:27 +0000 Subject: [New-bugs-announce] [issue43186] Recursive call causes core dump in assertRaises Message-ID: <1612948467.97.0.883928038728.issue43186@roundup.psfhosted.org> New submission from Yang Feng : In following teststr.py, class MyString is nestedly instanced in method __getattr__(). This script will lead to a "core dump" in Python interpreter. My Python version is 3.9.1 and my operating system is Ubuntu 16.04. teststr.py +++++++++++++++++++++++++++++++++++++++++++ class StrError(str): pass class MyString: def __init__(self, istr): self.__mystr__ = istr def __getattr__(self, content): with self: return MyString(getattr(self.__mystr__, content)) def __setattr__(self, content, sstr): setattr(self.__mystr__, content) def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): raise StrError(self.__mystr__) return True MyString("hello") +++++++++++++++++++++++++++++++++++++++++ ---------- components: Library (Lib) messages: 386764 nosy: CharlesFengY priority: normal severity: normal status: open title: Recursive call causes core dump in assertRaises versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 04:19:35 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:19:35 +0000 Subject: [New-bugs-announce] [issue43187] Dict creation in recursive function cause interpreter crashes. Message-ID: <1612948775.51.0.474463250225.issue43187@roundup.psfhosted.org> New submission from Yang Feng : In the following programs, dict is created in recursive calls. Then a core dump is reported by Python interpreter. +++++++++++++++++++++++++++++++++++++++++++ def test_equal_operator_modifying_operand(): class X(): def __del__(DictTest): dict_b.clear() def __eq__(DictTest, other): dict_a.clear() return True def __hash__(DictTest): return 13 dict_d = {X(): 0} class Y(): def __eq__(DictTest, other): dict_d.clear() return True dict_d = {0: Y()} # dict_c = {0: set()} test_equal_operator_modifying_operand() test_equal_operator_modifying_operand() +++++++++++++++++++++++++++++++++++++++++ ---------- components: Interpreter Core messages: 386765 nosy: CharlesFengY priority: normal severity: normal status: open title: Dict creation in recursive function cause interpreter crashes. type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 04:44:21 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:44:21 +0000 Subject: [New-bugs-announce] [issue43188] multiple operations of dict causes core dump of Python interpreter. Message-ID: <1612950261.11.0.487883893903.issue43188@roundup.psfhosted.org> New submission from Yang Feng : In the following programs, we call check_reentrant_insertion("s") twice, after multiple of update and clear of dict, the Python interpreter crashes. +++++++++++++++++++++++++++++++++++++++++++ def check_reentrant_insertion(mutate): class Mutating: def __del__(self): mutate(d) d = {k: Mutating() for k in 'abcdefghijklmnopqr'} for k in list(d): d[k] = k def test_reentrant_insertion(): check_reentrant_insertion("s") def mutate(d): d.update(DictTest.__dict__) d.clear() check_reentrant_insertion(test_reentrant_insertion()) test_reentrant_insertion() +++++++++++++++++++++++++++++++++++++++++ System Info: Ubuntu 16.04 Python Version: Python 3.9.1 ---------- components: Interpreter Core messages: 386766 nosy: CharlesFengY priority: normal severity: normal status: open title: multiple operations of dict causes core dump of Python interpreter. type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 04:46:08 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:46:08 +0000 Subject: [New-bugs-announce] [issue43189] decorator function run_with_locale() crashes Python interpreter Message-ID: <1612950368.13.0.435126330801.issue43189@roundup.psfhosted.org> New submission from Yang Feng : We use run_with_locale() as decorator function, then we recursively call test_float__format__locale in the following example. Python interpreter crashes. +++++++++++++++++++++++++++++++++++++++++++ from test.support import run_with_locale @run_with_locale('LC_NUMERIC', 'en_US.UTF8') def test_float__format__locale(): test_float__format__locale() test_float__format__locale() +++++++++++++++++++++++++++++++++++++++++ System Info: Ubuntu 16.04 Python Version: Python 3.9.1 ---------- components: Tests messages: 386767 nosy: CharlesFengY priority: normal severity: normal status: open title: decorator function run_with_locale() crashes Python interpreter type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 04:48:57 2021 From: report at bugs.python.org (Yang Feng) Date: Wed, 10 Feb 2021 09:48:57 +0000 Subject: [New-bugs-announce] [issue43190] < test.support > check_free_after_iterating( ) causes core dump in handling iteration. Message-ID: <1612950537.99.0.387983574304.issue43190@roundup.psfhosted.org> New submission from Yang Feng : In the following program, we call check_free_after_iterating( ) twice, in the second time, we recursively call function test_free_after_iterating(). Python interpreter crashes. +++++++++++++++++++++++++++++++++++++++++++ import unittest import test.support class UnicodeTest(unittest.TestCase): pass def test_free_after_iterating(): ut = UnicodeTest() test.support.check_free_after_iterating(ut, iter, str) test.support.check_free_after_iterating(str, test_free_after_iterating(), str) test_free_after_iterating() +++++++++++++++++++++++++++++++++++++++++ System Info: Ubuntu 16.04 Python Version: Python 3.9.1 ---------- components: Library (Lib) messages: 386768 nosy: CharlesFengY priority: normal severity: normal status: open title: < test.support > check_free_after_iterating( ) causes core dump in handling iteration. type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 05:13:44 2021 From: report at bugs.python.org (Hannah Busshoff) Date: Wed, 10 Feb 2021 10:13:44 +0000 Subject: [New-bugs-announce] [issue43191] Shared Memory for array of object Message-ID: <1612952024.75.0.333597228356.issue43191@roundup.psfhosted.org> New submission from Hannah Busshoff : Dear all, When seeking to put an object of type -- Array of object -- into shared memory when doing multiprocessing via starmap, I am encountering problems -- in that sense that the program does not finish running but apparently gets stuck. I attached a minimal example. Many thanks for your help. I sincerely hope I have not overlooked that this issue has been raised by somebody else. I am happy to provide further input! Cheers, Hannah ---------- files: example.py messages: 386769 nosy: hannahbusshoff priority: normal severity: normal status: open title: Shared Memory for array of object type: crash versions: Python 3.8 Added file: https://bugs.python.org/file49801/example.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 05:24:37 2021 From: report at bugs.python.org (Clint Olsen) Date: Wed, 10 Feb 2021 10:24:37 +0000 Subject: [New-bugs-announce] [issue43192] Argparse complains argument required when default is provided Message-ID: <1612952677.32.0.0422896967903.issue43192@roundup.psfhosted.org> New submission from Clint Olsen : When I run the following program, I expect args.run to be 'foo' if no argument is specified on the command-line. parser = argparse.ArgumentParser() parser.add_argument('foo', default='bar') args = parser.parse_args() $ ./test usage: test [-h] foo test: error: the following arguments are required: foo However if I specify nargs='*' this error goes away. Maybe I'm missing something obvious, but this seems non-intuitive to me. ---------- components: Library (Lib) messages: 386770 nosy: Clint Olsen priority: normal severity: normal status: open title: Argparse complains argument required when default is provided type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 05:41:31 2021 From: report at bugs.python.org (Muhammad Hussein Ammari) Date: Wed, 10 Feb 2021 10:41:31 +0000 Subject: [New-bugs-announce] [issue43193] Installer for All users Message-ID: <1612953691.92.0.275565504526.issue43193@roundup.psfhosted.org> New submission from Muhammad Hussein Ammari : I installed Python for All users Installer make below file to %LocalAppData% (Instead of %ProgramData%) "%LocalAppData%\Package Cache\{b2be55ad-3177-42aa-a6c2-53004684e4ea}" Now other user can't unistalling Python. Please fix this issue. ---------- components: Windows messages: 386772 nosy: paul.moore, steve.dower, tim.golden, xmha97, zach.ware priority: normal severity: normal status: open title: Installer for All users type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 09:37:21 2021 From: report at bugs.python.org (JiKwon Kim) Date: Wed, 10 Feb 2021 14:37:21 +0000 Subject: [New-bugs-announce] [issue43194] Add JFXX as jpeg marker in imghdr module Message-ID: <1612967841.33.0.0362829630893.issue43194@roundup.psfhosted.org> New submission from JiKwon Kim : Currently imghdr module only finds "JFIF" or "Exif" in specific position. However there's some jpeg images with "JFXX" marker. I had some image with this marker and imghdr.what() returned None. Refer to: https://www.ecma-international.org/wp-content/uploads/ECMA_TR-98_1st_edition_june_2009.pdf (Section 10.1 JFIF Extension APP0 Marker Segment) ---------- components: Library (Lib) messages: 386782 nosy: elbarkwon priority: normal pull_requests: 23291 severity: normal status: open title: Add JFXX as jpeg marker in imghdr module type: enhancement versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 15:05:35 2021 From: report at bugs.python.org (Christoph Reiter) Date: Wed, 10 Feb 2021 20:05:35 +0000 Subject: [New-bugs-announce] [issue43195] Same userbase for 32bit and 64bit install on Windows causing conflicts Message-ID: <1612987535.89.0.745521676506.issue43195@roundup.psfhosted.org> New submission from Christoph Reiter : I'm sure this is already filed somewhere, but I couldn't find anything. Currently when installing packages with pip using a 64bit Python to --user and then starting a 32bit Python things fail because they look up packages from the same location: .\python.exe -m site --user-base C:\Users\user\AppData\Roaming\Python For example trying to import numpy from a 32bit Python when it was installed with 64bit: >>> import numpy Traceback (most recent call last): File "", line 1, in File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 143, in from . import _distributor_init File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\numpy\_distributor_init.py", line 26, in WinDLL(os.path.abspath(filename)) File "C:\Python39-32\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application I guess this isn't a very common problem, but in MSYS2 we are facing this issue because users can easily switch between 32bit/64bit Python. We could patch things, but I'm wondering if there are any plans to fix this in CPython itself so we don't invent our own thing. thanks ---------- components: Windows messages: 386804 nosy: lazka, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Same userbase for 32bit and 64bit install on Windows causing conflicts versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 15:45:36 2021 From: report at bugs.python.org (Ellis Percival) Date: Wed, 10 Feb 2021 20:45:36 +0000 Subject: [New-bugs-announce] [issue43196] logging.config.dictConfig shuts down socket for existing SysLogHandlers Message-ID: <1612989936.74.0.764522656943.issue43196@roundup.psfhosted.org> New submission from Ellis Percival : Since https://github.com/python/cpython/commit/b6c1989168efeb8b6320bec958e7e339270ac0ce dictConfig (and presumably fileConfig) has called logging.shutdown() on the existing handlers. This causes existing SysLogHandlers' sockets to be closed, which then causes a BadFileDescriptor error when you try to use it: --- Logging error --- Traceback (most recent call last): File "/usr/lib/python3.8/logging/handlers.py", line 940, in emit self.socket.sendto(msg, self.address) OSError: [Errno 9] Bad file descriptor Call stack: File "/home/flyte/workspaces/python/test.py", line 18, in log.warning("Breaks") Reproduce the error with the following code: import logging.config import socket from logging.handlers import SysLogHandler log = logging.getLogger("logtest") syslog_handler = SysLogHandler(("127.0.0.1", 12345), socktype=socket.SOCK_DGRAM) log.addHandler(syslog_handler) log.warning("Works") logging.config.dictConfig( { "version": 1, "disable_existing_loggers": False, } ) log.warning("Breaks") This causes issues such as https://github.com/benoitc/gunicorn/issues/2073 where gunicorn sets up a SysLogHandler, then when any app (Django does it by default) calls dictConfig() it closes the socket used by gunicorn's SysLogHandler. Assuming this also affects Python 3.9 and 3.10, but untested. ---------- components: Library (Lib) messages: 386805 nosy: flyte priority: normal severity: normal status: open title: logging.config.dictConfig shuts down socket for existing SysLogHandlers type: crash versions: Python 3.7, Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 16:14:22 2021 From: report at bugs.python.org (Pablo) Date: Wed, 10 Feb 2021 21:14:22 +0000 Subject: [New-bugs-announce] [issue43197] random.shuffle() returning None Message-ID: <1612991662.12.0.189430879843.issue43197@roundup.psfhosted.org> New submission from Pablo : import random mylist = ["apple", "banana", "cherry"] print(random.shuffle(mylist)) Result: None Expected result: A shuffle list It works in Python 3.7.3 but it fails in Python 3.8.5 (Ubuntu 20.04.2) ---------- messages: 386807 nosy: pablonana priority: normal severity: normal status: open title: random.shuffle() returning None type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 10 19:15:07 2021 From: report at bugs.python.org (Eric Martin) Date: Thu, 11 Feb 2021 00:15:07 +0000 Subject: [New-bugs-announce] [issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions Message-ID: <1613002507.49.0.48232719319.issue43198@roundup.psfhosted.org> New submission from Eric Martin : Run on a MacBook Pro (15-inch, 2019) 2.3 GHz 8-Core Intel Core i9 16 GB 2400 MHz DDR4 Python 3.8.7 (default, Dec 24 2020, 19:07:18) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from timeit import timeit >>> S = set(range(10_000)) >>> timeit('S.remove(5000); S.add(5000)', globals=globals(), number=100_000) 0.01933291699999984 $ python3.9 Python 3.9.1 (default, Dec 8 2020, 13:10:53) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from timeit import timeit >>> S = set(range(10_000)) >>> timeit('S.remove(5000); S.add(5000)', globals=globals(), number=100_000) 3.8517225489999998 ---------- components: Interpreter Core messages: 386815 nosy: eamartin priority: normal severity: normal status: open title: Operations on sets more than hundred times less efficient with python3.9 than with previous versions type: performance versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 11 04:44:53 2021 From: report at bugs.python.org (=?utf-8?q?Mikael_L=C3=B6vqvist?=) Date: Thu, 11 Feb 2021 09:44:53 +0000 Subject: [New-bugs-announce] [issue43199] FAQ about goto lacks answer Message-ID: <1613036693.06.0.0717598867229.issue43199@roundup.psfhosted.org> New submission from Mikael L?vqvist : In the FAQ there is a question "Why is there no goto?" but the answer addresses how to use exceptions to do something akin to goto. I think the documentation could benefit from the reasons why there is no goto or that the question is changed, perhaps "How to approximate goto?". Reference: https://docs.python.org/3/faq/design.html#why-is-there-no-goto ---------- assignee: docs at python components: Documentation messages: 386825 nosy: docs at python, mlovqvist priority: normal severity: normal status: open title: FAQ about goto lacks answer type: enhancement 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 Feb 11 06:21:32 2021 From: report at bugs.python.org (nikkie) Date: Thu, 11 Feb 2021 11:21:32 +0000 Subject: [New-bugs-announce] [issue43200] link to copy module in shutil document, not to shutil.copy Message-ID: <1613042492.32.0.484655059288.issue43200@roundup.psfhosted.org> New submission from nikkie : "copy()" is not a link to shutil.copy, but a link to the copy module. https://docs.python.org/3/library/shutil.html#platform-dependent-efficient-copy-operations >Starting from Python 3.8 all functions involving a file copy (copyfile(), copy(), copy2(), copytree(), and move()) may use ... # As is https://docs.python.org/3/library/copy.html#module-copy # To be https://docs.python.org/3/library/shutil.html#shutil.copy The reference of :func:`copy` does not seem to be resolved properly. https://github.com/python/cpython/blob/ea46579067fd2d4e164d6605719ffec690c4d621/Doc/library/shutil.rst#platform-dependent-efficient-copy-operations ---------- assignee: docs at python components: Documentation messages: 386828 nosy: docs at python, nikkie priority: normal severity: normal status: open title: link to copy module in shutil document, not to shutil.copy versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 11 15:23:58 2021 From: report at bugs.python.org (Tyler Reed) Date: Thu, 11 Feb 2021 20:23:58 +0000 Subject: [New-bugs-announce] [issue43201] sqlite3 import * ImportError: DLL load failed while importing _sqlite3: The specified module could not be found. Message-ID: <1613075038.27.0.260449225949.issue43201@roundup.psfhosted.org> New submission from Tyler Reed : Running on a new, updated Windows 10 machine with no virtual environment. After removing all previous Python installations, rebooting and performing a fresh install if Python 3.9.1. I run the python console and type: import sqlite3 I receive the following error: Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 Traceback (most recent call last): File "", line 1, in File "C:\Program Files\Python39\lib\sqlite3\__init__.py", line 23, in from sqlite3.dbapi2 import * File "C:\Program Files\Python39\lib\sqlite3\dbapi2.py", line 27, in from _sqlite3 import * ImportError: DLL load failed while importing _sqlite3: The specified module could not be found. I verified that the sqlite3.dll file does exist in C:\Program Files\Python39\DLLs ---------- messages: 386832 nosy: ZenSkunkworx priority: normal severity: normal status: open title: sqlite3 import * ImportError: DLL load failed while importing _sqlite3: The specified module could not be found. type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 11 16:06:56 2021 From: report at bugs.python.org (Terry J. Reedy) Date: Thu, 11 Feb 2021 21:06:56 +0000 Subject: [New-bugs-announce] [issue43202] Cleanup codeop._maybe_compile Message-ID: <1613077616.54.0.579438220954.issue43202@roundup.psfhosted.org> New submission from Terry J. Reedy : Following-up on discussion in #43163 and PR-24483, this issue is limited to changes that are expected to not affect the return value. Therefore, do not backport unless and until needed as part of a bugfix. First is moving the code return to immediately after it is successfully created. Everything done after is ignored and useless. This move makes the function return sooner and renders initialization of 'code' unnecessary. ---------- assignee: terry.reedy components: Library (Lib) messages: 386836 nosy: terry.reedy priority: normal severity: normal stage: needs patch status: open title: Cleanup codeop._maybe_compile type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 11 19:42:30 2021 From: report at bugs.python.org (Samuel Marks) Date: Fri, 12 Feb 2021 00:42:30 +0000 Subject: [New-bugs-announce] [issue43203] Default value incorrectly read with unittests on Windows & macOS but not Linux Message-ID: <1613090550.2.0.513992790523.issue43203@roundup.psfhosted.org> New submission from Samuel Marks : Had a couple of commits to try and fix it on GitHub Actions (as I was unable to replicate locally), ended up with this very easy fix for Windows: https://github.com/SamuelMarks/doctrans/commit/98203e9fee3e0a888ab1f4128011dde5fad98f63 To completely remove the default value. The only thing I can assume happened is that a different test in the same class?which set the default value to something else?changed the default value of the function. This was all very confusing, and I can only think it to be a bug on python, or in GitHub Actions deployment thereof. PS: The macOS builds are still failing with the previous issue :\ ---------- components: Windows, macOS messages: 386845 nosy: ned.deily, paul.moore, ronaldoussoren, samuelmarks, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Default value incorrectly read with unittests on Windows & macOS but not Linux versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 05:27:23 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 12 Feb 2021 10:27:23 +0000 Subject: [New-bugs-announce] [issue43204] Fix LibTom URL's in hashlib comments Message-ID: <1613125643.6.0.405533024429.issue43204@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : The comments in Modules/md5module.c, Modules/sha1module.c, Modules/sha256module.c, and Modules/sha512module.c all point to http://libtom.org. However the LibTom website has in fairly recent years been relaunched at https://libtom.net. The old URL is now used by a blog called "Libations Tom" and has no connection to LibTomCrypt. ---------- components: Library (Lib) messages: 386854 nosy: christian.heimes, erlendaasland priority: normal severity: normal status: open title: Fix LibTom URL's in hashlib comments versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 06:28:24 2021 From: report at bugs.python.org (Mr Johnson) Date: Fri, 12 Feb 2021 11:28:24 +0000 Subject: [New-bugs-announce] [issue43205] Python Turtle Colour Message-ID: <1613129304.56.0.0860365755934.issue43205@roundup.psfhosted.org> New submission from Mr Johnson : An incredibly small annoyance, but as a teacher in the UK, using the Turtle library to teach students how to code, I spend more time explaining that they should use "color" instead of "colour" then actually teaching them coding! Would it be possible to add a duplicated function to each "color" function in the python turtle that uses the UK spelling, "colour"? They would behave exactly the same, you could have the "colour" functions just call the "color" function, it would just save a lot of hassle in class! ---------- components: Demos and Tools messages: 386858 nosy: Johnson.S priority: normal severity: normal status: open title: Python Turtle Colour type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 08:30:29 2021 From: report at bugs.python.org (Abhilash Jindal) Date: Fri, 12 Feb 2021 13:30:29 +0000 Subject: [New-bugs-announce] [issue43206] Optional parameter got passed even when not in the call Message-ID: <1613136629.64.0.932416781552.issue43206@roundup.psfhosted.org> New submission from Abhilash Jindal : Seeing a very unexpected behavior. A call to __init__ method is receiving extra arguments not present in the caller. Following is a debugger session to demonstrate. Notice that "data_dict" is not being passed in the caller, yet the callee is receiving it! ```python (Pdb) bt /Users/apple/Library/Python/3.8/bin/celery(10)() -> sys.exit(main()) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/__main__.py(15)main() -> sys.exit(_main()) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/bin/celery.py(213)main() -> return celery(auto_envvar_prefix="CELERY") /Users/apple/Library/Python/3.8/lib/python/site-packages/click/core.py(829)__call__() -> return self.main(*args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/click/core.py(782)main() -> rv = self.invoke(ctx) /Users/apple/Library/Python/3.8/lib/python/site-packages/click/core.py(1259)invoke() -> return _process_result(sub_ctx.command.invoke(sub_ctx)) /Users/apple/Library/Python/3.8/lib/python/site-packages/click/core.py(1066)invoke() -> return ctx.invoke(self.callback, **ctx.params) /Users/apple/Library/Python/3.8/lib/python/site-packages/click/core.py(610)invoke() -> return callback(*args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/click/decorators.py(21)new_func() -> return f(get_current_context(), *args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/bin/base.py(132)caller() -> return f(ctx, *args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/bin/worker.py(327)worker() -> worker.start() /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/worker/worker.py(203)start() -> self.blueprint.start(self) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/bootsteps.py(116)start() -> step.start(parent) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/bootsteps.py(365)start() -> return self.obj.start() /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/concurrency/base.py(129)start() -> self.on_start() /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/concurrency/prefork.py(107)on_start() -> P = self._pool = Pool(processes=self.limit, /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/concurrency/asynpool.py(460)__init__() -> super().__init__(processes, *args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/pool.py(1046)__init__() -> self._create_worker_process(i) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/concurrency/asynpool.py(477)_create_worker_process() -> return super()._create_worker_process(i) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/pool.py(1158)_create_worker_process() -> w.start() /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/process.py(124)start() -> self._popen = self._Popen(self) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/context.py(333)_Popen() -> return Popen(process_obj) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/popen_fork.py(24)__init__() -> self._launch(process_obj) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/popen_fork.py(79)_launch() -> code = process_obj._bootstrap() /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/process.py(327)_bootstrap() -> self.run() /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/process.py(114)run() -> self._target(*self._args, **self._kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/pool.py(292)__call__() -> sys.exit(self.workloop(pid=pid)) /Users/apple/Library/Python/3.8/lib/python/site-packages/billiard/pool.py(362)workloop() -> result = (True, prepare_result(fun(*args, **kwargs))) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/app/trace.py(580)_trace_task_ret() -> R, I, T, Rstr = trace_task(app.tasks[name], /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/app/trace.py(536)trace_task() -> return task.__trace__(uuid, args, kwargs, request) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/app/trace.py(405)trace_task() -> R = retval = fun(*args, **kwargs) /Users/apple/Library/Python/3.8/lib/python/site-packages/celery/app/trace.py(697)__protected_call__() -> return self.run(*args, **kwargs) /Users/apple/Documents/research/hint/code/scope/core/nodes.py(23)process() -> processor(idx) /Users/apple/Documents/research/hint/code/scope/core/nodes.py(96)__call__() -> k = next(iter(self.named_in_edges)) > /Users/apple/Documents/research/hint/code/scope/examples/word_count.py(55)__call__() -> out_row = Row(node_name, self.schema, from_rows=[input_row]) /Users/apple/Documents/research/hint/code/scope/model/row.py(21)__init__() -> self.lnode_name = lnode_name (Pdb) l. 50 def __call__(self, input_row: Row, *args: Any, **kwargs: Any) -> Generator[Row, None, None]: 51 node_name = kwargs['node_name'] 52 line, _ = input_row.pget(self.in_col) 53 words = line.split(self.separator) 54 for word in words: 55 -> out_row = Row(node_name, self.schema, from_rows=[input_row]) 56 out_row.pset(self.out_col, word.strip(' \t\r\n,!?.')) 57 yield out_row 58 59 60 class LowerCase(Processor): (Pdb) d > /Users/apple/Documents/research/hint/code/scope/model/row.py(21)__init__() -> self.lnode_name = lnode_name (Pdb) l. 17 def __init__(self, lnode_name, schema, id = '*', data_dict = {}, read_only = False, from_rows = None): 18 # type(str, Schema, str, Dict[bytes, bytes], bool, List[Row]) 19 if lnode_name == 'processor-1': 20 from celery.contrib import rdb; rdb.set_trace() 21 -> self.lnode_name = lnode_name 22 self._schema = schema 23 self.id = id 24 self.data_dict = data_dict 25 26 self.parents = RowRelations(self, RelationType.PARENT) (Pdb) lnode_name 'processor-1' (Pdb) data_dict {b'line': b'When will you realize... Vienna waits for you?'} (Pdb) from_rows [] (Pdb) from_rows[0] (Pdb) id '*' (Pdb) read_only False (Pdb) ``` ---------- components: macOS messages: 386864 nosy: ajindal, ned.deily, ronaldoussoren priority: normal severity: normal status: open title: Optional parameter got passed even when not in the call type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 09:40:00 2021 From: report at bugs.python.org (Jun) Date: Fri, 12 Feb 2021 14:40:00 +0000 Subject: [New-bugs-announce] [issue43207] InspectLoader.is_package is not an abstract method Message-ID: <1613140800.67.0.306485673538.issue43207@roundup.psfhosted.org> New submission from Jun : In the documentation of importlib: https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader It says InspectLoader.is_package is an abstract method while it is not in the implementation. @abc.abstractmethod decorator was removed with this commit https://github.com/python/cpython/commit/b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00 ---------- assignee: docs at python components: Documentation messages: 386866 nosy: Jun, docs at python priority: normal severity: normal status: open title: InspectLoader.is_package is not an abstract method versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 09:44:57 2021 From: report at bugs.python.org (Thijs Miedema) Date: Fri, 12 Feb 2021 14:44:57 +0000 Subject: [New-bugs-announce] [issue43208] Ctypes._FuncPtr.restype doesn't handle NoneType correctly Message-ID: <1613141097.76.0.252191412274.issue43208@roundup.psfhosted.org> New submission from Thijs Miedema : When setting the restype of a ctypes._FuncPtr you can use None to indicate a void function. However, I use inspect.signature to dynamically bind python functions to a DLL, and that doesn't return None but NoneType if the type hint return type is None starting at python 3.10. This change caused me to set the restype to NoneType, which makes ctypes cause a cryptic "TypeError: NoneType takes no arguments" upon returning from a successfully executed C function. The included example demonstrates the differing results from inspect, a working example, a failing example and an example that works in 3.9 but fails in 3.10. Proposed solution: Treat NoneType as None for ctypes._FuncPtr.restype ---------- components: ctypes files: minimal_example_ctypes_nonetype_behaviour.py messages: 386867 nosy: thijsmiedema94 priority: normal severity: normal status: open title: Ctypes._FuncPtr.restype doesn't handle NoneType correctly type: behavior versions: Python 3.10 Added file: https://bugs.python.org/file49803/minimal_example_ctypes_nonetype_behaviour.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 14:33:14 2021 From: report at bugs.python.org (robert j richardson) Date: Fri, 12 Feb 2021 19:33:14 +0000 Subject: [New-bugs-announce] [issue43209] system cannot find the file specified in subprocess.py Message-ID: <1613158394.2.0.196076436453.issue43209@roundup.psfhosted.org> New submission from robert j richardson : When using >python synth.py in the directory google-api-java-client-services-master python returns: synthtool > Cloning https://github.com/googleapis/discovery-artifact-manager.git. synthtool > Cleaning output directory. Traceback (most recent call last): File "D:\google-api-java-client-services-master\synth.py", line 47, in shell.run("rm -rf .cache".split(), cwd=repository) File "C:\Users\rober\AppData\Local\Programs\Python\Python39\lib\site-packages\synthtool\shell.py", line 27, in run return subprocess.run( File "C:\Users\rober\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 501, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\rober\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\rober\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ---------- components: Windows messages: 386871 nosy: paul.moore, robertjrichardson, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: system cannot find the file specified in subprocess.py type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 14:45:59 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 12 Feb 2021 19:45:59 +0000 Subject: [New-bugs-announce] [issue43210] Fix inaccurate byteswap comment in sha512.module.c Message-ID: <1613159159.15.0.0115331421083.issue43210@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : Include/internal/pycore_bitutils.h is included bco. _Py_bswap64(), not _Py_bswap32(). ---------- components: Library (Lib) messages: 386873 nosy: christian.heimes, erlendaasland priority: normal severity: normal status: open title: Fix inaccurate byteswap comment in sha512.module.c versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 16:55:12 2021 From: report at bugs.python.org (Diasy Barrett) Date: Fri, 12 Feb 2021 21:55:12 +0000 Subject: [New-bugs-announce] [issue43211] Python is not responding after running program Message-ID: <1613166912.2.0.538494691419.issue43211@roundup.psfhosted.org> New submission from Diasy Barrett : Good day all I am very new to Python programming so forgive me. The Python application is not responding after I run my program. ---------- components: macOS files: Screen Shot 2021-02-12 at 23.55.56.png messages: 386882 nosy: diasybarrett, ned.deily, ronaldoussoren priority: normal severity: normal status: open title: Python is not responding after running program type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49804/Screen Shot 2021-02-12 at 23.55.56.png _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 18:09:53 2021 From: report at bugs.python.org (=?utf-8?b?0JHQvtGA0LjRgSDQktC10YDRhdC+0LLRgdC60LjQuQ==?=) Date: Fri, 12 Feb 2021 23:09:53 +0000 Subject: [New-bugs-announce] [issue43212] Link to class and function source code on GitHub Message-ID: <1613171393.51.0.627157963271.issue43212@roundup.psfhosted.org> New submission from ????? ?????????? : We can use shpinx.ext.linkcode to link classes and functions/methods to their source code on GitHub from the documentation. See linked PR for screen shots. This is far from linking all the symbols in the docs, but it's gets quite a few. It would be hard to get to 100% because of C modules that get re-exported in Python files. It slighty increase the time it takes to generate the documentation with `make html`. I get 1m33s with these changes vs 1m28s without them. One thing is that when you merge a PR on GitHub, any files it touches will have the wrong line numbers while the documentation is being re-built and deployed. That's mostly neglible since most files haven't been edited in the last couple of minutes, but if it's an issue it may be possible to set up the CI to build the documentation then deploy the docs and merge the PR at the same time. ---------- assignee: docs at python components: Documentation messages: 386889 nosy: boris, docs at python priority: normal pull_requests: 23306 severity: normal status: open title: Link to class and function source code on GitHub type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 12 23:44:50 2021 From: report at bugs.python.org (Tomas Gustavsson) Date: Sat, 13 Feb 2021 04:44:50 +0000 Subject: [New-bugs-announce] [issue43213] Shortcut for checking if PurePath object contains str Message-ID: <1613191490.46.0.373267052174.issue43213@roundup.psfhosted.org> New submission from Tomas Gustavsson : While using pathlib I realised there are situations where I easily want to check if part of a returned path object contains a particular given path (as a string). Today the following will give an error: ... path = PosixPath('/usr/share/doc/') if 'share' in path: ....print('Do something') The patch will make the example above work and will open up for a simple shortcut. This is my first attempt to contribute, all opinions are very welcome. I have also pushed the commit to my own branch https://github.com/tomplast/cpython/tree/implement-path-contains. ---------- components: Library (Lib) messages: 386904 nosy: tomplast priority: normal severity: normal status: open title: Shortcut for checking if PurePath object contains str versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 13 03:53:26 2021 From: report at bugs.python.org (Inada Naoki) Date: Sat, 13 Feb 2021 08:53:26 +0000 Subject: [New-bugs-announce] [issue43214] site: Potential UnicodeDecodeError when handling pth file Message-ID: <1613206406.27.0.848192620201.issue43214@roundup.psfhosted.org> New submission from Inada Naoki : https://github.com/python/cpython/blob/4230bd52e3f9f289f02e41ab17a95f50ed4db5a6/Lib/site.py#L160 ``` f = io.TextIOWrapper(io.open_code(fullname)) ``` When default text encoding is not UTF-8 and pth file contains non-ASCII character, it will raise UnicodeDecodeError. ---------- components: Library (Lib) keywords: 3.8regression messages: 386916 nosy: methane priority: normal severity: normal status: open title: site: Potential UnicodeDecodeError when handling pth file type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 13 10:16:36 2021 From: report at bugs.python.org (Illia Volochii) Date: Sat, 13 Feb 2021 15:16:36 +0000 Subject: [New-bugs-announce] [issue43215] Document Happy Eyeballs arguments of asyncio.open_connection Message-ID: <1613229396.78.0.230354163599.issue43215@roundup.psfhosted.org> New submission from Illia Volochii : The problem is similar to https://bugs.python.org/issue39128. It is not documented that asyncio.open_connection accepts happy_eyeballs_delay and interleave that are passed to loop.create_connection. https://docs.python.org/3/library/asyncio-stream.html#asyncio.open_connection ---------- assignee: docs at python components: Documentation, asyncio messages: 386926 nosy: asvetlov, docs at python, illia-v, yselivanov priority: normal severity: normal status: open title: Document Happy Eyeballs arguments of asyncio.open_connection type: enhancement versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 13 11:47:55 2021 From: report at bugs.python.org (Illia Volochii) Date: Sat, 13 Feb 2021 16:47:55 +0000 Subject: [New-bugs-announce] [issue43216] Removal of @asyncio.coroutine in Python 3.10 Message-ID: <1613234875.25.0.783359316655.issue43216@roundup.psfhosted.org> New submission from Illia Volochii : It looks like @asyncio.coroutine was scheduled to be removed in Python 3.10. Is it still relevant? https://bugs.python.org/issue36921 https://docs.python.org/3.10/library/asyncio-task.html#asyncio.coroutine ---------- components: asyncio messages: 386927 nosy: asvetlov, illia-v, yselivanov priority: normal severity: normal status: open title: Removal of @asyncio.coroutine in Python 3.10 versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 13 19:43:47 2021 From: report at bugs.python.org (misianne) Date: Sun, 14 Feb 2021 00:43:47 +0000 Subject: [New-bugs-announce] [issue43217] tkinter style map return value in alt theme Message-ID: <1613263427.18.0.457810123469.issue43217@roundup.psfhosted.org> New submission from misianne : The return value for ttk.style().map('Treeview') is wrong for the 'background' value in the 'alt' theme: tuple are missing. Tcl alt Treeview map: -foreground {disabled #a3a3a3 {!disabled !selected} black selected #ffffff} -background {disabled #d9d9d9 {!disabled !selected} #ffffff selected #4a6984} tkinter alt Treeview map: { 'foreground': [('disabled', '#a3a3a3'), ('!disabled', '!selected', 'black'), ('selected', '#ffffff')], 'background': ['disabled', '#d9d9d9', '!disabled !selected', '#ffffff', 'selected', '#4a6984'] } It should be: 'background': [('disabled', '#d9d9d9'), ('!disabled !selected', '#ffffff'), ('selected', '#4a6984')] ---------- components: Tkinter messages: 386930 nosy: misianne priority: normal severity: normal status: open title: tkinter style map return value in alt theme type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 13 23:36:16 2021 From: report at bugs.python.org (Neel Gore) Date: Sun, 14 Feb 2021 04:36:16 +0000 Subject: [New-bugs-announce] [issue43218] after venv activation "which python3" and sys.path both give base installation instead of venv Message-ID: <1613277376.58.0.951553755579.issue43218@roundup.psfhosted.org> New submission from Neel Gore : Fresh python 3.9.1 installation on macOS, shell is zsh activated a venv with "python3 -m venv .venv" activated with "source .venv/bin./activate" "which python3" and "which pip3" both show my base installation ---------- components: macOS files: Screen Shot 2021-02-13 at 8.31.20 PM.png messages: 386931 nosy: ned.deily, neeltennis, ronaldoussoren priority: normal severity: normal status: open title: after venv activation "which python3" and sys.path both give base installation instead of venv type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49807/Screen Shot 2021-02-13 at 8.31.20 PM.png _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 00:16:28 2021 From: report at bugs.python.org (Jeremy Pinto) Date: Sun, 14 Feb 2021 05:16:28 +0000 Subject: [New-bugs-announce] [issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist Message-ID: <1613279788.4.0.734801709372.issue43219@roundup.psfhosted.org> New submission from Jeremy Pinto : Issue: If you try to copy a file to a directory that doesn't exist using shutil.copy, a IsADirectory error is raised saying the directory exists. This issue is actually caused when `open(not_a_dir, 'wb') is called on a non-existing dir. Expected behaviour: Should instead raise NotADirectoryError ----------------------------- Steps to reproduce: [nav] In [1]: import os ...: from pathlib import Path ...: from shutil import copy ...: ...: tmp_file = '/tmp/some_file.txt' ...: Path(tmp_file).touch() ...: nonexistent_dir = 'not_a_dir/' ...: assert not os.path.exists(nonexistent_dir) ...: copy(tmp_file, nonexistent_dir) --------------------------------------------------------------------------- IsADirectoryError Traceback (most recent call last) in 7 nonexistent_dir = 'not_a_dir/' 8 assert not os.path.exists(nonexistent_dir) ----> 9 copy(tmp_file, nonexistent_dir) ~/miniconda3/lib/python3.7/shutil.py in copy(src, dst, follow_symlinks) 243 if os.path.isdir(dst): 244 dst = os.path.join(dst, os.path.basename(src)) --> 245 copyfile(src, dst, follow_symlinks=follow_symlinks) 246 copymode(src, dst, follow_symlinks=follow_symlinks) 247 return dst ~/miniconda3/lib/python3.7/shutil.py in copyfile(src, dst, follow_symlinks) 119 else: 120 with open(src, 'rb') as fsrc: --> 121 with open(dst, 'wb') as fdst: 122 copyfileobj(fsrc, fdst) 123 return dst IsADirectoryError: [Errno 21] Is a directory: 'not_a_dir/' ---------- messages: 386932 nosy: jerpint priority: normal severity: normal status: open title: shutil.copy raises IsADirectoryError when the directory does not actually exist versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 01:34:45 2021 From: report at bugs.python.org (Keith Smiley) Date: Sun, 14 Feb 2021 06:34:45 +0000 Subject: [New-bugs-announce] [issue43220] Explicit default required arguments with add_mutually_exclusive_group are rejected Message-ID: <1613284485.11.0.495534943099.issue43220@roundup.psfhosted.org> New submission from Keith Smiley : With this code: ``` import argparse parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group(required=True) group.add_argument("--foo", default="1") group.add_argument("--bar") args = parser.parse_args() print(args) ``` When you explicitly pass `--foo 1`, it is treated as if no argument was passed: ``` % python3 /tmp/bug.py --foo 1 usage: bug.py [-h] (--foo FOO | --bar BAR) bug.py: error: one of the arguments --foo --bar is required ``` I can't tell if this behavior is intentional, but it was surprising to me. It also seems to be somewhat based on the length of the default string. For example on my macOS machine if I change the default to `longerstring` it does not have this issue. ---------- components: Library (Lib) messages: 386934 nosy: keith priority: normal severity: normal status: open title: Explicit default required arguments with add_mutually_exclusive_group are rejected versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 02:03:40 2021 From: report at bugs.python.org (Max Parry) Date: Sun, 14 Feb 2021 07:03:40 +0000 Subject: [New-bugs-announce] [issue43221] German Text Conversion Using Upper() and Lower() Message-ID: <1613286220.83.0.234888054811.issue43221@roundup.psfhosted.org> New submission from Max Parry : The German alphabet has four extra characters (?, ?, ? and ?) when compared to the UK/USA alphabet. Until 2017 the character ? was normally only lower case. Upper case ? was represented by SS. In 2017 upper case ? was introduced, although SS is still often/usually used instead. It is important to note that, as far as I can see, upper case ? and lower case ? are identical. The upper() method converts upper or lower case ? to SS. N.B. ?, ? and ? are handled correctly. Lower() seems to work correctly. Please note that German is my second language and everything I say about the language, its history and its use might not be reliable. Happy to be corrected. ---------- components: Windows messages: 386938 nosy: Strongbow, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: German Text Conversion Using Upper() and Lower() type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 03:17:10 2021 From: report at bugs.python.org (Philip) Date: Sun, 14 Feb 2021 08:17:10 +0000 Subject: [New-bugs-announce] [issue43222] Regular expression split fails on 3.6 and not 2.7 or 3.7+ Message-ID: <1613290630.55.0.329403737317.issue43222@roundup.psfhosted.org> New submission from Philip : I am receiving an unexpected behavior in using regular expressions for splitting a string. It seems like this error exists in `python 3.6` but not `python 2.7` and not `python 3.7+`. Below I have described a minimal example with `tox`. `setup.py` ``` from setuptools import setup setup( name='my-tox-tested-package', version='0.0.1', install_requires=["pytest"] ) ``` `tests/test_re.py` ``` import re import pytest _DIGIT_BOUNDARY_RE = re.compile( r'(?<=\D)(?=\d)|(?<=\d)(?=\D)' ) def test(): _DIGIT_BOUNDARY_RE.split("10.0.0") ``` `tox.ini` ``` [tox] envlist = py27, py36, py37 requires= pytest [testenv] commands = pytest {posargs: tests} ``` ``` ============================================= FAILURES ================================ _____________________________________________ test ____________________________________ def test(): > _DIGIT_BOUNDARY_RE.split("10.0.0") E ValueError: split() requires a non-empty pattern match. tests/test_god.py:9: ValueError ============================================ short test summary info ================== ... ============================================ test session starts ====================== platform linux -- Python 3.7.5, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: /home/probinson/code collected 1 item tests/test_re.py . [100%] ============================================ 1 passed in 0.00s ========================= ____________________________________________ summary ___________________________________ py27: commands succeeded ERROR: py36: commands failed py37: commands succeeded ``` ---------- components: Regular Expressions messages: 386942 nosy: ezio.melotti, mrabarnett, probinso priority: normal severity: normal status: open title: Regular expression split fails on 3.6 and not 2.7 or 3.7+ type: crash versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 06:42:36 2021 From: report at bugs.python.org (Hamza AVvan) Date: Sun, 14 Feb 2021 11:42:36 +0000 Subject: [New-bugs-announce] [issue43223] Open Redirection In Python 3.7 & 3.8 Message-ID: <1613302956.91.0.878390782912.issue43223@roundup.psfhosted.org> New submission from Hamza AVvan : The provided version of python distros 3.8.7 and 3.7.4 are vulnerable to open redirection while traversing to an existing directory. # PAYLOAD http://127.0.0.1:8000//attacker.com/..%2f..%2f..%2f..%2f..%2f../%0a%0d/../.ssh In this case, the actual path of .ssh was: http://127.0.0.1:8000/.ssh Upon visiting the payload URI the python server will respond back with a Location header instead of serving the directory contents directly which triggers the redirection to attacker.com Server: SimpleHTTP/0.6 Python/3.8.7 ---------- components: Windows files: Capture.PNG messages: 386945 nosy: hamzaavvan, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Open Redirection In Python 3.7 & 3.8 type: security versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file49808/Capture.PNG _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 12:21:47 2021 From: report at bugs.python.org (Matthew Rahtz) Date: Sun, 14 Feb 2021 17:21:47 +0000 Subject: [New-bugs-announce] [issue43224] Add support for PEP 646 (Variadic Generics) to typing.py Message-ID: <1613323307.22.0.4954496456.issue43224@roundup.psfhosted.org> Change by Matthew Rahtz : ---------- components: Library (Lib) nosy: mrahtz priority: normal severity: normal status: open title: Add support for PEP 646 (Variadic Generics) to typing.py versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 15:46:13 2021 From: report at bugs.python.org (Emmanuel Arias) Date: Sun, 14 Feb 2021 20:46:13 +0000 Subject: [New-bugs-announce] [issue43225] Add missing value returned by methods on cookiejar Message-ID: <1613335573.68.0.765301079654.issue43225@roundup.psfhosted.org> New submission from Emmanuel Arias : Documentation say that return something but don't specific what value is returned, and that can be confuse. ---------- assignee: docs at python components: Documentation messages: 386961 nosy: docs at python, eamanu priority: normal severity: normal status: open title: Add missing value returned by methods on cookiejar type: enhancement versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 17:40:09 2021 From: report at bugs.python.org (DoctorDan) Date: Sun, 14 Feb 2021 22:40:09 +0000 Subject: [New-bugs-announce] [issue43226] build from 3.9.1 tarball on WSL failed Message-ID: <1613342409.04.0.51116148793.issue43226@roundup.psfhosted.org> New submission from DoctorDan : Attempted to build 3.9.1 on WSL from tarball Python-3.9.1.tar.xz Make - succeeded Make test - Many tests failed Make install - failed Attaching the tail end of the console trace. The scrollback buffer was not big enough to accomodate the whole thing. If there is a log file I don't know where it is. ---------- components: Build files: tail of make test log.txt messages: 386967 nosy: DoctorDan priority: normal severity: normal status: open title: build from 3.9.1 tarball on WSL failed type: compile error versions: Python 3.9 Added file: https://bugs.python.org/file49809/tail of make test log.txt _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 14 19:52:28 2021 From: report at bugs.python.org (Thomas Nabelek) Date: Mon, 15 Feb 2021 00:52:28 +0000 Subject: [New-bugs-announce] [issue43227] Backslashes in function arguments in f-string expressions Message-ID: <1613350348.46.0.298135234419.issue43227@roundup.psfhosted.org> New submission from Thomas Nabelek : >From https://www.python.org/dev/peps/pep-0498/#escape-sequences: "Backslashes may not appear inside the expression portions of f-strings" Is this supposed to be true even for arguments to functions inside of the expression? my_str = "test\ test\ test" path = f"{my_str.replace(r'\ ', ' ')}" gives my_str = "test\ test\ test" path = f"{my_str.replace(r'\ ', ' ')}" SyntaxError: f-string expression part cannot include a backslash ---------- messages: 386978 nosy: nabelekt priority: normal severity: normal status: open title: Backslashes in function arguments in f-string expressions type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 08:43:15 2021 From: report at bugs.python.org (STINNER Victor) Date: Mon, 15 Feb 2021 13:43:15 +0000 Subject: [New-bugs-announce] [issue43228] Regression in function builtins Message-ID: <1613396595.98.0.792771642012.issue43228@roundup.psfhosted.org> New submission from STINNER Victor : The bpo-42990 introduced a regression with the following commit: commit d6c33fbd346765c6a8654dccacb2338006bf2b47 Author: Mark Shannon Date: Fri Jan 29 13:24:55 2021 +0000 bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends (GH-24298) * Introduce 'frame constructor' to simplify API for frame creation * Embed struct using a macro to conform to PEP 7 The commit adds a new PyFunctionObject.func_builtins member which is not constructed properly in the following code. The reproduce the issue, use attached cloudpickle_bug.py reproducer: ./python -m venv env ./env/bin/python -m pip install cloudpickle ./env/bin/python cloudpickle_bug.py Current output: --- 3 Traceback (most recent call last): File "/home/vstinner/python/master/cloudpickle_bug.py", line 10, in print(func2(text)) File "/home/vstinner/python/master/cloudpickle_bug.py", line -1, in func NameError: name 'len' is not defined --- Output before this commit: --- 3 3 --- pickle.loads() calls PyFunction_NewWithQualName() with globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}. In that case, _PyEval_BuiltinsFromGlobals() creates the {'None': None} builtin dictionary and stores it in PyFunctionObject.func_builtins. => func2 builtins is {'None': None} Before the commit, calling func2() got the builtins dictionary from frame_get_builtins(PyFrameObject *back, PyObject *globals). Now it's get from the PyFunctionObject.func_builtins member which is not initialized properly. If you want to see where PyFunction_NewWithQualName() is called, you can put a break point in _PyEval_BuiltinsFromGlobals(), at the code path creating the {'None': None} dictionary. vstinner at apu$ gdb -args ./env/bin/python -i cloudpickle_bug.py (...) (gdb) b frameobject.c:1190 Breakpoint 1 at 0x6543fa: file Objects/frameobject.c, line 1190. (gdb) run (...) 3 Breakpoint 1, _PyEval_BuiltinsFromGlobals (globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}) at Objects/frameobject.c:1190 1190 builtins = PyDict_New(); (gdb) where #0 _PyEval_BuiltinsFromGlobals (globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}) at Objects/frameobject.c:1190 #1 0x0000000000444191 in PyFunction_NewWithQualName (code=, globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, qualname=0x0) at Objects/funcobject.c:47 #2 0x0000000000444314 in PyFunction_New (code=, globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}) at Objects/funcobject.c:87 #3 0x0000000000445707 in func_new_impl (type=0x850300 , code=0x7fffea3db2b0, globals={'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, name=None, defaults=None, closure=None) at Objects/funcobject.c:576 #4 0x000000000044542b in func_new (type=0x850300 , args=(, {'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, None, None, None), kwargs=0x0) at Objects/clinic/funcobject.c.h:73 #5 0x0000000000490f4a in type_call (type=0x850300 , args=(, {'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, None, None, None), kwds=0x0) at Objects/typeobject.c:1039 #6 0x0000000000431332 in _PyObject_Call (tstate=0x8a0030, callable=, args=(, {'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, None, None, None), kwargs=0x0) at Objects/call.c:305 #7 0x00000000004316ab in PyObject_CallObject (callable=, args=(, {'__package__': None, '__name__': '__main__', '__file__': '/home/vstinner/python/master/cloudpickle_bug.py'}, None, None, None)) at Objects/call.c:399 #8 0x00007fffea4fdcc8 in load_reduce (self=0x7fffea5c8b90) at /home/vstinner/python/master/Modules/_pickle.c:6785 #9 0x00007fffea4fe743 in load (self=0x7fffea5c8b90) at /home/vstinner/python/master/Modules/_pickle.c:6933 #10 0x00007fffea50015a in _pickle_loads_impl (module=, data=b'\x80\x05\x95\xdf\x01\x00\x00\x00\x00\x00\x00\x8c\x17cloudpickle.cloudpickle\x94\x8c\r_builtin_type\x94\x93\x94\x8c\nLambdaType\x94\x85\x94R\x94(h\x02\x8c\x08CodeType\x94\x85\x94R\x94(K\x01K\x00K\x00K\x01K\x02KCC\x08t\x00|\x00\x83\x01S\x00\x94N\x85\x94\x8c\x03len\x94\x85\x94\x8c\x01s\x94\x85\x94\x8c//home/vstinner/python/master/cloudpickle_bug.py\x94\x8c\x04func\x94K\x04C\x02\x00\x01\x94))t\x94R\x94}\x94(\x8c\x0b__package__\x94N\x8c\x08__name__\x94\x8c\x08__main__\x94\x8c\x08__file__\x94h\x0fuNNNt\x94R\x94\x8c\x1ccloudpickle.cloudpickle_fast\x94\x8c\x12_function_setstate\x94\x93\x94h\x1a}\x94}\x94(h\x16h\x10\x8c\x0c__qualname__\x94h\x10\x8c\x0f__annotations__\x94}\x94\x8c\x0e__kwdefaults__\x94N\x8c\x0c__defaults__\x94N\x8c\n__module__\x94h\x17\x8c\x07__doc__\x94N\x8c\x0b__closure__\x94N\x8c\x17_cloudpickle_submodules\x94]\x94\x8c\x0b__globals__\x94}\x94u\x86\x94\x86R0.', fix_imports=1, encoding=0x7fffea502473 "ASCII", errors=0x7fffea502479 "strict", buffers=0x0) (...) (gdb) py-bt Traceback (most recent call first): File "/home/vstinner/python/master/cloudpickle_bug.py", line 9, in func2 = pickle.loads(cloudpickle.dumps(func)) ---------- components: Interpreter Core files: cloudpickle_bug.py messages: 387011 nosy: Mark.Shannon, vstinner priority: normal severity: normal status: open title: Regression in function builtins versions: Python 3.10 Added file: https://bugs.python.org/file49810/cloudpickle_bug.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 09:36:35 2021 From: report at bugs.python.org (Christian Bachmaier) Date: Mon, 15 Feb 2021 14:36:35 +0000 Subject: [New-bugs-announce] [issue43229] freeze searches libpython3.9.so in /usr/lib instead /usr/lib/x86_64-linux-gnu Message-ID: <1613399795.84.0.430887747566.issue43229@roundup.psfhosted.org> New submission from Christian Bachmaier : Now that the patch from issue 42591 (https://bugs.python.org/issue42591), i.e., msg383154 from 12/16/20 has made it to Ubuntu 20.04 with packet version python3.9.1-1, there show some problems with that. I did: > freeze/freeze.py -o frozen helloworld.py > cd frozen > make This delivers a linker error ...xml__parsers.o M_xml__parsers__expat.o M_xml__sax.o M_xml__sax___exceptions.o M_xml__sax__expatreader.o M_xml__sax__handler.o M_xml__sax__saxutils.o M_xml__sax__xmlreader.o M_xmlrpc.o M_xmlrpc__client.o M_zipfile.o M_zipimport.o /usr/lib/libpython3.9.so -lexpat -L/usr/lib -lz -lexpat -lcrypt -lpthread -ldl -lutil -lm -lm -o helloworld x86_64-linux-gnu-gcc: error: /usr/lib/libpython3.9.so: No such file or directory make: *** [Makefile:1234: helloworld] Error 1 The linker searches libpython3.9 in /usr/lib instead in /usr/lib/x86_64-linux-gnu . The "hot-fix" > ln -s /usr/lib/x86_64-linux-gnu/libpython3.9.so /usr/lib/libpython3.9.so fixes that, but brings another error: > freeze/freeze.py -o frozen helloworld.py > cd frozen > make ...xml__parsers.o M_xml__parsers__expat.o M_xml__sax.o M_xml__sax___exceptions.o M_xml__sax__expatreader.o M_xml__sax__handler.o M_xml__sax__saxutils.o M_xml__sax__xmlreader.o M_xmlrpc.o M_xmlrpc__client.o M_zipfile.o M_zipimport.o /usr/lib/libpython3.9.so -lexpat -L/usr/lib -lz -lexpat -lcrypt -lpthread -ldl -lutil -lm -lm -o helloworld /usr/bin/ld: config.o:(.data.rel+0x278): undefined reference to `PyInit_lazr' collect2: error: ld returned 1 exit status make: *** [Makefile:1234: helloworld] Error 1 @Victor: I know there are alternatives to freeze, however, I have to keep a larger legacy project running, and I am not that expert. Maybe you could have a look on the above. ---------- components: Library (Lib) messages: 387015 nosy: chba priority: normal severity: normal status: open title: freeze searches libpython3.9.so in /usr/lib instead /usr/lib/x86_64-linux-gnu versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 12:33:54 2021 From: report at bugs.python.org (NKID00) Date: Mon, 15 Feb 2021 17:33:54 +0000 Subject: [New-bugs-announce] [issue43230] typo in Simplified/Traditional Chinese documentation for library argparse Message-ID: <1613410434.09.0.36699009827.issue43230@roundup.psfhosted.org> New submission from NKID00 : For Simplified Chinese(https://docs.python.org/zh-cn/3/library/argparse.html#description): "??" should probably be replaced by "??". ????????????????????? -> ????????????????????? For Traditional Chinese(https://docs.python.org/zh-tw/3/library/argparse.html#description): "??" should probably be replaced by "??". ????????????????????? -> ????????????????????? ---------- assignee: docs at python components: Documentation messages: 387031 nosy: NKID00, docs at python priority: normal severity: normal status: open title: typo in Simplified/Traditional Chinese documentation for library argparse type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 13:46:05 2021 From: report at bugs.python.org (Pablo Galindo Salgado) Date: Mon, 15 Feb 2021 18:46:05 +0000 Subject: [New-bugs-announce] [issue43231] test.test_curses.TestCurses.test_init_pair fails in s390x Fedora Message-ID: <1613414765.81.0.929791182409.issue43231@roundup.psfhosted.org> New submission from Pablo Galindo Salgado : https://buildbot.python.org/all/#/builders/433/builds/181/steps/5/logs/stdio ====================================================================== ERROR: test_init_pair (test.test_curses.TestCurses) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_curses.py", line 47, in wrapped test(self, *args, **kwargs) File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.refleak/build/Lib/test/test_curses.py", line 959, in test_init_pair curses.init_pair(maxpair, 0, 0) ValueError: Color pair is greater than COLOR_PAIRS-1 (65535). ---------------------------------------------------------------------- ---------- messages: 387042 nosy: pablogsal, serhiy.storchaka priority: normal severity: normal status: open title: test.test_curses.TestCurses.test_init_pair fails in s390x Fedora _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 14:16:49 2021 From: report at bugs.python.org (Illia Volochii) Date: Mon, 15 Feb 2021 19:16:49 +0000 Subject: [New-bugs-announce] [issue43232] Prohibit previously deprecated operations on asyncio.trsock.TransportSocket Message-ID: <1613416609.25.0.407610615564.issue43232@roundup.psfhosted.org> New submission from Illia Volochii : https://github.com/python/cpython/blob/a2f0654b0a5b4c4f726155620002cc1f5f2d206a/Lib/asyncio/trsock.py#L19-L24 Using of the operations was supposed to be prohibited in Python 3.9, but that was missed. ---------- components: asyncio messages: 387044 nosy: asvetlov, illia-v, yselivanov priority: normal severity: normal status: open title: Prohibit previously deprecated operations on asyncio.trsock.TransportSocket versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 14:26:10 2021 From: report at bugs.python.org (Pablo Galindo Salgado) Date: Mon, 15 Feb 2021 19:26:10 +0000 Subject: [New-bugs-announce] [issue43233] test_copy_file_range_offset fails on AMD64 FreeBSD Shared 3.9 Message-ID: <1613417170.64.0.402539389952.issue43233@roundup.psfhosted.org> New submission from Pablo Galindo Salgado : ====================================================================== FAIL: test_copy_file_range_offset (test.test_os.FileTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/home/buildbot/python/3.9.koobs-freebsd-564d/build/Lib/test/test_os.py", line 365, in test_copy_file_range_offset self.assertIn(i, range(0, bytes_to_copy+1)); AssertionError: 7 not found in range(0, 7) ---------------------------------------------------------------------- https://buildbot.python.org/all/#/builders/151/builds/300/steps/5/logs/stdio ---------- messages: 387046 nosy: koobs, lukasz.langa, pablogsal, vstinner priority: normal severity: normal status: open title: test_copy_file_range_offset fails on AMD64 FreeBSD Shared 3.9 versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 15:11:41 2021 From: report at bugs.python.org (Illia Volochii) Date: Mon, 15 Feb 2021 20:11:41 +0000 Subject: [New-bugs-announce] [issue43234] Prohibit passing non-ThreadPoolExecutor executors to loop.set_default_executor following a deprecation Message-ID: <1613419901.25.0.801383845086.issue43234@roundup.psfhosted.org> New submission from Illia Volochii : https://github.com/python/cpython/blob/a2f0654b0a5b4c4f726155620002cc1f5f2d206a/Lib/asyncio/base_events.py#L816-L821 Setting non-ThreadPoolExecutor executors was supposed to be prohibited in Python 3.9. ---------- components: asyncio messages: 387052 nosy: asvetlov, illia-v, yselivanov priority: normal severity: normal status: open title: Prohibit passing non-ThreadPoolExecutor executors to loop.set_default_executor following a deprecation versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 19:13:30 2021 From: report at bugs.python.org (STINNER Victor) Date: Tue, 16 Feb 2021 00:13:30 +0000 Subject: [New-bugs-announce] [issue43235] Tools/scripts/stable_abi.py should also check PC/python3dll.c (Windows stable ABI) Message-ID: <1613434410.7.0.341389987333.issue43235@roundup.psfhosted.org> New submission from STINNER Victor : bpo-43155 is just yet another example that we always forget to export symbols of the stable ABI on Windows. It would be great to have a tool to check that all symbols exported on Unix are also exported on Windows. Tools/scripts/stable_abi.py could check PC/python3dll.c (Windows stable ABI). For example, currently "PyCMethod_New" symbol is in Doc/data/stable_abi.dat but miss in PC/python3dll.c. ---------- components: C API messages: 387073 nosy: vstinner priority: normal severity: normal status: open title: Tools/scripts/stable_abi.py should also check PC/python3dll.c (Windows stable ABI) versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 20:53:24 2021 From: report at bugs.python.org (veganaiZe) Date: Tue, 16 Feb 2021 01:53:24 +0000 Subject: [New-bugs-announce] [issue43236] Windows Taskbar Jump List fails to open Recent files Message-ID: <1613440404.37.0.977304766317.issue43236@roundup.psfhosted.org> New submission from veganaiZe : OS: Windows 8.1 (x86-64) Python: 3.8.7 When I right-click on IDLE's rectangle/icon in the Windows taskbar it displays a "jump list" which contains recent/pinned filenames. A program will typically open a file when it's selected from the list. IDLE doesn't open the file, nor does it switch to the corresponding editor window if the file is already open. It seems to ignore the selection entirely. If IDLE is going to display a "Recent" list, within the jump list, then it would be nice if it actually opened the file(s). ---------- assignee: terry.reedy components: IDLE files: jumplist.png messages: 387082 nosy: terry.reedy, veganaiZe priority: normal severity: normal status: open title: Windows Taskbar Jump List fails to open Recent files type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file49812/jumplist.png _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 15 23:52:32 2021 From: report at bugs.python.org (Richard Wise) Date: Tue, 16 Feb 2021 04:52:32 +0000 Subject: [New-bugs-announce] [issue43237] datetime.__eq__ returns true when timezones don't match Message-ID: <1613451152.5.0.28969611579.issue43237@roundup.psfhosted.org> New submission from Richard Wise : from datetime import datetime, timezone, timedelta datetime_in_sgt = datetime(2021, 2, 16, 8, 0, 0, tzinfo=timezone(timedelta(hours=8))) datetime_in_utc = datetime(2021, 2, 16, 0, 0, 0, tzinfo=timezone.utc) print(datetime_in_sgt == datetime_in_utc) Expected: False Actual: True Although these two datetimes represent the same instant on the timeline, they are not identical because they use different timezones. This means that when unit testing timezone handling, tests will incorrectly pass despite data being returned in UTC instead of the requested timezone, so we need to write code such as this: # Timestamp comparison self.assertEqual(datetime_in_sgt, datetime_in_utc) # Timezone comparison self.assertEqual(datetime_in_sgt.tzinfo, datetime_in_utc.tzinfo) This is confusing and non-intuitive. For examples of how other languages handle such comparison, can refer to: https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html#equals-java.lang.Object- and https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html#equals-java.lang.Object- ---------- components: Library (Lib) messages: 387087 nosy: Woodz priority: normal severity: normal status: open title: datetime.__eq__ returns true when timezones don't match versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 16 02:04:52 2021 From: report at bugs.python.org (Raghav Bhandari) Date: Tue, 16 Feb 2021 07:04:52 +0000 Subject: [New-bugs-announce] [issue43238] python picking garbage values randomly incase running palindrome function Message-ID: <1613459092.79.0.276117009371.issue43238@roundup.psfhosted.org> New submission from Raghav Bhandari : temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python3 and revtemp value is 3nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39 and revtemp value is 93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/ and revtemp value is /93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/p and revtemp value is p/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/py and revtemp value is yp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pyt and revtemp value is typ/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pyth and revtemp value is htyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pytho and revtemp value is ohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python and revtemp value is nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python. and revtemp value is .nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C &temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.e and revtemp value is e.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.ex and revtemp value is xe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe and revtemp value is exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe and revtemp value is exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c and revtemp value is c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c: and revtemp value is :c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/ and revtemp value is /:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/U and revtemp value is U/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Us and revtemp value is sU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Use and revtemp value is esU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/User and revtemp value is resU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users and revtemp value is sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/ and revtemp value is /sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/R and revtemp value is R/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ra and revtemp value is aR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Rag and revtemp value is gaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ragh and revtemp value is hgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ragha and revtemp value is ahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav and revtemp value is vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/ and revtemp value is /vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/D and revtemp value is D/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/De and revtemp value is eD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Des and revtemp value is seD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desk and revtemp value is kseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Deskt and revtemp value is tkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Deskto and revtemp value is otkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop and revtemp value is potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/ and revtemp value is /potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/t and revtemp value is t/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/te and revtemp value is et/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/tes and revtemp value is set/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/test and revtemp value is tset/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/test. and revtemp value is .tset/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/test.p and revtemp value is p.tset/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is & C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/test.py and revtemp value is yp.tset/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C & temp value is C and revtemp value is C temp value is C: and revtemp value is :C temp value is C:/ and revtemp value is /:C temp value is C:/U and revtemp value is U/:C temp value is C:/Us and revtemp value is sU/:C temp value is C:/Use and revtemp value is esU/:C temp value is C:/User and revtemp value is resU/:C temp value is C:/Users and revtemp value is sresU/:C temp value is C:/Users/ and revtemp value is /sresU/:C temp value is C:/Users/R and revtemp value is R/sresU/:C temp value is C:/Users/Ra and revtemp value is aR/sresU/:C temp value is C:/Users/Rag and revtemp value is gaR/sresU/:C temp value is C:/Users/Ragh and revtemp value is hgaR/sresU/:C temp value is C:/Users/Ragha and revtemp value is ahgaR/sresU/:C temp value is C:/Users/Raghav and revtemp value is vahgaR/sresU/:C temp value is C:/Users/Raghav/ and revtemp value is /vahgaR/sresU/:C temp value is C:/Users/Raghav/A and revtemp value is A/vahgaR/sresU/:C temp value is C:/Users/Raghav/Ap and revtemp value is pA/vahgaR/sresU/:C temp value is C:/Users/Raghav/App and revtemp value is ppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppD and revtemp value is DppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppDa and revtemp value is aDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppDat and revtemp value is taDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData and revtemp value is ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/ and revtemp value is /ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/L and revtemp value is L/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Lo and revtemp value is oL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Loc and revtemp value is coL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Loca and revtemp value is acoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local and revtemp value is lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/ and revtemp value is /lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/P and revtemp value is P/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Pr and revtemp value is rP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Pro and revtemp value is orP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Prog and revtemp value is gorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Progr and revtemp value is rgorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Progra and revtemp value is argorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Program and revtemp value is margorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs and revtemp value is smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/ and revtemp value is /smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/P and revtemp value is P/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Py and revtemp value is yP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Pyt and revtemp value is tyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Pyth and revtemp value is htyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Pytho and revtemp value is ohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python and revtemp value is nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/ and revtemp value is /nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/P and revtemp value is P/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Py and revtemp value is yP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Pyt and revtemp value is tyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Pyth and revtemp value is htyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Pytho and revtemp value is ohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python and revtemp value is nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python3 and revtemp value is 3nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39 and revtemp value is 93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/ and revtemp value is /93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/p and revtemp value is p/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/py and revtemp value is yp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pyt and revtemp value is typ/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pyth and revtemp value is htyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/pytho and revtemp value is ohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python and revtemp value is nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python. and revtemp value is .nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.e and revtemp value is e.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.ex and revtemp value is xe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe and revtemp value is exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe and revtemp value is exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c and revtemp value is c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c: and revtemp value is :c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/ and revtemp value is /:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/U and revtemp value is U/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Us and revtemp value is sU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Use and revtemp value is esU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/User and revtemp value is resU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users and revtemp value is sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/ and revtemp value is /sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/R and revtemp value is R/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ra and revtemp value is aR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Rag and revtemp value is gaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ragh and revtemp value is hgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Ragha and revtemp value is ahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav and revtemp value is vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/ and revtemp value is /vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/D and revtemp value is D/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/De and revtemp value is eD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Des and revtemp value is seD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desk and revtemp value is kseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Deskt and revtemp value is tkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Deskto and revtemp value is otkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop and revtemp value is potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/ and revtemp value is /potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/t and revtemp value is t/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C temp value is C:/Users/Raghav/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Raghav/Desktop/te and revtemp value is et/potkseD/vahgaR/sresU/:c exe.nohtyp/93nohtyP/nohtyP/smargorP/lacoL/ataDppA/vahgaR/sresU/:C ---------- components: Windows files: test.py messages: 387090 nosy: paul.moore, rv.raghav23, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: python picking garbage values randomly incase running palindrome function type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49813/test.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 16 11:07:52 2021 From: report at bugs.python.org (Petr Viktorin) Date: Tue, 16 Feb 2021 16:07:52 +0000 Subject: [New-bugs-announce] [issue43239] PyCFunction_New is not exported with PyAPI_FUNC Message-ID: <1613491672.14.0.339809223416.issue43239@roundup.psfhosted.org> New submission from Petr Viktorin : PyCFunction_New is part of the Stable ABI (see bpo-21354), but it is not declared as PyAPI_FUNC, and thus not exported with GCC's -fvisibility=hidden. To match Windows, it should be declared. (I don't think this has any real impact, I just want to fix it before enabling automatic tests on such issues.) ---------- assignee: petr.viktorin components: C API messages: 387119 nosy: petr.viktorin priority: normal severity: normal status: open title: PyCFunction_New is not exported with PyAPI_FUNC versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 16 13:37:48 2021 From: report at bugs.python.org (Alan Moore) Date: Tue, 16 Feb 2021 18:37:48 +0000 Subject: [New-bugs-announce] [issue43240] IDLE Classic Unix keyboard shortcuts broken Message-ID: <1613500668.98.0.749942466842.issue43240@roundup.psfhosted.org> New submission from Alan Moore : Using IDLE 3.9.1 on Arch Linux. In IDLE I've selected the "classic unix" key set. It worked for a while, then stopped registering key combinations for more than one key (e.g. Ctrl-x Ctrl-s). Have tried creating a custom key set and manually setting the shortcuts, but it still fails the same way. Caps lock is not on (disabled on my system). Have also tried moving configs and starting fresh, does not help. It had been working, then suddenly stopped in the middle of a work day and I can't get it working again. ---------- assignee: terry.reedy components: IDLE messages: 387124 nosy: Alan Moore, terry.reedy priority: normal severity: normal status: open title: IDLE Classic Unix keyboard shortcuts broken type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 07:37:44 2021 From: report at bugs.python.org (Xuehai Pan) Date: Wed, 17 Feb 2021 12:37:44 +0000 Subject: [New-bugs-announce] [issue43241] curses.h: present but cannot be compiled while building with custom CPPFLAGS Message-ID: <1613565464.32.0.197959355963.issue43241@roundup.psfhosted.org> New submission from Xuehai Pan : I install python3 with Linuxbrew. All header files have been symlinked to "~/.linuxbrew/inlcude". It raises warnings when I building with custom CPPFLAGS. ``` checking curses.h usability... no checking curses.h presence... yes configure: WARNING: curses.h: present but cannot be compiled configure: WARNING: curses.h: check for missing prerequisite headers? configure: WARNING: curses.h: see the Autoconf documentation configure: WARNING: curses.h: section "Present But Cannot Be Compiled" configure: WARNING: curses.h: proceeding with the compiler's result configure: WARNING: ## --------------------------------------- ## configure: WARNING: ## Report this to https://bugs.python.org/ ## configure: WARNING: ## --------------------------------------- ## checking for curses.h... no checking ncurses.h usability... no checking ncurses.h presence... yes configure: WARNING: ncurses.h: present but cannot be compiled configure: WARNING: ncurses.h: check for missing prerequisite headers? configure: WARNING: ncurses.h: see the Autoconf documentation configure: WARNING: ncurses.h: section "Present But Cannot Be Compiled" configure: WARNING: ncurses.h: proceeding with the compiler's result configure: WARNING: ## --------------------------------------- ## configure: WARNING: ## Report this to https://bugs.python.org/ ## configure: WARNING: ## --------------------------------------- ## checking for ncurses.h... no checking for term.h... yes ``` See https://github.com/Homebrew/linuxbrew-core/pull/22307 for more details. ---------- components: Build files: Screenshot config master.png messages: 387150 nosy: XuehaiPan priority: normal severity: normal status: open title: curses.h: present but cannot be compiled while building with custom CPPFLAGS type: compile error versions: Python 3.9 Added file: https://bugs.python.org/file49814/Screenshot config master.png _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 12:14:52 2021 From: report at bugs.python.org (ocket8888) Date: Wed, 17 Feb 2021 17:14:52 +0000 Subject: [New-bugs-announce] [issue43242] Add Void type to typing library Message-ID: <1613582092.09.0.127935431113.issue43242@roundup.psfhosted.org> New submission from ocket8888 : It'd be nice to have a "void" type that indicates to static type checkers that a function/method cannot be used in a valid assignment. ---------- components: Library (Lib) messages: 387166 nosy: ocket8888 priority: normal severity: normal status: open title: Add Void type to typing library type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 12:28:12 2021 From: report at bugs.python.org (Yurii Karabas) Date: Wed, 17 Feb 2021 17:28:12 +0000 Subject: [New-bugs-announce] [issue43243] Strict ABC classes Message-ID: <1613582892.97.0.748094590346.issue43243@roundup.psfhosted.org> New submission from Yurii Karabas <1998uriyyo at gmail.com>: Basically, the idea is to add the ability to mark abstract classes as strict. What does this mean - in case when a class inherits from a strict abstract base class and doesn't implement all abstract methods then it will fail to create a class. For instance: >>> class Iterable(ABC, strict=True): ... @abstractmethod ... def __iter__(self): ... pass >>> class MyClass(Iterable): ... pass TypeError: Can't create class MyClass with unimplemented strict abstract method __iter__ That allows creating abc classes and be sure that class defines a required method, it will be perfrormed on a class declaration stage rather than class instance creation. ---------- components: Library (Lib) messages: 387169 nosy: uriyyo priority: normal severity: normal status: open title: Strict ABC classes type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 13:31:30 2021 From: report at bugs.python.org (STINNER Victor) Date: Wed, 17 Feb 2021 18:31:30 +0000 Subject: [New-bugs-announce] [issue43244] Move PyArena C API to the internal C API Message-ID: <1613586690.19.0.383646964758.issue43244@roundup.psfhosted.org> New submission from STINNER Victor : Include/cpython/pyarena.h declares 4 functions which are implemented in Python/pyarena.c. The header file exists to access these functions from the compiler. IMO there was no intent to expose these functions to the public Python C API. Moreover, the PEP 384 explicitly excludes this API from the stable ABI (from the limited C API). I propose to move these functions to the internal C API. Since these functions are no even documented, I don't think that a deprecation period is needed. Note: The PR 24550 moved Include/pyarena.h to Include/cpython/pyarena.h. ---------- components: C API messages: 387180 nosy: vstinner priority: normal severity: normal status: open title: Move PyArena C API to the internal C API versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 14:48:44 2021 From: report at bugs.python.org (Raymond Hettinger) Date: Wed, 17 Feb 2021 19:48:44 +0000 Subject: [New-bugs-announce] [issue43245] Add keyword argument support to ChainMap.new_child() Message-ID: <1613591324.63.0.830748384561.issue43245@roundup.psfhosted.org> New submission from Raymond Hettinger : This would it more convenient to extend chains for local contexts. Currently, we write: local = parent.new_child(dict(foreground='white', background='cyan')) Instead, it would be easier to write: local = parent.new_child(foreground='white', background='cyan') The new code would look like this: def new_child(self, m=None, **kwargs): '''New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict: ''' if m is None: m = kwargs elif kwargs: m.update(kwargs) return self.__class__(m, *self.maps) ---------- assignee: rhettinger components: Library (Lib) messages: 387186 nosy: rhettinger priority: normal severity: normal status: open title: Add keyword argument support to ChainMap.new_child() type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 17:12:32 2021 From: report at bugs.python.org (Joshua Bronson) Date: Wed, 17 Feb 2021 22:12:32 +0000 Subject: [New-bugs-announce] [issue43246] Dict copy optimization violates subclass invariant Message-ID: <1613599952.95.0.0689652491879.issue43246@roundup.psfhosted.org> New submission from Joshua Bronson : If I understand correctly, it should be an invariant that in the code below, for all "Parent" classes, for all "method"s, Child1.method should return the same result as Child2.method: ``` class Parent: def __init__(self, value): self._value = value def method(self): return self._value class Child1(Parent): pass c1 = Child1(42) result = c1.method() assert result == 42, result class Child2(Parent): def method(self): return super().method() c2 = Child2(42) result = c2.method() assert result == 42, result ``` But when "Parent" is "dict" and method is "__iter__", that is not the case: ``` SHOW_BUG = True class ChildDict1(dict): """Simplification of werkzeug.datastructures.MultiDict.""" def __init__(self): pass if not SHOW_BUG: def __iter__(self): return super().__iter__() def add(self, key, value): self.setdefault(key, []).append(value) def __setitem__(self, key, value): """Like add, but removes any existing key first.""" super().__setitem__(key, [value]) def getall(self, key) -> list: return super().__getitem__(key) def __getitem__(self, key): """Return the first value for this key.""" return self.getall(key)[0] def items(self, multi=False): for (key, values) in super().items(): if multi: yield from ((key, value) for value in values) else: yield key, values[0] def values(self): return (values[0] for values in super().values()) # Remaining overridden implementations of methods # inherited from dict are elided for brevity. cd1 = ChildDict1() assert dict(cd1) == {} cd1[1] = "one" cd1.add(1, "uno") assert cd1.getall(1) == ["one", "uno"] assert list(cd1.items()) == [(1, "one")] assert list(cd1.values()) == [ "one"] assert dict(cd1) == {1: "one"}, cd1 # XXX ``` If you run the above as-is, the line marked "XXX" will trigger an AssertionError demonstrating the unexpected behavior. If you change SHOW_BUG to False, it won?t. Is it intended that toggling the value of SHOW_BUG in this code causes different results? You can visit https://repl.it/@jab/dict-subclass-copy-surprise to run the examples above directly in your browser. ---------- messages: 387191 nosy: jab priority: normal severity: normal status: open title: Dict copy optimization violates subclass invariant type: behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 17 22:16:48 2021 From: report at bugs.python.org (Aviral Srivastava) Date: Thu, 18 Feb 2021 03:16:48 +0000 Subject: [New-bugs-announce] [issue43247] How to search for a __main__ module using pyclbr in Python3? Message-ID: <1613618208.75.0.875306011279.issue43247@roundup.psfhosted.org> New submission from Aviral Srivastava : I want to get all the functions and classes in module: `__main__` of the source code directory: `/tmp/rebound/rebound`. When I use the `pyclbr.readmodule_ex` API: ``` source_code_data = pyclbr.readmodule_ex(source_code_module, path=source_code_path) ``` I specify it the module and it's path: ``` DEBUG:root:Source code module: __main__, Source code path: ['/tmp/rebound/rebound/rebound'] ``` I then get this error: ``` File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/util.py", line 69, in _find_spec_from_path raise ValueError('{}.__spec__ is None'.format(name)) ValueError: __main__.__spec__ is None ``` I then tried to use the function that is not supposed to be used by the public: `_readmodule`: ``` source_code_data = pyclbr._readmodule(source_code_module, source_code_path, ) ``` But I could not decide what should be the value of the parameter: `inpackage`. Upon tracing the code via debugger, I spotted a mistake: ``` def _find_spec_from_path(name, path=None): """Return the spec for the specified module. First, sys.modules is checked to see if the module was already imported. If so, then sys.modules[name].__spec__ is returned. If that happens to be set to None, then ValueError is raised. If the module is not in sys.modules, then sys.meta_path is searched for a suitable spec with the value of 'path' given to the finders. None is returned if no spec could be found. Dotted names do not have their parent packages implicitly imported. You will most likely need to explicitly import all parent packages in the proper order for a submodule to get the correct spec. """ if name not in sys.modules: return _find_spec(name, path) else: module = sys.modules[name] if module is None: return None try: spec = module.__spec__ except AttributeError: raise ValueError('{}.__spec__ is not set'.format(name)) from None else: if spec is None: raise ValueError('{}.__spec__ is None'.format(name)) return spec ``` This is the function in the module: `python3.8/importlib/util.py` and it evaluates `__main__` as a built-in module as it falls in the `else` block. How do I differentiate `__main__` of my target source code to read from the built-in `__main__`? In other words, how do I read the module `__main__` of the codebase: rebound? ---------- components: Library (Lib) messages: 387200 nosy: kebab-mai-haddi priority: normal severity: normal status: open title: How to search for a __main__ module using pyclbr in Python3? type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 06:13:38 2021 From: report at bugs.python.org (Omer Katz) Date: Thu, 18 Feb 2021 11:13:38 +0000 Subject: [New-bugs-announce] [issue43248] platform.libc_ver() returns no information on Alpine Linux Message-ID: <1613646818.72.0.219281463951.issue43248@roundup.psfhosted.org> New submission from Omer Katz : When calling platform.libc_ver() on Alpine I get the following tuple: ('', '') Instead, I expect to get ('muslc', '') or an exception if the libc type & version cannot be detected. If one of them is not detected, the returned value shouldn't be an empty string but None. The current API is not what most people would expect it to be. This is verified on Python 3.8 since that's the latest one available on Alpine. This code reliably detects musl libc and its version: https://github.com/lovell/detect-libc/blob/master/lib/detect-libc.js I'd be happy to contribute a PR if needed. ---------- messages: 387211 nosy: Omer.Katz priority: normal severity: normal status: open title: platform.libc_ver() returns no information on Alpine Linux versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 06:14:23 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Thu, 18 Feb 2021 11:14:23 +0000 Subject: [New-bugs-announce] [issue43249] sqlite3_column_bytes() should be called after sqlite3_column_blob() Message-ID: <1613646863.88.0.107963073708.issue43249@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : sqlite3_column_bytes() should be called _after_ sqlite3_column_blob(). There two calls to sqlite3_column_blob() are both preceeded by calls to sqlite3_column_bytes(). Currently it does not do any harm, but it is bad API usage. I suggest to fix the two cases, and add a comment in the source code as a reminder. Berker? Quoting from https://sqlite.org/c3ref/column_blob.html: The safest policy is to invoke these routines in one of the following ways: * sqlite3_column_text() followed by sqlite3_column_bytes() * sqlite3_column_blob() followed by sqlite3_column_bytes() * sqlite3_column_text16() followed by sqlite3_column_bytes16() In other words, you should call sqlite3_column_text(), sqlite3_column_blob(), or sqlite3_column_text16() first to force the result into the desired format, then invoke sqlite3_column_bytes() or sqlite3_column_bytes16() to find the size of the result. ---------- components: Library (Lib) messages: 387212 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: sqlite3_column_bytes() should be called after sqlite3_column_blob() type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 06:21:34 2021 From: report at bugs.python.org (STINNER Victor) Date: Thu, 18 Feb 2021 11:21:34 +0000 Subject: [New-bugs-announce] [issue43250] [C API] Depreate or remove PyFPE_START_PROTECT() and PyFPE_END_PROTECT() Message-ID: <1613647294.57.0.745628645388.issue43250@roundup.psfhosted.org> New submission from STINNER Victor : In Python 3.6, there was a WANT_SIGFPE_HANDLER macro defined if Python was built with ./configure --with-fpectl. By default, the macro was not defined. The fpectl module installed a SIGFPE signal handler which uses longjmp(). If the WANT_SIGFPE_HANDLER macro was defined, PyFPE_START_PROTECT() and PyFPE_END_PROTECT() macros used setjmp() to catch SIGFPE. All of this machinery was removed by bpo-29137 to fix ABI issues: commit 735ae8d139a673b30b321dc10acfd3d14f0d633b Author: Nathaniel J. Smith Date: Fri Jan 5 23:15:34 2018 -0800 bpo-29137: Remove fpectl module (#4789) This module has never been enabled by default, never worked correctly on x86-64, and caused ABI problems that caused C extension compatibility. See bpo-29137 for details/discussion. The PyFPE_START_PROTECT() and PyFPE_END_PROTECT() macros still exist for backward compatibility with Python 3.6 and older. Python/pyfpe.c contains the comment: /* These variables used to be used when Python was built with --with-fpectl, * but support for that was dropped in 3.7. We continue to define them, * though, because they may be referenced by extensions using the stable ABI. */ I'm not convinced that these macros are part of the stable ABI. The PEP 384 doesn't exclude pyfpe.h explicitly, but it's also unclear if it's part of the stable ABI or not. "PyFPE_START_PROTECT" and "PyFPE_END_PROTECT" symbols are not part of the stable ABI at least: they are missing from PC/python3dll.c and Doc/data/stable_abi.dat. Well, these are macros which emitted directly code rather than calling an opaque function. That sounds really bad in term of stable ABI :-( Python 3.6 macros, when WANT_SIGFPE_HANDLER macro is defined: --- #include #include #include extern jmp_buf PyFPE_jbuf; extern int PyFPE_counter; extern double PyFPE_dummy(void *); #define PyFPE_START_PROTECT(err_string, leave_stmt) \ if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ PyErr_SetString(PyExc_FloatingPointError, err_string); \ PyFPE_counter = 0; \ leave_stmt; \ } #define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); --- I propose to either deprecate these macros or remove them. These macros are not documented. In Python 3.6, the PyFPE macros were used in the Python stdlib, by files: Doc/library/fpectl.rst Include/pyfpe.h Modules/_tkinter.c Modules/clinic/cmathmodule.c.h Modules/cmathmodule.c Modules/fpetestmodule.c Modules/mathmodule.c Objects/complexobject.c Objects/floatobject.c Python/bltinmodule.c Python/pystrtod.c But it doesn't seem to be used outside Python. Note: In master, they are not used anywhere, they are only defined by Include/pyfpe.h. ---------- components: C API messages: 387213 nosy: njs, vstinner priority: normal severity: normal status: open title: [C API] Depreate or remove PyFPE_START_PROTECT() and PyFPE_END_PROTECT() versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 06:22:34 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Thu, 18 Feb 2021 11:22:34 +0000 Subject: [New-bugs-announce] [issue43251] sqlite3_column_name() failures should call PyErr_NoMemory() Message-ID: <1613647354.29.0.206061609144.issue43251@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : AFAICS, the docs for sqlite3_column_name() says that if it returns NULL, we are out of memory, thus we should call PyErr_NoMemory() and bail. FYI, there are the calls to sqlite3_column_name() in Modules/_sqlite//cursor.c Ref: - http://sqlite.org/c3ref/column_name.html - http://sqlite.org/c3ref/free.html ---------- components: Library (Lib) messages: 387214 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: sqlite3_column_name() failures should call PyErr_NoMemory() versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 07:19:02 2021 From: report at bugs.python.org (Konrad Schwarz) Date: Thu, 18 Feb 2021 12:19:02 +0000 Subject: [New-bugs-announce] [issue43252] deepcopy of weakref proxies Message-ID: <1613650741.99.0.0896392354865.issue43252@roundup.psfhosted.org> New submission from Konrad Schwarz : copy.deepcopy()-ing a tree structure that has internal parent and cross-reference links implemented as weakref.proxy() objects causes the weak reference proxies themselves to be copied (still refering to their original referents) rather than weak references to deep-copied referents to be created. A workaround is to add the following __deepcopy__ method to affected classes: def __deepcopy__ (self, memo): # taken from Stackoverflow: "How to override the # copy deepcopy operations for a python object" # and "Python: dereferencing weakproxy" cls = self.__class__ result = cls.__new__ (cls) memo [id (self)] = result for k, v in self.__dict__.items (): if isinstance (v, weakref.ProxyType): new_v = weakref.proxy (copy.deepcopy ( v.__repr__.__self__, memo)) else: new_v = copy.deepcopy (v, memo) setattr (result, k, new_v) return result ---------- components: Library (Lib) messages: 387226 nosy: konrad.schwarz priority: normal severity: normal status: open title: deepcopy of weakref proxies type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 08:46:25 2021 From: report at bugs.python.org (Daniel Engel) Date: Thu, 18 Feb 2021 13:46:25 +0000 Subject: [New-bugs-announce] [issue43253] asyncio open_connection fails when a socket is explicitly closed Message-ID: <1613655985.97.0.0380110039523.issue43253@roundup.psfhosted.org> New submission from Daniel Engel : Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help. In [1]: import socket ...: s1, s2 = socket.socketpair() ...: import asyncio ...: async def test(): ...: r1, w1 = await asyncio.open_connection(sock=s1) ...: r2, w2 = await asyncio.open_connection(sock=s2) ...: s1.close() ...: asyncio.run(test()) Exception in callback _ProactorBasePipeTransport._call_connection_lost(ConnectionAbo...e, 1236, None)) handle: Traceback (most recent call last): File "c:\python39\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) File "c:\python39\lib\asyncio\proactor_events.py", line 162, in _call_connection_lost self._sock.shutdown(socket.SHUT_RDWR) OSError: [WinError 10038] An operation was attempted on something that is not a socket ---------- components: asyncio messages: 387228 nosy: asvetlov, danielen1337, yselivanov priority: normal severity: normal status: open title: asyncio open_connection fails when a socket is explicitly closed versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 09:06:47 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Thu, 18 Feb 2021 14:06:47 +0000 Subject: [New-bugs-announce] [issue43254] Fix *snprintf() man page links Message-ID: <1613657207.71.0.865293132233.issue43254@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : Both snprintf and vsnprintf belong to man section 3 (library functions), not section 2 (system calls). Affected doc page: https://docs.python.org/3.10/c-api/conversion.html ---------- assignee: docs at python components: Documentation messages: 387230 nosy: docs at python, erlendaasland priority: normal severity: normal status: open title: Fix *snprintf() man page links versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 09:18:04 2021 From: report at bugs.python.org (=?utf-8?q?Bo=C5=A1tjan_Mejak?=) Date: Thu, 18 Feb 2021 14:18:04 +0000 Subject: [New-bugs-announce] [issue43255] Ceil division with /// operator Message-ID: <1613657884.47.0.693807596849.issue43255@roundup.psfhosted.org> New submission from Bo?tjan Mejak : I hope I'm not too late for a Python 3.10 feature request. I love the fact that Python 3.x does floor division with the // operator. We, however, don't have a ceil division operator, besides importing the math module and using its math.ceil() function. Is it possible we have /// as a ceil division operator in Python 3.10? I just wanted to put this thought out of my head if anyone becomes entertained by this idea. ---------- components: Library (Lib) messages: 387231 nosy: PedanticHacker, gvanrossum, rhettinger priority: normal severity: normal status: open title: Ceil division with /// operator type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 09:31:32 2021 From: report at bugs.python.org (Antoine Pitrou) Date: Thu, 18 Feb 2021 14:31:32 +0000 Subject: [New-bugs-announce] [issue43256] Document that PyErr_SetInterrupt is async-signal-safe Message-ID: <1613658692.98.0.566153002087.issue43256@roundup.psfhosted.org> New submission from Antoine Pitrou : While this makes sense given the exposed functionality, the reader may be wary of calling PyErr_SetInterrupt from a C signal handler if it's not explicitly documented as signal-safe. ---------- assignee: docs at python components: C API, Documentation messages: 387234 nosy: docs at python, pablogsal, pitrou, vstinner priority: low severity: normal status: open title: Document that PyErr_SetInterrupt is async-signal-safe type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 13:53:09 2021 From: report at bugs.python.org (Josue Balandrano Coronel) Date: Thu, 18 Feb 2021 18:53:09 +0000 Subject: [New-bugs-announce] [issue43257] get_type_hints evaluates class variables before type hints Message-ID: <1613674389.7.0.662545627223.issue43257@roundup.psfhosted.org> New submission from Josue Balandrano Coronel : Using typing.get_type_hints() on classes returns the wrong value when a class variable has the same name as a type and a default value. For instance: from dataclasses import dataclass from typing import get_type_hints @dataclass class DataClassHints: str: str="asdf" >>> get_type_hints(DataClassHints) ... NameError: name 'asdf' is not defined Looks like get_type_hints() is using "asdf" as a type. This is more clear if we use something like datetime: from datetime import datetime class ClassHints: datetime: datetime=datetime.now() >>> get_type_hints(ClassHints) ... {'datetime': datetime.datetime(2021, 2, 18, 12, 40, 16, 966502) If we do the same thing in a method get_type_hints works correctly: class CorrectHints: def __init__(self, str: str="asdf", datetime: datetime=datetime.now()): self.str = str self.datetime = datetime >>> ch = CorrectHints() >>> ch.str ... 'asdf' >>> ch.datetime ... datetime.datetime(2021, 2, 18, 12, 41, 46, 214844) >>> get_type_hints(CorrectHints.__init__) ... {'str': str, 'datetime': datetime.datetime} Also functions work correctly: def func_type_hints(str: str="asdf", datetime: datetime=datetime.now()): return f"str: {str}, datetime: {datetime}" >>> func_type_hints() ... 'str: asdf, datetime: 2021-02-18 12:44:21.102933' >>> get_type_hints(func_type_hints) ... {'str': str, 'datetime': datetime.datetime} It looks like get_type_hints is evaluating the default value in a class variable before the type hint. Here's another way to replicate this issue to make it clearer: class EvalOrderHints: datetime = datetime.now() datetime: datetime >>> get_type_hints(EvalOrderHints) ... {'datetime': datetime.datetime(2021, 2, 18, 12, 47, 56, 608261)} >>> EvalOrderHints().datetime ... datetime.datetime(2021, 2, 18, 12, 47, 56, 608261) ---------- messages: 387266 nosy: xirdneh priority: normal severity: normal status: open title: get_type_hints evaluates class variables before type hints type: behavior versions: Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 17:21:00 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Thu, 18 Feb 2021 22:21:00 +0000 Subject: [New-bugs-announce] [issue43258] Prevent needless allocation of sqlite3 aggregate function context Message-ID: <1613686860.13.0.742108376023.issue43258@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : If no rows match an aggregate query, _pysqlite_step_callback() is never called, and _pysqlite_final_callback() is called once. In order to prevent needless context allocation, we should pass 0 as the second argument to sqlite3_aggregate_context(). Quoting from https://sqlite.org/c3ref/aggregate_context.html: Within the xFinal callback, it is customary to set N=0 in calls to sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur. ---------- components: Library (Lib) messages: 387272 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: Prevent needless allocation of sqlite3 aggregate function context versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 18 21:28:41 2021 From: report at bugs.python.org (Christoph Anton Mitterer) Date: Fri, 19 Feb 2021 02:28:41 +0000 Subject: [New-bugs-announce] [issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group Message-ID: <1613701721.93.0.742004676065.issue43259@roundup.psfhosted.org> New submission from Christoph Anton Mitterer : Hey. AFAIU, the sole purpose of ArgumentParser.add_argument_group() is for the grouping within the help output. It would be nice, if one could create a mutually exclusive group (with ArgumentParser.add_mutually_exclusive_group) from/within such a "normal" group, so that the mutually exclusive arguments are listed within the group, but are still, mutually exclusive. Right now when doing something like: parser = argparse.ArgumentParser() parser_group = parser.add_argument_group("INPUT OPTIONS") parser_group_mutually_exclusive = parser_group.add_mutually_exclusive_group(required=False) parser_group_mutually_exclusive.add_argument("--from-args") parser_group_mutually_exclusive.add_argument("--from-files") parser_group_mutually_exclusive.add_argument("--from-stdin") parser_group.add_argument("-0", help="null delimited pathnames") it works, but the mutually exclusive options are note printed within the "INPUT OPTIONS", but rather at the normal "optional arguments:" section of the help. The above example also kinda shows what this could be used for: - one might have e.g. a group for input options, and amongst that the mutually exclusive "--from-*" which specify the source of the input. Cheers, Chris. ---------- components: Library (Lib) messages: 387278 nosy: calestyo priority: normal severity: normal status: open title: argparse: allow add_mutually_exclusive_group on add_argument_group type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 00:27:20 2021 From: report at bugs.python.org (Ramin Farajpour Cami) Date: Fri, 19 Feb 2021 05:27:20 +0000 Subject: [New-bugs-announce] [issue43260] Never release buffer when MemoryError in prtin() Message-ID: <1613712440.26.0.95537936361.issue43260@roundup.psfhosted.org> New submission from Ramin Farajpour Cami : Hi, When we use "a"*10000000000 in print("a"*10000000000) function, Show "MemoryError",Again i use print("1") again display "MemoryError", I think memory not release for use again, >>> print("a"*1000000000) Traceback (most recent call last): File "", line 1, in MemoryError >>> print("1") Traceback (most recent call last): File "", line 1, in MemoryError When i exit() python interpeter, and again print("1") it's work. And I test in linux its' work: >>> print("a"*1000000000) Traceback (most recent call last): File "", line 1, in MemoryError >>> print("1") 1 >>> print("a") a >>> Thanks. Ramin ---------- components: Windows messages: 387282 nosy: Ramin Farajpour Cami, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Never release buffer when MemoryError in prtin() versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 01:36:00 2021 From: report at bugs.python.org (Svyatoslav) Date: Fri, 19 Feb 2021 06:36:00 +0000 Subject: [New-bugs-announce] [issue43261] Python 3.9 repair on Windows do not recover pip module Message-ID: <1613716560.59.0.602550864554.issue43261@roundup.psfhosted.org> New submission from Svyatoslav : I by mistake run command `pip install -U pip setuptools wheel` on Windows which deleted pip and did not install a new version. I decided to repair Python using 3.9.1 installer option. But after repair pip still was not installed. ---------- components: Windows messages: 387285 nosy: Prometheus3375, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Python 3.9 repair on Windows do not recover pip module type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 01:47:59 2021 From: report at bugs.python.org (Jinghao Shi) Date: Fri, 19 Feb 2021 06:47:59 +0000 Subject: [New-bugs-announce] [issue43262] "_weakrefset.py", line 56: IndexError: pop from empty list Message-ID: <1613717279.64.0.759786918974.issue43262@roundup.psfhosted.org> New submission from Jinghao Shi : One of our asyncio based application sporadically crash due to this stack trace: ``` File ".../lib/python3.8/asyncio/runners.py", line 48, in run loop.run_until_complete(loop.shutdown_asyncgens()) File ".../lib/python3.8/asyncio/base_events.py", line 595, in run_until_complete future = tasks.ensure_future(future, loop=self) File ".../lib/python3.8/asyncio/tasks.py", line 669, in ensure_future task = loop.create_task(coro_or_future) File ".../lib/python3.8/asyncio/base_events.py", line 431, in create_task task = tasks.Task(coro, loop=self, name=name) File ".../lib/python3.8/_weakrefset.py", line 83, in add self._commit_removals() File ".../lib/python3.8/_weakrefset.py", line 56, in _commit_removals discard(l.pop()) IndexError: pop from empty list ``` We do not have a reliable repro. From reading the source code, it appears we should never try to pop from empty list: ``` def _commit_removals(self): l = self._pending_removals discard = self.data.discard while l: discard(l.pop()) # <-- HERE ``` ---------- components: asyncio messages: 387288 nosy: asvetlov, jhshi89, yselivanov priority: normal severity: normal status: open title: "_weakrefset.py", line 56: IndexError: pop from empty list type: crash versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 03:19:05 2021 From: report at bugs.python.org (twoone3) Date: Fri, 19 Feb 2021 08:19:05 +0000 Subject: [New-bugs-announce] [issue43263] threading module unable to run Message-ID: <1613722745.98.0.253058139819.issue43263@roundup.psfhosted.org> New submission from twoone3 <3197653242 at qq.com>: When I use embedded Python to import and use threading module,The program will hang,I tested it in versions 3.6.5 and 3.9.1. ---------- components: C API messages: 387293 nosy: twoone3 priority: normal severity: normal status: open title: threading module unable to run versions: Python 3.6, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 03:55:42 2021 From: report at bugs.python.org (Tobiichi) Date: Fri, 19 Feb 2021 08:55:42 +0000 Subject: [New-bugs-announce] [issue43264] Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No such file or directory problem Message-ID: <1613724942.01.0.259421151252.issue43264@roundup.psfhosted.org> New submission from Tobiichi <754785103 at qq.com>: I append EventProxy into ListProxy like this: ``` l = manager.list([mp.Event() for _ in range(2)]) ``` It works fine on a single node when I'm trying to get this listproxy. but when I trying to use multiple nodes across ethernet. it cause problem like this: ``` Traceback (most recent call last): File "client2.py", line 30, in logic(manager) File "client2.py", line 18, in logic if l[i].is_set(): File "", line 2, in __getitem__ File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 819, in _callmethod kind, result = conn.recv() File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", line 251, in recv return _ForkingPickler.loads(buf.getbuffer()) File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 943, in RebuildProxy return func(token, serializer, incref=incref, **kwds) File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 793, in __init__ self._incref() File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 847, in _incref conn = self._Client(self._token.address, authkey=self._authkey) File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", line 492, in Client c = SocketClient(address) File "/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", line 620, in SocketClient s.connect(address) ``` Nest ListProxy will cause same problem. like ``` l = manager.list([manager.list([1 for _ in range(2)])for _ in range(2)]) ``` Client act like this (manager in torch is SyncManager): ``` import torch.multiprocessing as mp mp.current_process().authkey = b'abc' def start_client(manager, host, port, key): manager.register('get_list') manager.__init__(address=(host, port), authkey=key) manager.connect() return manager def logic(manager): l = manager.get_list() for i in range(len(l)): if not l[i].is_set(): l[i].set() print('set') if __name__=='__main__': manager = mp.Manager() manager = start_client(manager, '127.0.0.1', 5000, b'abc') logic(manager) ``` ---------- files: server.py messages: 387295 nosy: show-me-code priority: normal severity: normal status: open title: Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No such file or directory problem type: crash versions: Python 3.6 Added file: https://bugs.python.org/file49819/server.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 04:10:02 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 19 Feb 2021 09:10:02 +0000 Subject: [New-bugs-announce] [issue43265] Improve sqlite3 backup error handling Message-ID: <1613725802.16.0.516336537835.issue43265@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : There are some issues with the error handling in pysqlite_connection_backup_impl(): 1. ValueError is returned if the target connection equals source connection. Should be OperationalError, IMHO. 2. The aforementioned check is already performed by sqlite3_backup_init(), so we should just let SQLite take care of it and let _pysqlite_seterror() set the error if sqlite3_backup_init() returns NULL. This will also take care of 1. 3. The following comment seems to be wrong; errors are set on the connection object, not on the backup handle: /* We cannot use _pysqlite_seterror() here because the backup APIs do not set the error status on the connection object, but rather on the backup handle. */ After sqlite3_backup_finish(), we can just check the return code, and call _pysqlite_seterror() on the connection and return NULL. The mentioned comment can be removed. Resolving these issues will save 18 lines of code, and make the backup function easier to maintain. Berker? ---------- components: Library (Lib) messages: 387297 nosy: berker.peksag, erlendaasland priority: normal severity: normal status: open title: Improve sqlite3 backup error handling type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 04:21:37 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 19 Feb 2021 09:21:37 +0000 Subject: [New-bugs-announce] [issue43266] "String conversion and formatting" formatting messes up array subscripting Message-ID: <1613726497.48.0.989705999924.issue43266@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : str[size-1] is rendered incorrectly in https://docs.python.org/3.10/c-api/conversion.html The original intent was probably to apply italics to the variables names only. This can be fixed by prefixing the first bracket with a backslash. However, that results in the italic text crashing with the bracket. I suggest to just use ``str[size-1]``. Also applies to str[rv] in the same section. ---------- assignee: docs at python components: Documentation messages: 387298 nosy: docs at python, erlendaasland priority: normal severity: normal status: open title: "String conversion and formatting" formatting messes up array subscripting versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 05:45:36 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 19 Feb 2021 10:45:36 +0000 Subject: [New-bugs-announce] [issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter() Message-ID: <1613731536.26.0.545379664561.issue43267@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : The type checks at the start of pysqlite_statement_bind_parameter() are redundant: We first check for exact types (*_CheckExact()), and then we check again for exact or subtyped versions (*_Check()). (Adding to the redundantness: the result of this if..else "switch statement" is then reused as the expression in the subsequent switch statement.) Suggesting to remove the redundant checks and merge the two switch statements. ---------- components: Library (Lib) messages: 387302 nosy: berker.peksag, erlendaasland priority: normal severity: normal status: open title: [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter() type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 06:59:23 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 19 Feb 2021 11:59:23 +0000 Subject: [New-bugs-announce] [issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state) Message-ID: <1613735963.3.0.941946997765.issue43268@roundup.psfhosted.org> New submission from STINNER Victor : I modified many internal C functions to pass the current Python thread state (tstate), but in practice, only the current interpreter (interp) is needed. ---------- components: Interpreter Core messages: 387308 nosy: vstinner priority: normal severity: normal status: open title: [internals] Pass the current interpreter (interp) rather than the current Python thread state (state) versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 07:05:57 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Fri, 19 Feb 2021 12:05:57 +0000 Subject: [New-bugs-announce] [issue43269] [sqlite3] Clean up function scoping Message-ID: <1613736357.16.0.00586339940376.issue43269@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : There's a lot of file scoped functions without the static storage-class specifier. All file local functions should have the static storage-class specifier. ---------- components: Library (Lib) messages: 387310 nosy: berker.peksag, erlendaasland priority: normal severity: normal status: open title: [sqlite3] Clean up function scoping type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 08:25:53 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 19 Feb 2021 13:25:53 +0000 Subject: [New-bugs-announce] [issue43270] [C API] Remove _PyErr_OCCURRED() macro Message-ID: <1613741153.22.0.969941653103.issue43270@roundup.psfhosted.org> New submission from STINNER Victor : The private _PyErr_OCCURRED() function was introduced to optimize Objects/setobject.c: commit 5ba0cbe39221ff8985ce5a4702a3b01a17ae3248 Author: Raymond Hettinger Date: Sat Aug 6 18:31:24 2005 +0000 * set_new() doesn't need to zero the structure a second time after tp_alloc has already done the job. * Use a macro form of PyErr_Occurred() inside the set_lookkey() function. But the usage of the macro was removed one month later: commit 9bda1d6f645bd0f3e76c14f27bbbac919814cd38 Author: Raymond Hettinger Date: Fri Sep 16 07:14:21 2005 +0000 No longer ignore exceptions raised by comparisons during key lookup. Inspired by Armin Rigo's suggestion to do the same with dictionaries. The macro is currently defined as: #if defined(Py_DEBUG) || defined(Py_LIMITED_API) #define _PyErr_OCCURRED() PyErr_Occurred() #else #define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type) #endif IMO the new _PyErr_Occurred(tstate) internal function is a more reliable way (don't depend on Py_DEBUG and Py_LIMITED_API) to ensure that the code uses the most efficient way to check if an exception was raised. I cannot find "_PyErr_OCCURRED" in the PyPI top 4000 projects, I checked with INADA-san's tool: https://github.com/methane/notes/tree/master/2020/wchar-cache (But I found many C extensiosn using "PyErr_Occurred" which is fine, this one stays ;-) I just wanted to check that my search was working.) So removing _PyErr_OCCURRED() is unlikely to break PyPI top 4000 projects. If it breaks a third party project: well, we don't provide any backward compatibility warranty on the *private* C API. ---------- components: C API messages: 387318 nosy: vstinner priority: normal severity: normal status: open title: [C API] Remove _PyErr_OCCURRED() macro versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 15:26:54 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 19 Feb 2021 20:26:54 +0000 Subject: [New-bugs-announce] [issue43271] AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow Message-ID: <1613766414.64.0.363657915419.issue43271@roundup.psfhosted.org> New submission from STINNER Victor : AMD64 Windows10 3.x, build 856: https://buildbot.python.org/all/#/builders/146/builds/856 17 tests failed: test_exceptions test_fileio test_io test_isinstance test_json test_lib2to3 test_logging test_pickle test_pickletools test_plistlib test_richcmp test_runpy test_sys test_threading test_traceback test_typing test_xml_etree It may be a regression caused by: "bpo-43166: Disable ceval.c optimisations for Windows debug builds (GH-24485)" https://github.com/python/cpython/commit/b74396c3167cc780f01309148db02709bc37b432 The latest successful build was 11 days ago (Feb 9): https://buildbot.python.org/all/#/builders/146/builds/819 ---- 0:01:46 load avg: 14.25 [ 61/426/1] test_xml_etree crashed (Exit code 3221225725) -- running: test_tokenize (46.4 sec), test_largefile (1 min 10 sec) Windows fatal exception: stack overflow Current thread 0x0000110c (most recent call first): File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", line 178 in __repr__ File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", line 178 in __repr__ File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", line 178 in __repr__ ... ====================================================================== FAIL: test_recursion_limit (test.test_threading.ThreadingExceptionTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_threading.py", line 1203, in test_recursion_limit self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode()) AssertionError: 3221225725 != 0 : Unexpected error: 0:05:09 load avg: 29.65 [140/426/3] test_traceback crashed (Exit code 3221225725) -- running: test_concurrent_futures (2 min 6 sec), test_mmap (2 min) Windows fatal exception: stack overflow Current thread 0x00000118 (most recent call first): File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", line 1154 in f File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", line 1156 in f File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", line 1156 in f ... 0:06:14 load avg: 29.15 [151/426/4] test_lib2to3 crashed (Exit code 3221225725) -- running: test_multiprocessing_spawn (31.7 sec), test_capi (1 min 3 sec), test_mmap (3 min 4 sec) Windows fatal exception: stack overflow Current thread 0x00001b90 (most recent call first): File "D:\buildarea\3.x.bolen-windows10\build\lib\lib2to3\pytree.py", line 496 in generate_matches File "D:\buildarea\3.x.bolen-windows10\build\lib\lib2to3\pytree.py", line 845 in generate_matches ... ---------- components: Windows messages: 387348 nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware priority: normal severity: normal status: open title: AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 19 15:32:05 2021 From: report at bugs.python.org (STINNER Victor) Date: Fri, 19 Feb 2021 20:32:05 +0000 Subject: [New-bugs-announce] [issue43272] AMD64 Arch Linux VintageParser 3.9: test_fstring test_named_expressions test_unpack_ex failed Message-ID: <1613766725.82.0.224144138609.issue43272@roundup.psfhosted.org> New submission from STINNER Victor : AMD64 Arch Linux VintageParser 3.9: https://buildbot.python.org/all/#/builders/495/builds/147 3 tests failed: test_fstring test_named_expressions test_unpack_ex The latest success build was 4 months ago (Nov 2): https://buildbot.python.org/all/#/builders/495/builds/107 ********************************************************************** File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py", line ?, in test.test_unpack_ex.__test__.doctests Failed example: (*x),y = 1, 2 # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... SyntaxError: can't use starred expression here Got nothing ********************************************************************** File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py", line ?, in test.test_unpack_ex.__test__.doctests Failed example: (((*x))),y = 1, 2 # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... SyntaxError: can't use starred expression here Got nothing ********************************************************************** File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py", line ?, in test.test_unpack_ex.__test__.doctests Failed example: z,(*x),y = 1, 2, 4 # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... SyntaxError: can't use starred expression here Got nothing ********************************************************************** File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py", line ?, in test.test_unpack_ex.__test__.doctests Failed example: z,(*x) = 1, 2 # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... SyntaxError: can't use starred expression here Got nothing ********************************************************************** File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py", line ?, in test.test_unpack_ex.__test__.doctests Failed example: ((*x),y) = 1, 2 # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... SyntaxError: can't use starred expression here Got nothing ********************************************************************** 1 items had failures: 5 of 91 in test.test_unpack_ex.__test__.doctests ====================================================================== FAIL: test_named_expression_invalid_rebinding_set_comprehension_iteration_variable (test.test_named_expressions.NamedExpressionInvalidTest) (case='Local reuse') ---------------------------------------------------------------------- File "", line 1 {i := 0 for i in range(5)} ^ SyntaxError: invalid syntax During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py", line 185, in test_named_expression_invalid_rebinding_set_comprehension_iteration_variable exec(code, {}, {}) AssertionError: "assignment expression cannot rebind comprehension iteration variable 'i'" does not match "invalid syntax (, line 1)" ====================================================================== FAIL: test_named_expression_invalid_rebinding_set_comprehension_iteration_variable (test.test_named_expressions.NamedExpressionInvalidTest) (case='Unpacking reuse') ---------------------------------------------------------------------- File "", line 1 {i := 0 for i, j in {(0, 1)}} ^ SyntaxError: invalid syntax During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py", line 185, in test_named_expression_invalid_rebinding_set_comprehension_iteration_variable exec(code, {}, {}) AssertionError: "assignment expression cannot rebind comprehension iteration variable 'i'" does not match "invalid syntax (, line 1)" ====================================================================== FAIL: test_named_expression_invalid_set_comprehension_iterable_expression (test.test_named_expressions.NamedExpressionInvalidTest) (case='Inside list') ---------------------------------------------------------------------- File "", line 1 {i for i in {2, 3, i := range(5)}} ^ SyntaxError: invalid syntax During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py", line 218, in test_named_expression_invalid_set_comprehension_iterable_expression exec(code, {}) # Module scope AssertionError: "assignment expression cannot be used in a comprehension iterable expression" does not match "invalid syntax (, line 1)" ====================================================================== FAIL: test_ast_line_numbers_with_parentheses (test.test_fstring.TestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_fstring.py", line 377, in test_ast_line_numbers_with_parentheses self.assertEqual(call.lineno, 5) AssertionError: 4 != 5 ---------- components: Tests messages: 387350 nosy: vstinner priority: normal severity: normal status: open title: AMD64 Arch Linux VintageParser 3.9: test_fstring test_named_expressions test_unpack_ex failed versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 03:44:25 2021 From: report at bugs.python.org (Richard Wise) Date: Sat, 20 Feb 2021 08:44:25 +0000 Subject: [New-bugs-announce] [issue43273] Mock `_mock_wraps` is undocumented and inconsistently named Message-ID: <1613810665.37.0.436661907336.issue43273@roundup.psfhosted.org> New submission from Richard Wise : I am trying to use wraps to delegate a call to a decorated patch mock to another method. By examining the source code, I was able to achieve this using the (apparently undocumented) `Mock._mock_wraps` attribute instead of the `wraps` attribute which would be expected given the constructor parameter names. I find this behaviour very confusing and inconsistent. Can we either expose `Mock.wraps` attribute or document `_mock_wraps` accordingly? Example: class MockRepro(unittest.TestCase) @patch('foo') def test_side_effect(self, mock_foo): # Set side effect in constructor as per https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock Mock(side_effect = [1, 2]) # Or can set on decorated patch foo.side_effect = [1, 2] @patch('foo') def test_wraps(self, mock_foo): def wrapped_method(): return 3 # Set wraps in constructor as per https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock Mock(wraps=wrapped_method) # Or can set on decorated patch foo.wraps = wrapped_method # This silently fails foo._mock_wraps = wrapped_method # Where does `_mock_wraps` come from? ---------- components: Library (Lib) messages: 387397 nosy: Woodz priority: normal severity: normal status: open title: Mock `_mock_wraps` is undocumented and inconsistently named versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 04:24:37 2021 From: report at bugs.python.org (Webstar Website) Date: Sat, 20 Feb 2021 09:24:37 +0000 Subject: [New-bugs-announce] [issue43274] Backlinks Strong decouverte SSL Message-ID: <1613813077.14.0.66972535006.issue43274@roundup.psfhosted.org> New submission from Webstar Website : Comment puis-je savoir si mon python g?n?r? ? la source a activ? SSL il faut obtenir l'information suivante : de savoir si opensslest est install?, vous pouvez analyser la sortie de openssl version: $ openssl version OpenSSL 1.0.2g-fips 1 Mar 2016 on obtient l? toutes sortes d'informations ? partir de cette version, par exemple, du r?pertoire o? elles sont stock?es: $ openssl version -d OPENSSLDIR: "/usr/lib/ssl" ---------- assignee: christian.heimes components: SSL messages: 387398 nosy: christian.heimes, webstarnantes priority: normal severity: normal status: open title: Backlinks Strong decouverte SSL versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 08:17:23 2021 From: report at bugs.python.org (star2000) Date: Sat, 20 Feb 2021 13:17:23 +0000 Subject: [New-bugs-announce] [issue43275] Add a `.gitignore` file with content `*` in the root folder generated by venv module Message-ID: <1613827043.02.0.761895659665.issue43275@roundup.psfhosted.org> New submission from star2000 : In this way, you don't need to add `venv` to `.gitignore` at the root of each project. ---------- messages: 387404 nosy: star2000 priority: normal severity: normal status: open title: Add a `.gitignore` file with content `*` in the root folder generated by venv module _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 11:39:15 2021 From: report at bugs.python.org (parsa mpsh) Date: Sat, 20 Feb 2021 16:39:15 +0000 Subject: [New-bugs-announce] [issue43276] add `false` and `true` keywords (aliases) for True and False Message-ID: <1613839155.27.0.1262506351.issue43276@roundup.psfhosted.org> New submission from parsa mpsh : I wanna add `true` and `false` aliases for `True` and `False` keywords. Currently my patch is ready and i will send it as a pull request. ---------- messages: 387411 nosy: parsampsh priority: normal severity: normal status: open title: add `false` and `true` keywords (aliases) for True and False type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 11:48:37 2021 From: report at bugs.python.org (Pablo Galindo Salgado) Date: Sat, 20 Feb 2021 16:48:37 +0000 Subject: [New-bugs-announce] [issue43277] Add PySet_CheckExact Message-ID: <1613839717.86.0.726302240391.issue43277@roundup.psfhosted.org> New submission from Pablo Galindo Salgado : For some mysterious reason we have PySet_Check, PyFrozenSet_Check, PyAnySet_Check, PyAnySet_CheckExact and PyFrozenSet_CheckExact but no PySet_CheckExact ---------- components: C API messages: 387413 nosy: pablogsal priority: normal severity: normal status: open title: Add PySet_CheckExact versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 12:02:21 2021 From: report at bugs.python.org (Joseph Shen) Date: Sat, 20 Feb 2021 17:02:21 +0000 Subject: [New-bugs-announce] [issue43278] Inconsistent behavior of Py_GetCompiler() Message-ID: <1613840541.54.0.110258286705.issue43278@roundup.psfhosted.org> New submission from Joseph Shen : The function Py_GetCompiler() return the version info with a leading '\n' when build with GCC/clang, while without this on other compilers. This inconsistent make the REPL print the 'welcome message' quit different, which I think is not we expect. >From the snapshot images, we can see, when compiler with MSVC, the 'welcome message' has two lines, but with GCC it is 3 lines, which two lines is what expected. Patch is given in the github rp, thanks for review. ---------- components: C API files: explorer_lN3ARB7gnj.png messages: 387417 nosy: josephsmeng priority: normal pull_requests: 23377 severity: normal status: open title: Inconsistent behavior of Py_GetCompiler() type: behavior Added file: https://bugs.python.org/file49824/explorer_lN3ARB7gnj.png _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 12:49:15 2021 From: report at bugs.python.org (Illia Volochii) Date: Sat, 20 Feb 2021 17:49:15 +0000 Subject: [New-bugs-announce] [issue43279] Update code taken from Keccak Code Package Message-ID: <1613843355.04.0.232424254564.issue43279@roundup.psfhosted.org> New submission from Illia Volochii : There were some updates to the Keccak package (https://github.com/XKCP/XKCP) since it was integrated in CPython initially. I will submit a pull request soon ---------- components: Extension Modules messages: 387422 nosy: christian.heimes, illia-v priority: normal severity: normal status: open title: Update code taken from Keccak Code Package type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 15:05:58 2021 From: report at bugs.python.org (Fabian Brinkmann) Date: Sat, 20 Feb 2021 20:05:58 +0000 Subject: [New-bugs-announce] [issue43280] addition argument for str.join() Message-ID: <1613851558.65.0.682568061448.issue43280@roundup.psfhosted.org> New submission from Fabian Brinkmann : It would be nice to have an additional argument for str.join() so this ", ".join(["a", "b", "c"], ", and ") would output "a, b, and, c" ---------- components: Library (Lib) messages: 387426 nosy: f-brinkmann priority: normal severity: normal status: open title: addition argument for str.join() type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 20:20:04 2021 From: report at bugs.python.org (Saiyang Gou) Date: Sun, 21 Feb 2021 01:20:04 +0000 Subject: [New-bugs-announce] [issue43281] Walrus comprehension rebind checking behavior Message-ID: <1613870404.85.0.640514140391.issue43281@roundup.psfhosted.org> New submission from Saiyang Gou : # test PEP 572 disallows walrus use cases such as `[(i := 1) for i in [1]]`, because `for i` implies that `i` is local to the comprehension but `(i := 1)` implies that `i` is "exported", which is a contradiction. However, I noticed the following behavior both in 3.8 and 3.9: >>> [(a := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'a' >>> [(b := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'b' >>> [(c := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'c' >>> [(d := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'd' >>> [(e := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'e' >>> [(f := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'f' >>> [(g := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'g' >>> [(h := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] File "", line 1 SyntaxError: assignment expression cannot rebind comprehension iteration variable 'h' >>> [(i := 1) for a, (*b, c[d+e::f(g)], h.i) in [1]] Traceback (most recent call last): File "", line 1, in File "", line 1, in TypeError: cannot unpack non-iterable int object Among all of these assignment expressions, only the assignment to `i` (attribute name) is allowed. However, in my understanding, only `a` and `b` should be disallowed for assignment. This comprehension example only creates two new variables, `a` and `b`, which are local to the comprehension. Assignment expressions assigning to `c`, `d`, `e`, `f`, `g` and `h` should be allowed. `c` and `h` are already in the outer scope. `d`, `e`, `f` and `g` are just names inside the expression in the subscript part. They are not "comprehension iteration variables" and not local to the comprehension. The same behavior is also observed when detecting inner loop variable rebinding outer loop assignment expression targets: >>> [i for i in range(5) if (j := 0) for k[j + 1] in range(5)] File "", line 1 SyntaxError: comprehension inner loop cannot rebind assignment expression target 'j' ---------- messages: 387433 nosy: gousaiyang priority: normal severity: normal status: open title: Walrus comprehension rebind checking behavior type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 20 23:49:05 2021 From: report at bugs.python.org (Eli Schwartz) Date: Sun, 21 Feb 2021 04:49:05 +0000 Subject: [New-bugs-announce] [issue43282] Add split install targets to install tests separately from lib Message-ID: <1613882945.82.0.411428525027.issue43282@roundup.psfhosted.org> New submission from Eli Schwartz : cf. https://bugs.python.org/issue27640#msg386758 Carrying on from the addition of --disable-test-modules, I would find it convenient to be able to still provide the tests, but install them separately. The end result would be two distro packages, one slim package that does not include the test modules by default, and one package that adds in the test modules for people that need it. This is currently possible via running the install step twice and some hacky shell globbing to delete unneeded files from each install. Some sort of libinstall/testinstall target split target would be less hacky, and not require checking if the list of test modules is up to date. So I'd consider it nice to have. :) ---------- components: Build messages: 387438 nosy: eschwartz priority: normal severity: normal status: open title: Add split install targets to install tests separately from lib type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 01:16:39 2021 From: report at bugs.python.org (Terry J. Reedy) Date: Sun, 21 Feb 2021 06:16:39 +0000 Subject: [New-bugs-announce] [issue43283] IDLE: Explain print slowness and speedup method Message-ID: <1613888199.55.0.371320208003.issue43283@roundup.psfhosted.org> Change by Terry J. Reedy : ---------- assignee: docs at python components: Documentation, IDLE nosy: docs at python, terry.reedy priority: normal severity: normal stage: patch review status: open title: IDLE: Explain print slowness and speedup method type: enhancement versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 05:42:26 2021 From: report at bugs.python.org (bugale bugale) Date: Sun, 21 Feb 2021 10:42:26 +0000 Subject: [New-bugs-announce] [issue43284] Wrong windows build in 20H2 Message-ID: <1613904146.72.0.850542213327.issue43284@roundup.psfhosted.org> New submission from bugale bugale : Running `platform.platform()` on Windows 10 20H2 results in the build number 19041: Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.platform() 'Windows-10-10.0.19041-SP0' This is incorrect, the build number is 19042. Using ctypes like in the answer here produces a correct result: https://stackoverflow.com/questions/32300004/python-ctypes-getting-0-with-getversionex-function ---------- components: Windows messages: 387450 nosy: bugale bugale, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Wrong windows build in 20H2 type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 06:49:34 2021 From: report at bugs.python.org (RiceX Star) Date: Sun, 21 Feb 2021 11:49:34 +0000 Subject: [New-bugs-announce] [issue43285] ftplib use host from PASV response Message-ID: <1613908174.7.0.0578051462677.issue43285@roundup.psfhosted.org> New submission from RiceX Star : Last year, curl had a security update for CVE-2020-8284. more info, see https://hackerone.com/reports/1040166 The problem is ftp client trust the host from PASV response by default, A malicious server can trick ftp client into connecting back to a given IP address and port. This may make ftp client scan ports and extract service banner from private newwork. After test and read ftplib module(https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/ftplib.py#L346), I found ftplib has the same problem. ---------- components: Library (Lib) messages: 387455 nosy: ricexdream priority: normal severity: normal status: open title: ftplib use host from PASV response type: security versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 10:56:24 2021 From: report at bugs.python.org (Antony Lee) Date: Sun, 21 Feb 2021 15:56:24 +0000 Subject: [New-bugs-announce] [issue43286] Clarify that Popen.returncode does not get auto-set when the process terminates Message-ID: <1613922985.0.0.488591869976.issue43286@roundup.psfhosted.org> New submission from Antony Lee : Currently, the documentation for Popen.returncode states The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn?t terminated yet. A negative value -N indicates that the child was terminated by signal N (POSIX only). As far back as https://bugs.python.org/issue1727024 it had been suggested that this fails to emphasize an important piece of information, namely that this attribute can be outdated (it is *only* set if poll() or wait() are called; this is not obvious, e.g. returncode could have beeen implemented as a property that auto-calls poll()). I do realize that a strict reading of the docs does suggest the actual behavior, but a bit of explicitness won't hurt... The wording suggested in https://bugs.python.org/issue1727024 seems clearer to me ("Note: The value stored in returncode may be out-of-date. Use poll() to reliably find the current return code."). ---------- assignee: docs at python components: Documentation messages: 387463 nosy: Antony.Lee, docs at python priority: normal severity: normal status: open title: Clarify that Popen.returncode does not get auto-set when the process terminates versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 12:59:22 2021 From: report at bugs.python.org (Dong-hee Na) Date: Sun, 21 Feb 2021 17:59:22 +0000 Subject: [New-bugs-announce] [issue43287] Use PEP 590 vectorcall to speed up calls to filter() Message-ID: <1613930363.0.0.0194789956004.issue43287@roundup.psfhosted.org> New submission from Dong-hee Na : +--------------+--------+----------------------+ | Benchmark | master | vectorcall | +==============+========+======================+ | bench filter | 191 ns | 151 ns: 1.26x faster | +--------------+--------+----------------------+ Like reversed(https://bugs.python.org/issue41922), it looks okay to update filter() to use PEP 590. ---------- components: Interpreter Core files: filter_bench.py messages: 387469 nosy: corona10, vstinner priority: normal severity: normal status: open title: Use PEP 590 vectorcall to speed up calls to filter() versions: Python 3.10 Added file: https://bugs.python.org/file49825/filter_bench.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 14:04:37 2021 From: report at bugs.python.org (Neil Schemenauer) Date: Sun, 21 Feb 2021 19:04:37 +0000 Subject: [New-bugs-announce] [issue43288] test_importlib failure due to missing skip() method Message-ID: <1613934277.61.0.647402041317.issue43288@roundup.psfhosted.org> New submission from Neil Schemenauer : The FileSystem class is missing a skip() method. If the file system doesn't support Unicode filenames, the test crashes. File "/home/nas/src/cpython/Lib/test/test_importlib/fixtures.py", line 221, in unicode_filename self.skip("File system does not support non-ascii.") AttributeError: 'FileSystem' object has no attribute 'skip' I'm running tests inside a Debian 32-bit container and for some reason the test.support.FS_NONASCII variable is not set. ---------- components: Tests messages: 387471 nosy: nascheme priority: normal severity: normal status: open title: test_importlib failure due to missing skip() method type: behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 16:29:59 2021 From: report at bugs.python.org (Yehuda Katz) Date: Sun, 21 Feb 2021 21:29:59 +0000 Subject: [New-bugs-announce] [issue43289] step bug in turtle's for loop Message-ID: <1613942999.52.0.979246620938.issue43289@roundup.psfhosted.org> New submission from Yehuda Katz : from turtle import * col = ["black", "white"] for rad in range(40, 0, -1): dot(5*rad, col[rad % 2]) done() ====================== Any other step than -1 crashes the code. Thank you. ---------- messages: 387472 nosy: Yehuda priority: normal severity: normal status: open title: step bug in turtle's for loop type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 18:16:09 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Sun, 21 Feb 2021 23:16:09 +0000 Subject: [New-bugs-announce] [issue43290] [sqlite3] remove legacy code from pysqlite_step Message-ID: <1613949369.74.0.130974571749.issue43290@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : pysqlite_step() contains a NULL check needed for SQLite 3.5 and earlier. This can be removed. ---------- components: Library (Lib) messages: 387476 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: [sqlite3] remove legacy code from pysqlite_step type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 20:37:01 2021 From: report at bugs.python.org (Tony) Date: Mon, 22 Feb 2021 01:37:01 +0000 Subject: [New-bugs-announce] [issue43291] elementary multiplication by 0.01 error Message-ID: <1613957821.53.0.407911881199.issue43291@roundup.psfhosted.org> New submission from Tony : on the >>> prompt type: >>>717161 * 0.01 7171.610000000001 the same goes for >>>717161.0 * 0.01 7171.610000000001 You can easily find more numbers with similar problem: for i in range(1000000): if len(str(i * 0.01)) > 12: print(i, i * 0.01) I am sure, that this problem was found before and circumvented by: >>>717161 / 100 7171.61 but this is hardly the way, one wants to rely on the code. This is the python version I use: Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 ---------- messages: 387485 nosy: tonys_0 priority: normal severity: normal status: open title: elementary multiplication by 0.01 error type: behavior versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 21 23:11:29 2021 From: report at bugs.python.org (Viktor Kis) Date: Mon, 22 Feb 2021 04:11:29 +0000 Subject: [New-bugs-announce] [issue43292] xml.ElementTree iterparse filehandle left open Message-ID: <1613967089.4.0.392869817438.issue43292@roundup.psfhosted.org> New submission from Viktor Kis : Standard library xml.ElementTree - iterparse does not close filehandle properly when breaking out of a for loop iterating with iterparse. The issue only occurs when the user passes a "string" as a source object instead of a filehandle (that is because a user's filehandle can safely be closed in a context manager as shown in the attachment). ---------- components: XML files: ETiterparse.py messages: 387494 nosy: vkisforever priority: normal severity: normal status: open title: xml.ElementTree iterparse filehandle left open type: crash versions: Python 3.9 Added file: https://bugs.python.org/file49826/ETiterparse.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 01:44:05 2021 From: report at bugs.python.org (Guanzhong Chen) Date: Mon, 22 Feb 2021 06:44:05 +0000 Subject: [New-bugs-announce] [issue43293] Move note about GIL to top of threading module Message-ID: <1613976245.39.0.497030592079.issue43293@roundup.psfhosted.org> New submission from Guanzhong Chen : The note about the GIL is buried pretty deep in the threading documentation, and this makes it hard for first time users to discover why their attempts at using threading to parallelizing their application did not work. This used to be the case in the old Python 2 documentation, but https://github.com/python/cpython/commit/d6d17c58af8002000ecd1326c7accafb5af8a9db moved it, and no corresponding discussion exists. I think the GIL is a pretty important thing to mention, especially for people used to other programming languages. I believe the change had a negative effect and should be reverted. ---------- assignee: docs at python components: Documentation messages: 387503 nosy: docs at python, quantum5 priority: normal severity: normal status: open title: Move note about GIL to top of threading module type: enhancement 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 Feb 22 05:06:47 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Mon, 22 Feb 2021 10:06:47 +0000 Subject: [New-bugs-announce] [issue43294] [sqlite3] unused variables in Connection begin, commit, and rollback Message-ID: <1613988407.68.0.840775188908.issue43294@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : In Modules/_sqlite/connection.c: pysqlite_connection_commit_impl(), pysqlite_connection_rollback_impl(), and _pysqlite_connection_begin() all call sqlite3_prepare_v2() with the fourth parameter (pzTail) set. This (output) parameter is never used, we can safely remove the tail variables, and just call sqlite3_prepare_v2() with NULL as the fourth parameter. Also, there's a lot of code duplication here. A support function could help simplify this, but that's out of scope. ---------- components: Library (Lib) messages: 387510 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: [sqlite3] unused variables in Connection begin, commit, and rollback type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 08:58:19 2021 From: report at bugs.python.org (itchyny) Date: Mon, 22 Feb 2021 13:58:19 +0000 Subject: [New-bugs-announce] [issue43295] datetime.strptime emits IndexError on parsing 'z' as %z Message-ID: <1614002299.86.0.551520528109.issue43295@roundup.psfhosted.org> New submission from itchyny : In Python 3.9.2, parsing 'z' (small letter) as '%z' (time zone offset) using datetime.strptime emits an IndexError. >>> from datetime import datetime >>> datetime.strptime('z', '%z') Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.9/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/usr/local/lib/python3.9/_strptime.py", line 453, in _strptime if z[3] == ':': IndexError: string index out of range I expect ValueError (or some another useful error) as follows. ValueError: time data 'z' does not match format '%z' This is caused by compiling '%z' to a pattern containing 'Z' (for UTC) with the IGNORECASE flag and accessing z[3] without noticing 'z' is accepted by the regexp. ---------- components: Library (Lib) messages: 387514 nosy: itchyny priority: normal severity: normal status: open title: datetime.strptime emits IndexError on parsing 'z' as %z type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 09:37:13 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Mon, 22 Feb 2021 14:37:13 +0000 Subject: [New-bugs-announce] [issue43296] [sqlite3] sqlite3_value_bytes() should be called after sqlite3_value_blob() Message-ID: <1614004633.85.0.0676920983033.issue43296@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : The sqlite3_value_*() API is almost identical to the sqlite3_column_*() API. sqlite3_value_bytes() should be called after we've converted the value using sqlite3_value_blob(). See also bpo-43249. ---------- components: Library (Lib) messages: 387516 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: [sqlite3] sqlite3_value_bytes() should be called after sqlite3_value_blob() type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 12:03:22 2021 From: report at bugs.python.org (Philipp Freyer) Date: Mon, 22 Feb 2021 17:03:22 +0000 Subject: [New-bugs-announce] [issue43297] bz2.open modes behaving differently than standard open() modes Message-ID: <1614013402.3.0.966797647642.issue43297@roundup.psfhosted.org> New submission from Philipp Freyer : The documentation clearly states that bz2.open(mode='r') opens a file in binary mode. I would have to use 'rt' for text mode. The basic Python open(mode='r') method opens a file in text mode. This is how I would expect any open(mode='r') method to work, especially since the standard Python implementation of open() treats 'r' as a synonym to 'rt'. IMHO the behavior of bz2.open() is a possible pitfall for many developers and should be in line with the standard open() behavior. Sorry, if this is in the wrong place, I am happy to put this elsewhere. However, I do see that as a conceptual issue (in our case this bug was not found for years) ---------- messages: 387517 nosy: philipp.freyer priority: normal severity: normal status: open title: bz2.open modes behaving differently than standard open() modes type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 12:25:51 2021 From: report at bugs.python.org (Kevin Thomas) Date: Mon, 22 Feb 2021 17:25:51 +0000 Subject: [New-bugs-announce] [issue43298] Windows build issue Message-ID: <1614014751.18.0.52094135212.issue43298@roundup.psfhosted.org> New submission from Kevin Thomas : When compiling for Windows it does not properly handle the version string MSB4184 C:\Users\kevin\cpython>PCbuild\build.bat Using py -3.7 (found 3.7 with py.exe) Fetching external libraries... bzip2-1.0.6 already exists, skipping. sqlite-3.34.0.0 already exists, skipping. xz-5.2.2 already exists, skipping. zlib-1.2.11 already exists, skipping. Fetching external binaries... libffi already exists, skipping. openssl-bin-1.1.1i already exists, skipping. tcltk-8.6.10.0 already exists, skipping. Finished. Using "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" (found in the Visual Studio installation) C:\Users\kevin\cpython>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" "C:\Users\kevin\cpython\PCbuild\pcbuild.proj" /t:Build /m /nologo /v:m /clp:summary /p:Configuration=Release /p:Platform=x64 /p:IncludeExternals=true /p:IncludeCTypes=true /p:IncludeSSL=true /p:IncludeTkinter=true /p:UseTestMarker= /p:GIT="C:\Program Files\Git\cmd\git.exe" C:\Users\kevin\cpython\PCbuild\python.props(111,31): error MSB4184: The expression "[System.Version]::Parse('')" cannot be evaluated. Version string portion was too short or too long. [C:\Users\kevin\cpython\PCbuild\pythoncore.vcxproj] Build FAILED. C:\Users\kevin\cpython\PCbuild\python.props(111,31): error MSB4184: The expression "[System.Version]::Parse('')" cannot be evaluated. Version string portion was too short or too long. [C:\Users\kevin\cpython\PCbuild\pythoncore.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.06 ---------- messages: 387518 nosy: mytechnotalent priority: normal severity: normal status: open title: Windows build issue type: compile error versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 12:48:25 2021 From: report at bugs.python.org (Robert) Date: Mon, 22 Feb 2021 17:48:25 +0000 Subject: [New-bugs-announce] [issue43299] pyclbr.readmodule_ex traversing "import __main__": dies with ValueError: __main__.__spec__ is None / is not set Message-ID: <1614016105.41.0.669776853412.issue43299@roundup.psfhosted.org> New submission from Robert : When pyclbr.readmodule_ex() is traversing "import __main__" or another module without __spec__, it dies completely with "ValueError: __main__.__spec__ is None / is not set". => It should at least continue with the (big) rest as the comment in _ModuleBrowser.visit_Import() says: # If we can't find or parse the imported module, # too bad -- don't die here. And optionally fall back to using __file__ when present? Traceback (most recent call last): File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\ModuleBrowser.py", line 128, in OnActivateView self.CheckRefreshList() File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\ModuleBrowser.py", line 181, in CheckRefreshList self.CheckMadeList() File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\ModuleBrowser.py", line 173, in CheckMadeList self.rootitem = root = self._MakeRoot() File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\ModuleBrowser.py", line 153, in _MakeRoot data = reader(mod, path and [path]) File "C:\Python310\lib\pyclbr.py", line 120, in readmodule_ex return _readmodule(module, path or []) File "C:\Python310\lib\pyclbr.py", line 159, in _readmodule return _readmodule(submodule, parent['__path__'], package) File "C:\Python310\lib\pyclbr.py", line 184, in _readmodule return _create_tree(fullmodule, path, fname, source, tree, inpackage) File "C:\Python310\lib\pyclbr.py", line 272, in _create_tree mbrowser.visit(ast.parse(source)) File "C:\Python310\lib\ast.py", line 410, in visit return visitor(node) File "C:\Python310\lib\ast.py", line 418, in generic_visit self.visit(item) File "C:\Python310\lib\ast.py", line 410, in visit return visitor(node) File "C:\Python310\lib\pyclbr.py", line 243, in visit_Import _readmodule(module.name, []) File "C:\Python310\lib\pyclbr.py", line 167, in _readmodule spec = importlib.util._find_spec_from_path(fullmodule, search_path) File "C:\Python310\lib\importlib\util.py", line 69, in _find_spec_from_path raise ValueError('{}.__spec__ is None'.format(name)) ValueError: __main__.__spec__ is None ---------- components: Library (Lib) messages: 387520 nosy: kxrob priority: normal severity: normal status: open title: pyclbr.readmodule_ex traversing "import __main__": dies with ValueError: __main__.__spec__ is None / is not set type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 13:12:33 2021 From: report at bugs.python.org (James Murphy) Date: Mon, 22 Feb 2021 18:12:33 +0000 Subject: [New-bugs-announce] [issue43300] "bisect" module should support reverse-sorted sequences Message-ID: <1614017554.0.0.495039898854.issue43300@roundup.psfhosted.org> New submission from James Murphy : Currently, the bisect module's functions all assume the user is maintaining a sorted list/sequence in increasing order. From the docs: "This module provides support for maintaining a list in sorted order without having to sort the list after each insertion" However, bisection is not limited to this use case, nor is it limited to increasing sequences. Many algorithms involve bisecting a sequence derived from (potentially immutable) user input, such as the standard longest-increasing-subsequence algorithm. Sometimes these derived sequences are naturally reverse-sorted, as they would be in the longest-decreasing-subsequence algorithm. (I have personally had to work around bisect not working with decreasing sequences in this case). There are other natural reasons for a reverse-sorted list to appear that one might want to bisect. Of course, a monotone decreasing function applied to a sorted list would result in a reverse-sorted one. One may want to use bisect as a root-finding algorithm for a decreasing function that may not be differentiable (or even continuous). Or a user may simply have chosen to reverse-sort using sorted(a, reverse=True). In my mind, the bisect module's purpose should be to support common use cases of bisection, not specifically to maintain a sorted list. So then the question arises, how to support reverse-sorted sequences? I see a few possible routes. 1. Add a "decreasing" parameter to bisect_left, bisect_right, (and perhaps insort_left, insort_right as well). 2. Add dedicated functions bisect_left_decreasing, bisect_right_decreasing, (and perhaps insort_left_decreasing, insort_right_decreasing as well) that operate on reverse-sorted sequences. 3. Add a more general bisect_first_false(a, pred, lo, hi) (equivalent to C++'s std::partition_point) that assumes the sequence to be partitioned with respect to the predicate function and returns the first index such that the predicate is falsey, or hi if no falsey elements are found. Then reverse-sorted lists can be bisected with something like bisect_first_false(a, lambda y: y > x). This way may be too general, but it becomes very obvious what operators will be called on the values and what the post-condition of the function is, similar to the condition of a while loop. 4. Add a "cmp" parameter to bisect_left, bisect_right, (and perhaps insort_left, insort_right as well) that keys are meant to be compared with, so one would pass bisect_left(a, x, cmp=operator.gt). It could be used in conjuction with "key", i.e. "cmp" is not meant to be a replacement for "key" as it was with sorted. 5. Do nothing. People who _really_ want to bisect reverse-sorted lists will write their own bisect_*_decreasing or figure out that if "a" is reverse-sorted, the following monstrosity does the job, making ab(use) of the new "key" parameter in 3.10 and due to the fact that False < True: a = ... # reverse-sorted x = ... # bisect left on reverse-sorted pred = lambda y: not (x < y) idx = bisect_left(a, x, key=pred) # bisect right on reverse-sorted pred = lambda y: y < x idx = bisect_right(a, x, key=pred) Commentary on the choices. 1 or 4 are the most convenient from a user perspective, no extra imports and discoverable behavior. 4 also has the benefit that the element/key class does not need to define a __lt__, which can be useful in cases where the element/key has many comparable attributes and it does not make sense to pick one to be used to define a __lt__. 3 would have the most generality and usefulness to library writers, who would probably be the primary users in need of a reverse-sorted bisection implementation. 2 suffers from combinatorial explosion (many new functions) and extra importing needed, but allows the implementation of existing functions to be unchanged, as well as mildly discouraging users from using it unless they _really_ want to use it. 5 will lead to many incorrect home-grown bisection searches or other hacks being used in the wild. Personally, I am somewhat indifferent between 1 and 4, perhaps slightly learning towards 4 as it makes explicit exactly how elements/keys will be compared. I would like to see 3 implemented as well, but admit that it is likely too general a solution for the proposed issue "support reverse-sorted lists". ---------- components: Library (Lib) messages: 387523 nosy: mCoding priority: normal severity: normal status: open title: "bisect" module should support reverse-sorted sequences type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 13:40:52 2021 From: report at bugs.python.org (Candra Wijaya) Date: Mon, 22 Feb 2021 18:40:52 +0000 Subject: [New-bugs-announce] [issue43301] Update form create for android Message-ID: <1614019252.61.0.935700227063.issue43301@roundup.psfhosted.org> New submission from Candra Wijaya : I need documend create sistems ---------- assignee: terry.reedy components: C API, Demos and Tools, Distutils, FreeBSD, IDLE, Installation, Regular Expressions, Tests, ctypes, email messages: 387527 nosy: barry, dstufft, eric.araujo, ezio.melotti, koobs, mrabarnett, r.david.murray, sirsak406, terry.reedy priority: normal severity: normal status: open title: Update form create for android type: crash versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Mon Feb 22 13:52:18 2021 From: report at bugs.python.org (Coleman) Date: Mon, 22 Feb 2021 18:52:18 +0000 Subject: [New-bugs-announce] [issue43302] shutil. copy file throws incorrect SameFileError on Google Drive File Stream Message-ID: <1614019938.71.0.464413527592.issue43302@roundup.psfhosted.org> New submission from Coleman : When using shuttle. copy file on the Google Drive File Stream file way, an incorrect SameFileError can happen. MWE (assuming foo.txt exists in your google drive G:\\): >>> f1 = 'G:\\My Drive\\foo.txt' >>> f2 = 'G:\\My Drive\\foo2.txt' >>> import shutil >>> shutil.copyfile(f1, f2) >>> shutil.copyfile(f1, f2) --> Last line throws incorrect SameFileError. In contrast, executing the same code on a different file operation(e.g. local hard drive) will result in no errors. More details described here: https://apkwill.com/ The error originates in the library in generalpath.py in the function same stat: Google Drive File Stream reports inode==0 which makes os. path.same file(f1, f2) == True for any files f1 and f2 on Google File Stream. I suggest the following patch, which currently works for me: --- genericpath.py 2018-06-22 02:14:27.145744900 +0200 +++ genericpath_new.py 2018-06-22 02:10:44.485961100 +0200 @@ -86,8 +86,11 @@ # describing the same file? def samestat(s1, s2): """Test whether two stat buffers reference the same file""" - return (s1.st_ino == s2.st_ino and - s1.st_dev == s2.st_dev) + return (s1.st_ino != 0 and + s2.st_ino != 0 and + s1.st_ino == s2.st_ino and + s1.st_dev == s2.st_dev) + # Are two filenames actually pointing to the very file? ---------- components: Library (Lib) messages: 387531 nosy: Deniz Bozyigit, White1, alexkowel, eryksun priority: normal severity: normal status: open title: shutil. copy file throws incorrect SameFileError on Google Drive File Stream versions: Python 3.7, Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 00:57:00 2021 From: report at bugs.python.org (Ramin Farajpour Cami) Date: Tue, 23 Feb 2021 05:57:00 +0000 Subject: [New-bugs-announce] [issue43303] ASAN : Memory leak in compilation Message-ID: <1614059820.89.0.803150096137.issue43303@roundup.psfhosted.org> New submission from Ramin Farajpour Cami : Hi, Asan has detected a memory leak : $ wget https://github.com/python/cpython/archive/v3.9.2.tar.gz $ tar xvf v3.9.2.tar.gz $ ./configure --disable-shared CFLAGS="-fsanitize=address -ggdb" CXXFLAGS="-fsanitize=address -ggdb" LDFLAGS="-fsanitize=address" $ make -j4 $ ~/cpython-3.9.2# ./python -E -S -m sysconfig --generate-posix-vars ================================================================= ==330505==ERROR: LeakSanitizer: detected memory leaks Direct leak of 300082 byte(s) in 137 object(s) allocated from: #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8) #1 0x55a58e972015 in PyMem_RawMalloc Objects/obmalloc.c:572 #2 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1645 #3 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1638 Direct leak of 2066 byte(s) in 2 object(s) allocated from: #0 0x7f647a692ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) #1 0x55a58e9c9e7d in resize_compact Objects/unicodeobject.c:1079 Direct leak of 672 byte(s) in 1 object(s) allocated from: #0 0x7f647a692ffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) #1 0x55a58eb6c620 in _PyObject_GC_Resize Modules/gcmodule.c:2297 Indirect leak of 110001 byte(s) in 115 object(s) allocated from: #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8) #1 0x55a58e972015 in PyMem_RawMalloc Objects/obmalloc.c:572 #2 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1645 #3 0x55a58e972015 in _PyObject_Malloc Objects/obmalloc.c:1638 Indirect leak of 536 byte(s) in 1 object(s) allocated from: #0 0x7f647a692bc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8) #1 0x55a58e972382 in _PyObject_Malloc Objects/obmalloc.c:572 #2 0x55a58e972382 in pymalloc_realloc Objects/obmalloc.c:1988 #3 0x55a58e972382 in _PyObject_Realloc Objects/obmalloc.c:2007 SUMMARY: AddressSanitizer: 413357 byte(s) leaked in 256 allocation(s). Thanks, Ramin ---------- components: Build messages: 387551 nosy: Ramin Farajpour Cami priority: normal severity: normal status: open title: ASAN : Memory leak in compilation type: resource usage versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 02:54:32 2021 From: report at bugs.python.org (Noel del Rosario) Date: Tue, 23 Feb 2021 07:54:32 +0000 Subject: [New-bugs-announce] [issue43304] THONNY 3.3.0 failing to install package MULTIPROCESSING Message-ID: <1614066872.94.0.250943376947.issue43304@roundup.psfhosted.org> New submission from Noel del Rosario : I am actually using a PYTHON IDE called THONNY 3.3.- and I am not geting any success to install the package MULTI{ROCESSING. Error message is shown below. requirement multiprocessing ERROR: No matching distribution found for multiprocessing Process returned with code 1 ---------- messages: 387553 nosy: gvanrossum, rosarion2 priority: normal severity: normal status: open title: THONNY 3.3.0 failing to install package MULTIPROCESSING versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 09:05:58 2021 From: report at bugs.python.org (Ma Lin) Date: Tue, 23 Feb 2021 14:05:58 +0000 Subject: [New-bugs-announce] [issue43305] A typo in /Modules/_io/bufferedio.c Message-ID: <1614089158.05.0.547226223268.issue43305@roundup.psfhosted.org> New submission from Ma Lin : 654 PyErr_Fetch(&t, &v, &tb); 655 if (v == NULL || !PyErr_GivenExceptionMatches(v, PyExc_BlockingIOError)) { ? this should be t https://github.com/python/cpython/blob/v3.10.0a5/Modules/_io/bufferedio.c#L654-L655 Does this need a test case? ---------- components: IO messages: 387570 nosy: malin priority: normal severity: normal status: open title: A typo in /Modules/_io/bufferedio.c type: behavior versions: Python 3.10, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 10:55:10 2021 From: report at bugs.python.org (=?utf-8?q?D=C3=A1vid_Nemeskey?=) Date: Tue, 23 Feb 2021 15:55:10 +0000 Subject: [New-bugs-announce] [issue43306] Error in multiprocessing.Pool's initializer doesn't stop execution Message-ID: <1614095710.79.0.438522017133.issue43306@roundup.psfhosted.org> New submission from D?vid Nemeskey : There is an inconsistency in how multiprocessing.Pool handles exceptions thrown in the workers: - exceptions raised by the mapped function stop execution right away - exceptions raised in an initializer are ignored and the pool continues spawning new workers indefinitely, each of them failing. I believe the behavior should be the same in both cases, and of the two, the first one is preferable (especially since that's what people are used to). The documentation doesn't cover how exceptions are handled in pools, either. ---------- assignee: docs at python components: Documentation, Library (Lib) messages: 387577 nosy: docs at python, nemeskeyd priority: normal severity: normal status: open title: Error in multiprocessing.Pool's initializer doesn't stop execution type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 12:01:37 2021 From: report at bugs.python.org (mattip) Date: Tue, 23 Feb 2021 17:01:37 +0000 Subject: [New-bugs-announce] [issue43307] Sync site.py and sysconfig.py with PyPy Message-ID: <1614099697.74.0.00793474139311.issue43307@roundup.psfhosted.org> New submission from mattip : PyPy added some enhancements to sysconfig.py to deal with multiple implementations. site.py copies parts of sysconfig.py to save time when importing. It would be nice to backport these enhamncements, maybe other implementations could reuse them. ---------- components: Installation messages: 387583 nosy: mattip priority: normal severity: normal status: open title: Sync site.py and sysconfig.py with PyPy versions: Python 3.7 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 13:26:22 2021 From: report at bugs.python.org (cptpcrd) Date: Tue, 23 Feb 2021 18:26:22 +0000 Subject: [New-bugs-announce] [issue43308] subprocess.Popen leaks file descriptors opened for DEVNULL or PIPE stdin/stdout/stderr arguments Message-ID: <1614104782.38.0.966400001347.issue43308@roundup.psfhosted.org> New submission from cptpcrd : TL;DR: subprocess.Popen's handling of file descriptors opened for DEVNULL or PIPE inputs/outputs has serious problems, and it can be coerced into leaking file descriptors in several ways. This can cause issues related to resource exhaustion. # The basic problem As part of its setup, Popen.__init__() calls Popen._get_handles(), which looks at the given stdin/stdout/stderr arguments and returns a tuple of 6 file descriptors (on Windows, file handles) indicating how stdin/stdout/stderr should be redirected. However, these file descriptors aren't properly closed if exceptions occur in certain cases. # Variant 1: Bad argument errors (introduced in 3.9) The first variant of this bug is shockingly easy to reproduce (note that this only works on platforms with /proc/self/fd, like Linux): ``` import os, subprocess def show_fds(): for entry in os.scandir("/proc/self/fd"): print(entry.name, "->", os.readlink(entry.path)) print("Before:") show_fds() try: subprocess.Popen(["ls"], stdin=subprocess.PIPE, user=1.0) except TypeError as e: # "User must be a string or an integer" print(e) print("After:") show_fds() ``` This produces something like: ``` Before: 0 -> /dev/pts/1 1 -> /dev/pts/1 2 -> /dev/pts/1 3 -> /proc/12345/fd User must be a string or an integer After: 0 -> /dev/pts/1 1 -> /dev/pts/1 2 -> /dev/pts/1 3 -> pipe:[1234567] 3 -> pipe:[1234567] 5 -> /proc/12345/fd ``` The process never got launched (because of the invalid `user` argument), but the (unused) pipe created for piping to stdin is left open! Substituting DEVNULL for PIPE instead leaves a single file descriptor open to `/dev/null`. This happens because the code that validates the `user`, `group`, and `extra_groups` arguments [1] was added to Popen.__init__() *after* the call to Popen._get_handles() [2], and there isn't a try/except that closes the file descriptors if an exception gets raised during validation (which can easily happen). # Variant 2: Error opening file descriptors (seems to have been around in `subprocess` forever) Within Popen._get_handles() (on Windows [3] or POSIX [4]), previously opened file descriptors are not closed if an error occurs while opening later file descriptors. For example, take the case where only one more file descriptor can be opened without hitting the limit on the number of file descriptors, and `subprocess.Popen(["ls"], stdin=subprocess.DEVNULL, stdout=supbrocess.PIPE)` is called. subprocess will be able to open `/dev/null` for stdin, but trying to creating a `pipe()` for stdout will fail with EMFILE or ENFILE. Since Popen._get_handles() doesn't handle exceptions from `pipe()` (or when opening `/dev/null`), the `/dev/null` file descriptor opened for stdin will be be left open. This variant is most easily triggered by file descriptor exhaustion, and it makes that problem worse by leaking even *more* file descriptors. Here's an example that reproduces this by monkey-patching `os` to force an error: ``` import os, subprocess def show_fds(): for entry in os.scandir("/proc/self/fd"): print(entry.name, "->", os.readlink(entry.path)) print("Before:") show_fds() # Trigger an error when trying to open /dev/null os.devnull = "/NOEXIST" try: subprocess.Popen(["ls"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL) except FileNotFoundError as e: # "User must be a string or an integer" print(e) print("After:") show_fds() ``` Output: ``` Before: 0 -> /dev/pts/1 1 -> /dev/pts/1 2 -> /dev/pts/1 3 -> /proc/12345/fd [Errno 2] No such file or directory: '/dev/null' After: 0 -> /dev/pts/1 1 -> /dev/pts/1 2 -> /dev/pts/1 3 -> pipe:[1234567] 4 -> pipe:[1234567] 5 -> /proc/12345/fd ``` Again, the pipe is left open. # Paths to fix. Variant 1 can be fixed by simply reordering code in Popen.__init__() (and leaving comments warning about the importance of maintaining the order!). I've attached a basic patch that does this. Variant 2 might take some more work -- especially given the shared Popen._devnull file descriptor that needs to be accounted for separately -- and may require significant changes to both Popen.__init__() and Popen._get_handles() to fix. [1]: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L872 [2]: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L840 [3]: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L1251 [4]: https://github.com/python/cpython/blob/master/Lib/subprocess.py#L1581 ---------- components: Library (Lib) files: subprocess-validation-fd-leak.patch keywords: patch messages: 387589 nosy: cptpcrd priority: normal severity: normal status: open title: subprocess.Popen leaks file descriptors opened for DEVNULL or PIPE stdin/stdout/stderr arguments type: resource usage versions: Python 3.10, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49830/subprocess-validation-fd-leak.patch _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Tue Feb 23 18:42:25 2021 From: report at bugs.python.org (bland328) Date: Tue, 23 Feb 2021 23:42:25 +0000 Subject: [New-bugs-announce] [issue43309] str.replace() TypeError exception message backward Message-ID: <1614123745.38.0.870290425288.issue43309@roundup.psfhosted.org> New submission from bland328 : Attempting to replace a character in a bytes string literal results in an exception saying that "a bytes-like object is required, not 'str'", when (unless I'm missing something) it should say the opposite. To repro: >>> x=b'abc' >>> x.replace('a','z') Traceback (most recent call last): File "", line 1, in TypeError: a bytes-like object is required, not 'str' ---------- messages: 387593 nosy: bland328 priority: normal severity: normal status: open title: str.replace() TypeError exception message backward type: behavior versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 01:44:13 2021 From: report at bugs.python.org (Andrey Petukhov) Date: Wed, 24 Feb 2021 06:44:13 +0000 Subject: [New-bugs-announce] [issue43310] Method __del__ with callable Message-ID: <1614149053.65.0.947728004035.issue43310@roundup.psfhosted.org> New submission from Andrey Petukhov : Is it possible to use callable to replace __del__ method of class? if so, how to get self variable? class A(object): """A.""" class C(object): """Callable.""" def __call__(self, *args, **kwargs): print("call", args, kwargs) def func_del(*args, **kwargs): """Method.""" print("func", args, kwargs) def del_function(): """ Test del. ('func', (<__main__.A object at 0x7f8ae5a82750>,), {}) ('call', (), {}) """ c = C() A.__del__ = func_del a = A() del a A.__del__ = c a = A() del a ---------- components: Interpreter Core messages: 387609 nosy: andribas404 priority: normal severity: normal status: open title: Method __del__ with callable versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 03:30:05 2021 From: report at bugs.python.org (junyixie) Date: Wed, 24 Feb 2021 08:30:05 +0000 Subject: [New-bugs-announce] [issue43311] PyInterpreterState_New use thread tstate before set. Message-ID: <1614155405.65.0.593028600281.issue43311@roundup.psfhosted.org> New submission from junyixie : PyInterpreterState_New use thread tstate before set. PyInterpreterState_New use tstate. but tstate is not set. tstate will set after PyInterpreterState_New. PyInterpreterState *interp = PyInterpreterState_New(); if (interp == NULL) { *tstate_p = NULL; return _PyStatus_OK(); } PyThreadState *tstate = PyThreadState_New(interp); if (tstate == NULL) { PyInterpreterState_Delete(interp); *tstate_p = NULL; return _PyStatus_OK(); } PyThreadState *save_tstate = PyThreadState_Swap(tstate); ---------- components: Subinterpreters messages: 387610 nosy: JunyiXie priority: normal severity: normal status: open title: PyInterpreterState_New use thread tstate before set. type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 04:26:40 2021 From: report at bugs.python.org (Tzu-ping Chung) Date: Wed, 24 Feb 2021 09:26:40 +0000 Subject: [New-bugs-announce] [issue43312] Interface to select preferred "user" or "home" sysconfig scheme for an environment Message-ID: <1614158800.84.0.101101658017.issue43312@roundup.psfhosted.org> New submission from Tzu-ping Chung : While trying to migrate pip?s internal usages of distutils to sysconfig,[1] I noticed there isn?t a way for pip to select a scheme for sysconfig.get_paths() for `pip install --target` and `pip install --user`. I tried to implement some logic to "guess" a scheme ("posix_home" for `--home`, "nt_user" for `--user` when os.name is "nt", etc.), but eventually hit a wall trying to support alternative implementations. PyPy, for example, adds additional schemes "pypy" and "pypy_nt", and it?s not clear whether pip should use then for `--home` or not. @mattip helped clear this up for PyPy (which also prompts bpo-43307), but we are worried that other implementations may introduce even more special rules that causes problems, and it?s also not a good idea for pip to implement special logic for every implementation. I would propose two changes to sysconfig: 1. Make sysconfig._get_default_scheme() a public function. This function will be documented for implementations to return a default scheme to use when none is given to sysconfig.get_paths(). 2. Add a new function sysconfig.get_preferred_schemes() for implementations to return preferred schemes for prefix, home, and user installations. This function should return a dict[str, str] with three keys "prefix", "home", and "user", and their values the scheme names to use. I would be happy to work on a PR and iterate on the design if this sounds like a reasonable idea. For CPython, the implementation would be something like (to match distutils?s behaviour): def get_preferred_schemes(): if os.name == "nt": return { "prefix": "nt", "home": "posix_home", "user": "nt_user", } return { "prefix": "posix_prefix", "home": "posix_home", "user": "posix_user", } [1]: https://github.com/pypa/pip/pull/9626 ---------- components: Library (Lib) messages: 387611 nosy: uranusjr priority: normal severity: normal status: open title: Interface to select preferred "user" or "home" sysconfig scheme for an environment versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 04:43:29 2021 From: report at bugs.python.org (junyixie) Date: Wed, 24 Feb 2021 09:43:29 +0000 Subject: [New-bugs-announce] [issue43313] feature: support pymalloc for subinterpreters. each subinterpreter has pymalloc_state Message-ID: <1614159809.71.0.199865657429.issue43313@roundup.psfhosted.org> New submission from junyixie : https://github.com/ericsnowcurrently/multi-core-python/issues/73 https://github.com/JunyiXie/cpython/commit/820954879fd546fcb29b654d10c424bd47da70ce changes: move pymalloc state in obmalloc.h _is add pymalloc_state pymalloc_allocxx api use subinterpreter pymalloc_state ---------- components: Subinterpreters messages: 387614 nosy: JunyiXie priority: normal severity: normal status: open title: feature: support pymalloc for subinterpreters. each subinterpreter has pymalloc_state _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 05:48:54 2021 From: report at bugs.python.org (Erlend Egeberg Aasland) Date: Wed, 24 Feb 2021 10:48:54 +0000 Subject: [New-bugs-announce] [issue43314] [sqlite3] remove pre SQLite 3.7.7 support code Message-ID: <1614163734.14.0.841142847915.issue43314@roundup.psfhosted.org> New submission from Erlend Egeberg Aasland : I missed the SQLITE_OPEN_URI #ifdef in GH-24106. The "open URI" interface was added in 3.7.7. The dead code can safely be removed. $ grep -r SQLITE_OPEN_URI sqlite-3.7.6/ $ grep -r SQLITE_OPEN_URI sqlite-3.7.7/ [...] sqlite-3.7.7/sqlite3.h:#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ ---------- components: Library (Lib) messages: 387616 nosy: berker.peksag, erlendaasland, serhiy.storchaka priority: normal severity: normal status: open title: [sqlite3] remove pre SQLite 3.7.7 support code type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Wed Feb 24 05:59:48 2021 From: report at bugs.python.org (Szymon) Date: Wed, 24 Feb 2021 10:59:48 +0000 Subject: [New-bugs-announce] [issue43315] Decimal.__str__ has no way to force exact decimal representation Message-ID: <1614164388.53.0.057673280167.issue43315@roundup.psfhosted.org> New submission from Szymon : str(Decimal("0.00000001")) always returns "1E-8" and there is no way to directly get the "0.00000001" string back without writting custom method for converting DecimalTuple to string. This is caused by arbitrary choice of `and leftdigits > -6` condition in https://github.com/python/cpython/blob/master/Lib/_pydecimal.py#L1052 . The hardcoded value of -6 should be parametrizable. This can be done by adding it as argument to the __str__ method or maybe by adding it to the decimal context. ---------- messages: 387618 nosy: sim1234 priority: normal severity: normal status: open title: Decimal.__str__ has no way to force exact decimal representation type: enhancement 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 Feb 24 09:34:00 2021 From: report at bugs.python.org (Ruben Vorderman) Date: Wed, 24 Feb 2021 14:34:00 +0000 Subject: [New-bugs-announce] [issue43316] python -m gzip handles error incorrectly Message-ID: <1614177240.99.0.73469579254.issue43316@roundup.psfhosted.org> New submission from Ruben Vorderman : `Python -m gzip -d myfile` will throw an error because myfile does not end in '.gz'. That is fair (even though a bit redundant, GzipFile contains a header check, so why bother checking the extension?). The problem is how this error is thrown. 1. Error is printed to stdout instead of stderr 2. Tool exits with exit 0. This is not the behaviour that is expected when using python -m gzip in a script. The error is even codified in a test: https://github.com/python/cpython/blob/1f433406bd46fbd00b88223ad64daea6bc9eaadc/Lib/test/test_gzip.py#L776 def test_decompress_infile_outfile_error(self): rc, out, err = assert_python_ok('-m', 'gzip', '-d', 'thisisatest.out') self.assertIn(b"filename doesn't end in .gz:", out) self.assertEqual(rc, 0) self.assertEqual(err, b'') This should be assert_python_failure, out and err should be swapped, and exit code should be something different than 0. >From the zen of python: Errors should never pass silently. I am willing to fix this in a PR, but first I would like some feedback on how to solve this exactly. I propose raising a ValueError("can not determine output filename: 'myfile' does not end in '.gz'"). ---------- components: Library (Lib) messages: 387622 nosy: rhpvorderman priority: normal severity: normal status: open title: python -m gzip handles error incorrectly 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 Feb 24 10:06:00 2021 From: report at bugs.python.org (Ruben Vorderman) Date: Wed, 24 Feb 2021 15:06:00 +0000 Subject: [New-bugs-announce] [issue43317] python -m gzip could use a larger buffer Message-ID: <1614179160.12.0.374051475595.issue43317@roundup.psfhosted.org> New submission from Ruben Vorderman : python -m gzip reads in chunks of 1024 bytes: https://github.com/python/cpython/blob/1f433406bd46fbd00b88223ad64daea6bc9eaadc/Lib/gzip.py#L599 This hurts performance somewhat. Using io.DEFAULT_BUFFER_SIZE will improve it. Also 'io.DEFAULT_BUFFER_SIZE' is better than: 'ARBITRARY_NUMBER_WITH_NO_COMMENT_EXPLAINING_WHY'. With 1024 blocks Decompression: $ hyperfine -r 10 -w 3 'cat ~/test/500000reads.fastq.gz | ./prefix/bin/python3 -m gzip -d > /dev/null' Benchmark #1: cat ~/test/500000reads.fastq.gz | ./prefix/bin/python3 -m gzip -d > /dev/null Time (mean ? ?): 926.9 ms ? 7.7 ms [User: 901.2 ms, System: 59.1 ms] Range (min ? max): 913.3 ms ? 939.4 ms 10 runs Compression: $ hyperfine -r 10 -w 3 'cat ~/test/500000reads.fastq | ./prefix/bin/python3 -m gzip --fast > /dev/null' Benchmark #1: cat ~/test/500000reads.fastq | ./prefix/bin/python3 -m gzip --fast > /dev/null Time (mean ? ?): 2.514 s ? 0.030 s [User: 2.469 s, System: 0.125 s] Range (min ? max): 2.472 s ? 2.563 s 10 runs with io.DEFAULT_BUFFER_SIZE Decompression: $ hyperfine -r 10 -w 3 'cat ~/test/500000reads.fastq.gz | ./prefix/bin/python3 -m gzip -d > /dev/null' Benchmark #1: cat ~/test/500000reads.fastq.gz | ./prefix/bin/python3 -m gzip -d > /dev/null Time (mean ? ?): 839.9 ms ? 7.3 ms [User: 816.0 ms, System: 57.3 ms] Range (min ? max): 830.1 ms ? 851.3 ms 10 runs Compression: $ hyperfine -r 10 -w 3 'cat ~/test/500000reads.fastq | ./prefix/bin/python3 -m gzip --fast > /dev/null' Benchmark #1: cat ~/test/500000reads.fastq | ./prefix/bin/python3 -m gzip --fast > /dev/null Time (mean ? ?): 2.275 s ? 0.024 s [User: 2.247 s, System: 0.096 s] Range (min ? max): 2.254 s ? 2.322 s 10 runs Speedups: - Decompression 840 / 927 = 0.906 ~= 9% reduction in runtime - Compression 2.275 / 2.514 = 0.905 ~= 9% reduction in runtime. It is not stellar, but it is a quite nice improvement for such a tiny change. ---------- components: Library (Lib) messages: 387624 nosy: rhpvorderman priority: normal severity: normal status: open title: python -m gzip could use a larger buffer 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 Feb 25 01:55:08 2021 From: report at bugs.python.org (huzhaojie) Date: Thu, 25 Feb 2021 06:55:08 +0000 Subject: [New-bugs-announce] [issue43318] pdb can't output the prompt message when successfully clear a breakpoint by "filename:lineno" Message-ID: <1614236108.11.0.116062540393.issue43318@roundup.psfhosted.org> Change by huzhaojie : ---------- components: Library (Lib) nosy: hjzin priority: normal severity: normal status: open title: pdb can't output the prompt message when successfully clear a breakpoint by "filename:lineno" type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 03:31:46 2021 From: report at bugs.python.org (cmhzc) Date: Thu, 25 Feb 2021 08:31:46 +0000 Subject: [New-bugs-announce] [issue43319] A possible misleading expression in the Virtual Environment Tutorial Message-ID: <1614241906.48.0.234906735386.issue43319@roundup.psfhosted.org> Change by cmhzc : ---------- assignee: docs at python components: Documentation nosy: cmhzc, docs at python priority: normal severity: normal status: open title: A possible misleading expression in the Virtual Environment Tutorial type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 08:41:32 2021 From: report at bugs.python.org (Fabian Beitler) Date: Thu, 25 Feb 2021 13:41:32 +0000 Subject: [New-bugs-announce] [issue43320] test test_webbrowser "can't locate runnable browser" with enable-optimizations Message-ID: <1614260492.83.0.266852228438.issue43320@roundup.psfhosted.org> New submission from Fabian Beitler : I downloaded the sources for python 3.8.8 (not tested with Python3.9.2. so far)and compiled it with enabled-optimisations parameter on a fresh Ubuntu 20.04 machine. Beside the test_ssl error (there is an existing workaround, but still not happy with that one tbh) I could solve, the test "test_webbrowser" fails and I don't know how to handle that one. ERROR: test_synthesize(test_webbrowser.ImportTest) ---------------------------------------------------------------- Traceback (most recent call last): File "Path/Python-3.8.8/Lib/test/test_webbrowser.py", line 299, in test_synthesize webbrowser.get(sys.executable) File "Path/Python-3.8.8/Lib/webbrowser.py", line 65, in get raise Error("could not locate runnable browser") webbrowser.Error: could not locate runnable browser ---------- components: Tests messages: 387672 nosy: swamper123 priority: normal severity: normal status: open title: test test_webbrowser "can't locate runnable browser" with enable-optimizations versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 11:05:25 2021 From: report at bugs.python.org (Robert) Date: Thu, 25 Feb 2021 16:05:25 +0000 Subject: [New-bugs-announce] [issue43321] PyArg_ParseTuple() false-returns SUCCESS though SystemError and missing data (when PY_SSIZE_T_CLEAN not #define'd) Message-ID: <1614269125.06.0.289577576658.issue43321@roundup.psfhosted.org> New submission from Robert : When PY_SSIZE_T_CLEAN is not #defined in Py3.10, PyArg_ParseTuple() etc. sets a SystemError but the return value says 1 (=SUCCESS)! => Causes terrific crashes with unfilled variables - instead of a clean Python exception. Background: pywin32 suffers in masses from the drop of int support for the s#/y#/et#... formats in PyArg_ParseTuple() etc. (PY_SSIZE_T_CLEAN is required in Py3.10). And only part of the source is already PY_SSIZE_T_CLEAN. Now it is very difficult to even run tests and weed out / check, because of freezes instead of nice Python exceptions. => Instead of preventing such freezes, the PY_SSIZE_T_CLEAN mechanism became the opposite: a clever trap, a sword of Damocles :) The cause is in getargs.c: =================== getargs.c / convertsimple() ==== #define REQUIRE_PY_SSIZE_T_CLEAN \ if (!(flags & FLAG_SIZE_T)) { \ PyErr_SetString(PyExc_SystemError, \ "PY_SSIZE_T_CLEAN macro must be defined for '#' formats"); \ return NULL; \ } #define RETURN_ERR_OCCURRED return msgbuf =================== => The return NULL is further processed as no msg NULL -> no error. => Perhaps it should be a `return converterr(...)` or `return sstc_system_error(...)` !? ---------- components: Interpreter Core messages: 387678 nosy: kxrob priority: normal severity: normal status: open title: PyArg_ParseTuple() false-returns SUCCESS though SystemError and missing data (when PY_SSIZE_T_CLEAN not #define'd) type: crash versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 11:18:54 2021 From: report at bugs.python.org (Matthew Hughes) Date: Thu, 25 Feb 2021 16:18:54 +0000 Subject: [New-bugs-announce] [issue43322] Inconsistent '#include' notation in extensions tutorial doc Message-ID: <1614269934.51.0.264833374893.issue43322@roundup.psfhosted.org> New submission from Matthew Hughes : Just a small thing in these docs, there is a mix of "#include ", e.g. https://github.com/python/cpython/blame/master/Doc/extending/newtypes_tutorial.rst#L243 and '#include "structmember.h"', mostly in the included samples e.g. https://github.com/python/cpython/blob/master/Doc/includes/custom2.c#L3. Should these all be the same? ---------- assignee: docs at python components: Documentation messages: 387679 nosy: docs at python, mhughes priority: normal severity: normal status: open title: Inconsistent '#include' notation in extensions tutorial doc versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 13:18:08 2021 From: report at bugs.python.org (Anders Kaseorg) Date: Thu, 25 Feb 2021 18:18:08 +0000 Subject: [New-bugs-announce] [issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset Message-ID: <1614277088.24.0.58040288739.issue43323@roundup.psfhosted.org> New submission from Anders Kaseorg : We ran into a UnicodeEncodeError exception using email.parser to parse this email , with full headers available in the raw archive . The offending header is hilariously invalid: Content-Type: text/plain; charset*=utf-8?''utf-8%E2%80%9D but I?m filing an issue since the parser is intended to be robust against invalid input. Minimal reproduction: >>> import email, email.policy >>> email.message_from_bytes(b"Content-Type: text/plain; charset*=utf-8\xE2\x80\x9D''utf-8%E2%80%9D", policy=email.policy.default) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.10/email/__init__.py", line 46, in message_from_bytes return BytesParser(*args, **kws).parsebytes(s) File "/usr/local/lib/python3.10/email/parser.py", line 123, in parsebytes return self.parser.parsestr(text, headersonly) File "/usr/local/lib/python3.10/email/parser.py", line 67, in parsestr return self.parse(StringIO(text), headersonly=headersonly) File "/usr/local/lib/python3.10/email/parser.py", line 57, in parse return feedparser.close() File "/usr/local/lib/python3.10/email/feedparser.py", line 187, in close self._call_parse() File "/usr/local/lib/python3.10/email/feedparser.py", line 180, in _call_parse self._parse() File "/usr/local/lib/python3.10/email/feedparser.py", line 256, in _parsegen if self._cur.get_content_type() == 'message/delivery-status': File "/usr/local/lib/python3.10/email/message.py", line 578, in get_content_type value = self.get('content-type', missing) File "/usr/local/lib/python3.10/email/message.py", line 471, in get return self.policy.header_fetch_parse(k, v) File "/usr/local/lib/python3.10/email/policy.py", line 163, in header_fetch_parse return self.header_factory(name, value) File "/usr/local/lib/python3.10/email/headerregistry.py", line 608, in __call__ return self[name](name, value) File "/usr/local/lib/python3.10/email/headerregistry.py", line 196, in __new__ cls.parse(value, kwds) File "/usr/local/lib/python3.10/email/headerregistry.py", line 453, in parse kwds['decoded'] = str(parse_tree) File "/usr/local/lib/python3.10/email/_header_value_parser.py", line 126, in __str__ return ''.join(str(x) for x in self) File "/usr/local/lib/python3.10/email/_header_value_parser.py", line 126, in return ''.join(str(x) for x in self) File "/usr/local/lib/python3.10/email/_header_value_parser.py", line 798, in __str__ for name, value in self.params: File "/usr/local/lib/python3.10/email/_header_value_parser.py", line 783, in params value = value.decode(charset, 'surrogateescape') UnicodeEncodeError: 'utf-8' codec can't encode characters in position 5-7: surrogates not allowed ---------- components: email messages: 387685 nosy: andersk, barry, r.david.murray priority: normal severity: normal status: open title: UnicodeEncodeError: surrogates not allowed when parsing invalid charset 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 Feb 25 17:47:07 2021 From: report at bugs.python.org (Hasan) Date: Thu, 25 Feb 2021 22:47:07 +0000 Subject: [New-bugs-announce] [issue43324] asyncio Message-ID: <1614293227.43.0.791416347033.issue43324@roundup.psfhosted.org> New submission from Hasan : Added socket getfqdn and gethostbyaddr functions with threadpoolexecutor to asyncio library ---------- messages: 387690 nosy: AliyevH priority: normal severity: normal status: open title: asyncio type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 18:11:20 2021 From: report at bugs.python.org (Anthony Flury) Date: Thu, 25 Feb 2021 23:11:20 +0000 Subject: [New-bugs-announce] [issue43325] Documentation should warn that 'is' is not a safe comparison operator for most values. Message-ID: <1614294680.42.0.115546489096.issue43325@roundup.psfhosted.org> New submission from Anthony Flury : A frequent bug for beginners is to assume that 'is' is somehow 'better' then '==' when comparing values, and it is certainly a cause for confusion amongst beginners as to why: [1,2] is [1,2] evaluates to False but 'a' is 'a' evaluates to True and many similar examples. As far as I can see the first mention of the 'is' operator is under Section 5 - More on conditionals : https://docs.python.org/3/tutorial/datastructures.html?highlight=comparison#comparing-sequences-and-other-types; and it is mentioned thus : The operators is and is not compare whether two objects are really the same object; this only matters for mutable objects like lists. As we know though this statement is misleading - it suggests that 'is' can be used to compare immutable values (ints, strings, tuples) etc, and while for some values of some immutables (small ints, shortish strings) 'is' can be used as an equivalent of '==' it wont be clear from this 'statement' that 'is' is simply not a safe way to compare values. There needs to be a warning here about 'is' and how it is not an equivalent to '==' in any general sense. ---------- assignee: docs at python components: Documentation messages: 387692 nosy: anthony-flury, docs at python priority: normal severity: normal status: open title: Documentation should warn that 'is' is not a safe comparison operator for most values. type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Thu Feb 25 22:27:00 2021 From: report at bugs.python.org (Fcant) Date: Fri, 26 Feb 2021 03:27:00 +0000 Subject: [New-bugs-announce] [issue43326] About Zipfile Message-ID: <1614310020.48.0.485375340056.issue43326@roundup.psfhosted.org> New submission from Fcant : When I Unzip a package using the zipfile module, the package?s filename has a newline character, which causes the Unzip to fail, so the UNZIP filename needs to be processed ---------- components: Library (Lib) files: Fcant_2021-02-26_11-26-37.jpg messages: 387705 nosy: Fcscanf priority: normal severity: normal status: open title: About Zipfile type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file49836/Fcant_2021-02-26_11-26-37.jpg _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 04:39:06 2021 From: report at bugs.python.org (Zackery Spytz) Date: Fri, 26 Feb 2021 09:39:06 +0000 Subject: [New-bugs-announce] [issue43327] The docs falsely state that PyImport_ImportFrozenModuleObject() returns a new reference Message-ID: <1614332346.77.0.251072894564.issue43327@roundup.psfhosted.org> New submission from Zackery Spytz : The docs state that PyImport_ImportFrozenModuleObject() returns a new reference, but it actually returns an int. https://docs.python.org/3.10/c-api/import.html#c.PyImport_ImportFrozenModuleObject ---------- assignee: docs at python components: Documentation messages: 387716 nosy: ZackerySpytz, docs at python priority: normal severity: normal status: open title: The docs falsely state that PyImport_ImportFrozenModuleObject() returns a new reference versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 07:27:17 2021 From: report at bugs.python.org (Alexei S) Date: Fri, 26 Feb 2021 12:27:17 +0000 Subject: [New-bugs-announce] [issue43328] make test errors Message-ID: <1614342437.38.0.34857180933.issue43328@roundup.psfhosted.org> New submission from Alexei S : this commands are successful: CXX=/usr/bin/g++ ./configure --enable-optimizations >> log_configure.log make -j4 >> log_make.log errors on make test: make -j4 test >> log_make_test.log my system: uname -a Linux home 5.8.0-43-generic #49~20.04.1-Ubuntu SMP Fri Feb 5 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Linux Mint 20.1 x64 Cinnamon ---------- files: PythonCompileLogs.tar.gz messages: 387723 nosy: asholomitskiy84 priority: normal severity: normal status: open title: make test errors type: compile error versions: Python 3.9 Added file: https://bugs.python.org/file49838/PythonCompileLogs.tar.gz _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 09:31:42 2021 From: report at bugs.python.org (Michael L. Boom) Date: Fri, 26 Feb 2021 14:31:42 +0000 Subject: [New-bugs-announce] [issue43329] Multiprocessing Manager Client Not Reconnecting Message-ID: <1614349902.25.0.128405443976.issue43329@roundup.psfhosted.org> New submission from Michael L. Boom : The client doesn't reconnect automatically, or explicitly. I just get BrokenPipeError over and over. Manager: import multiprocessing.managers, os, sys, time class TestClass(object): def test_method(self): print("In test_method") return "TEST" class TestManager(multiprocessing.managers.BaseManager): pass address = ("127.0.0.1", 54321) TestManager.register("Test", TestClass) manager = TestManager(address = address, authkey = "1234".encode("utf-8")) manager.get_server().serve_forever() Client: import multiprocessing.managers, os, sys, time class TestManager(multiprocessing.managers.BaseManager): pass address = ("127.0.0.1", 54321) TestManager.register("Test") manager = TestManager(address = address, authkey = "1234".encode("utf-8")) manager.connect() test_class = manager.Test() def call_it(): time.sleep(1) result = test_class.test_method() print("result: '" + str(type(result)) + ", " + str(result) + "'") call_it() print("Kill and restart the server and press return") sys.stdin.readline() error = False while (True): try: if (error): print("Reconnecting") manager.connect() test_class = manager.Test() call_it() error = False except Exception as e: print("Got exception " + str(type(e)) + ", " + repr(e)) error = True time.sleep(1) ---------- components: Library (Lib) messages: 387726 nosy: boom0192 priority: normal severity: normal status: open title: Multiprocessing Manager Client Not Reconnecting type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 12:02:19 2021 From: report at bugs.python.org (Julien Castiaux) Date: Fri, 26 Feb 2021 17:02:19 +0000 Subject: [New-bugs-announce] [issue43330] xmlrpc.Server URI query and fragment are discarded from HTTP query since py3 Message-ID: <1614358939.96.0.184711772416.issue43330@roundup.psfhosted.org> New submission from Julien Castiaux : Hello, There is a backward incompatibility between xmlrpc.client and xmlrpclib in server classes about how the URI is parsed and used to connect to the remote server. While py2's xmlrpclib use the path, query and fragment parts of the URI request the server, py3's xmlrpc.client solely uses the path and discard both the query and the fragment parts. In the ProxyServer init method, py2 xmlrpclib does the following to extract the URI: def __init__(self, uri, transport=None, encoding=None, verbose=0, allow_none=0, use_datetime=0, context=None): import urllib type, uri = urllib.splittype(uri) self.__host, self.__handler = urllib.splithost(uri) if not self.__handler: self.__handler = "/RPC2" While in ProxyServer init method, py3 xmlrpc.client does the following: def __init__(self, uri, transport=None, encoding=None, verbose=False, allow_none=False, use_datetime=False, use_builtin_types=False, *, headers=(), context=None): p = urllib.parse.urlparse(uri) self.__host = p.netloc self.__handler = p.path or "/RPC2" A Pull Request is coming shortly ---------- components: Library (Lib) messages: 387730 nosy: Julien Castiaux priority: normal severity: normal status: open title: xmlrpc.Server URI query and fragment are discarded from HTTP query since py3 type: behavior versions: Python 3.6 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 14:07:45 2021 From: report at bugs.python.org (Alix Lourme) Date: Fri, 26 Feb 2021 19:07:45 +0000 Subject: [New-bugs-announce] [issue43331] [Doc][urllib.request] Explicit the fact that header keys are sent in Camel case Message-ID: <1614366465.63.0.480408878251.issue43331@roundup.psfhosted.org> New submission from Alix Lourme : Currently, the Request (https://docs.python.org/3/library/urllib.request.html#urllib.request.Request) send header keys in Camel case. This is a choice strategy (no problem with that) and even if headers should be considered insensitively (RFC 7230 - 3.2. Header Fields: https://tools.ietf.org/html/rfc7230#section-3.2), this is not always the case. The fact that header keys are "rewritten" (in Camel case) could occurs complexity in troubleshooting (for sample: https://github.com/probot/adapter-aws-lambda-serverless/issues/62). Having a note/mention about that in documentation would be nice. PR will come. ---------- assignee: docs at python components: Documentation messages: 387736 nosy: axel3rd, docs at python priority: normal severity: normal status: open title: [Doc][urllib.request] Explicit the fact that header keys are sent in Camel case type: behavior versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 15:18:00 2021 From: report at bugs.python.org (Zveinn) Date: Fri, 26 Feb 2021 20:18:00 +0000 Subject: [New-bugs-announce] [issue43332] def _tunnel(self): - uses multiple network writes, possibly causing unnecessary implementation complexity on the receiving end Message-ID: <1614370680.1.0.103129903648.issue43332@roundup.psfhosted.org> New submission from Zveinn : Hey, some time ago I ran into some code in the cpython code I thought might be possible to improve it a little bit. https://github.com/python/cpython/blob/master/Lib/http/client.py#L903 This code specifically. Notice how the self.send() method is used multiple time to construct the CONNECT request. When the network load is high, these different parts actually get split into separate network frames. This causes additional meta data to be sent, effectively costing more bandwidth and causing the request to be split into multiple network frames. This has some interesting behavior on the receiving end as well. If you send everything as a single network frame, then the receiver can read the entire thing in a single read call. If you send multiple frames, the main reader pipe now needs a temporary buffer to encapsulate the multiple calls. Because of this, sending requests as many network frames actually causes a rise in processing complexity on the receiving end. Here is a github issue I made about this problem some time ago: https://github.com/psf/requests/issues/5384 In this issue you will find detailed information and screenshots. My recommendation would be to construct the query as a whole before using a single self.send() to send the whole payload in one network frame. Even if we ignore the added complexity on the receivers end, the gain in network performance is worth it. ---------- components: C API messages: 387742 nosy: zveinn priority: normal severity: normal status: open title: def _tunnel(self): - uses multiple network writes, possibly causing unnecessary implementation complexity on the receiving end type: performance versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 16:50:13 2021 From: report at bugs.python.org (Darcy Beurle) Date: Fri, 26 Feb 2021 21:50:13 +0000 Subject: [New-bugs-announce] [issue43333] utf8 in BytesGenerator Message-ID: <1614376213.69.0.504043333554.issue43333@roundup.psfhosted.org> New submission from Darcy Beurle : I have some emails that I'm importing from an XML format according to rfc822. Some of these have some encoding other than ascii. I create the message with the default policy: message = email.message_from_string( # Extract text from xml message_name.find("property_string").text, policy=email.policy.default) Then I want to convert this to bytes so I can append it to an IMAP folder using the imap_tools package: mailbox.append(email.as_bytes(), "INBOX", dt=None, flag_set=(imap_tools.MailMessageFlags.SEEN)) Which then leads to the following output: line 405, in parse_goldmine_output email.as_bytes(), File "/usr/lib64/python3.9/email/message.py", line 178, in as_bytes g.flatten(self, unixfrom=unixfrom) File "/usr/lib64/python3.9/email/generator.py", line 116, in flatten self._write(msg) File "/usr/lib64/python3.9/email/generator.py", line 181, in _write self._dispatch(msg) File "/usr/lib64/python3.9/email/generator.py", line 218, in _dispatch meth(msg) File "/usr/lib64/python3.9/email/generator.py", line 276, in _handle_multipart g.flatten(part, unixfrom=False, linesep=self._NL) File "/usr/lib64/python3.9/email/generator.py", line 116, in flatten self._write(msg) File "/usr/lib64/python3.9/email/generator.py", line 181, in _write self._dispatch(msg) File "/usr/lib64/python3.9/email/generator.py", line 218, in _dispatch meth(msg) File "/usr/lib64/python3.9/email/generator.py", line 436, in _handle_text super(BytesGenerator,self)._handle_text(msg) File "/usr/lib64/python3.9/email/generator.py", line 253, in _handle_text self._write_lines(payload) File "/usr/lib64/python3.9/email/generator.py", line 155, in _write_lines self.write(line) File "/usr/lib64/python3.9/email/generator.py", line 410, in write self._fp.write(s.encode('ascii', 'surrogateescape')) UnicodeEncodeError: 'ascii' codec can't encode characters in position 41-43: ordinal not in range(128) If I change the line: self._fp.write(s.encode('ascii', 'surrogateescape')) to: self._fp.write(s.encode('utf8', 'surrogateescape')) then it writes the email body with the strange characters (same as in the xml). I'm not sure how to proceed. Those emails should be able to be processed, but the bytes writer doesn't seem to inherit the utf8 encoding from anywhere (e.g. if a utf8 policy is used). ---------- components: email messages: 387749 nosy: barry, darcy.beurle, r.david.murray priority: normal severity: normal status: open title: utf8 in BytesGenerator type: crash versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 17:40:16 2021 From: report at bugs.python.org (Anup Parikh) Date: Fri, 26 Feb 2021 22:40:16 +0000 Subject: [New-bugs-announce] [issue43334] venv does not install libpython Message-ID: <1614379216.7.0.137032053148.issue43334@roundup.psfhosted.org> New submission from Anup Parikh : The libpython.a or libpython.so objects are not copied/linked in new virtual environments when created with venv. ---------- components: C API, Installation, Library (Lib) messages: 387752 nosy: anuppari priority: normal severity: normal status: open title: venv does not install libpython type: behavior _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 18:28:21 2021 From: report at bugs.python.org (DANIEL VILLENEUVE) Date: Fri, 26 Feb 2021 23:28:21 +0000 Subject: [New-bugs-announce] [issue43335] _ctypes/callbacks.c cannot be compiled by gcc 4.4.7 (RHEL6) Message-ID: <1614382101.65.0.823517794704.issue43335@roundup.psfhosted.org> New submission from DANIEL VILLENEUVE : gcc 4.4.7 does not accept #pragma's inside functions. I made the following patch, inspired by code found in other Python source files. diff -r U/Python-3.9.2/Modules/_ctypes/callbacks.c V/Python-3.9.2/Modules/_ctypes/callbacks.c 433c433 < #if defined(__GNUC__) --- > #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))) 442c442 < #if defined(__GNUC__) --- > #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))) Regards ---------- components: ctypes messages: 387755 nosy: dvilleneuve priority: normal severity: normal status: open title: _ctypes/callbacks.c cannot be compiled by gcc 4.4.7 (RHEL6) type: compile error versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Fri Feb 26 21:15:37 2021 From: report at bugs.python.org (Christoph Anton Mitterer) Date: Sat, 27 Feb 2021 02:15:37 +0000 Subject: [New-bugs-announce] [issue43336] document whether io.TextIOBase.readline(size>0) will always read the full newline Message-ID: <1614392137.45.0.448589201829.issue43336@roundup.psfhosted.org> New submission from Christoph Anton Mitterer : Hey. It would be nice if the following behaviour could be definitely clarified: When reading from a text stream with readline(size) with a n > 0size it says: "If size is specified, at most size characters will be read." Also, depending on the settings of newlines of the stream, \r\n would be converted to \n. It's not definitely clear whether a string like "abc\r\n" read with a size of = 4 will return "abc\n" (which it seems to do, in other words, it reads actually 5 characters, but sill returns only 4), or whether it returns "abc\r". Cheers, Chris. ---------- assignee: docs at python components: Documentation messages: 387758 nosy: calestyo, docs at python priority: normal severity: normal status: open title: document whether io.TextIOBase.readline(size>0) will always read the full newline _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 00:45:28 2021 From: report at bugs.python.org (Christoph Anton Mitterer) Date: Sat, 27 Feb 2021 05:45:28 +0000 Subject: [New-bugs-announce] [issue43337] export the set newline value on TextIOBase/TextIOWrapper Message-ID: <1614404728.94.0.258919800539.issue43337@roundup.psfhosted.org> New submission from Christoph Anton Mitterer : Hey. It seems there is no way to determine the newline value (None, '', \n, \r, \r\n) of a given text stream. .newlines rather gives the newlines that have been encountered so far. Just like .encoding and .errors this would be quite useful for anything that gets a stream and operates on it, possibly needing to know which newlines it will see when reading from the stream. One example would be, after line = stream.readline(4096+n) one want's to know whether actually a full line of 4096 characters has been read. Putting aside newline="", for simplicity here, n already depends on whether newline was None, \n, \r or \r\n, as would any check like line.endswith(foo). Maybe some attribute, that indicates the most recently read newline in newline="" mode, would be helpful, too. Cheers, Chris. ---------- components: IO messages: 387767 nosy: calestyo priority: normal severity: normal status: open title: export the set newline value on TextIOBase/TextIOWrapper type: enhancement _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 05:07:25 2021 From: report at bugs.python.org (Zhang Boyang) Date: Sat, 27 Feb 2021 10:07:25 +0000 Subject: [New-bugs-announce] [issue43338] [feature request] Please provide offical installers for security releases Message-ID: <1614420445.03.0.702209147206.issue43338@roundup.psfhosted.org> New submission from Zhang Boyang : Hello, Thanks for developing Python! I noticed there is no offical installers for security releases of old python version. This looks a little strange to me. As a python user & developer, it's often to stay with some old version of python, because some package's version constraints, or we need to support old platforms. The offical installer is the most trusted installaion source, but it's not provided with security releases. Lacking of installers makes installaion extreme difficult (impossible for end users), and there's no (free) way for a individual to create a code signed copy of python. Non-code-signed binarys will lead a lot of problem on recent operating systems. The choice of providing no offical installer leads a lot of user stay with lastest bug-fix release and not upgrading to latest security releases. Individuals who want to stay with a old version must either use lastest bug-fix release or risk running a non-code-signed python binary. The former lacks recent python security fix, and the latter is vulnerable to binary modifications such as virus infection. To sum up, if offical installer is provided, it will make life a lot easier for users who want to stay with old python version. It would be appreciated if you could accept my feature request. Thank you! ---------- components: Installation messages: 387774 nosy: zby1234 priority: normal severity: normal status: open title: [feature request] Please provide offical installers for security releases type: enhancement versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 06:43:37 2021 From: report at bugs.python.org (Samuel Marks) Date: Sat, 27 Feb 2021 11:43:37 +0000 Subject: [New-bugs-announce] [issue43339] Could not build the ssl module! | macOS with `CPPFLAGS` and `LDFLAGS` set Message-ID: <1614426217.53.0.648681369165.issue43339@roundup.psfhosted.org> New submission from Samuel Marks : I was on 3.10a4 on macOS 11.1 for ages, finally decided to upgrade to a5, building from source. With latest `brew install openssl zlib`. ``` $ export LDFLAGS='-L/usr/local/opt/openssl at 1.1/lib -L/usr/local/opt/zlib/lib' $ export CPPFLAGS='-I/usr/local/opt/openssl at 1.1/include -I/usr/local/opt/zlib/include' $ ./configure --enable-optimizations --prefix /opt/python3.10 ``` I suppose I could set this which I forgot, but I doubt it's the problem, unless pkg_config is how the CPython build system find OpenSSL? ``` export PKG_CONFIG_PATH='/usr/local/opt/openssl at 1.1/lib/pkgconfig' ``` Error: ``` Python build finished successfully! The necessary bits to build these optional modules were not found: _hashlib _ssl ossaudiodev spwd To find the necessary bits, look in setup.py in detect_modules() for the module's name. The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc pwd time Could not build the ssl module! Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host(). LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381 ``` Happy to test alternative configurations ---------- components: Build messages: 387777 nosy: samuelmarks priority: normal severity: normal status: open title: Could not build the ssl module! | macOS with `CPPFLAGS` and `LDFLAGS` set versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 13:24:21 2021 From: report at bugs.python.org (Matthew Woodcraft) Date: Sat, 27 Feb 2021 18:24:21 +0000 Subject: [New-bugs-announce] [issue43340] json.load() can raise UnicodeDecodeError, but this is not documented Message-ID: <1614450261.52.0.147425024304.issue43340@roundup.psfhosted.org> New submission from Matthew Woodcraft : The documentation for json.load() and json.loads() says: ? If the data being deserialized is not a valid JSON document, a JSONDecodeError will be raised. ? But this is not currently entirely true: if the data is provided in bytes form and is not properly encoded in one of the three accepted encodings, UnicodeDecodeError is raised instead. (I have no opinion on whether the documentation or the behaviour should be changed.) ---------- components: Library (Lib) messages: 387780 nosy: mattheww priority: normal severity: normal status: open title: json.load() can raise UnicodeDecodeError, but this is not documented 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 Sat Feb 27 13:37:25 2021 From: report at bugs.python.org (Dan Snider) Date: Sat, 27 Feb 2021 18:37:25 +0000 Subject: [New-bugs-announce] [issue43341] functools.partial missing __weakref__ descriptor? Message-ID: <1614451045.31.0.00161523259974.issue43341@roundup.psfhosted.org> New submission from Dan Snider : The only way to lookup weak references to functools.partial objects is with weakref.getweakrefs. I don't know if it's normal for extension types that define tp_weaklistoffset to not add a __weakref__ descriptor, but I figured at the very least a subtype specifying "__weakref__" in its __slots__ could get one. Instead, it fails with the partially true TypeError: __weakref__ slot disallowed: either we already got one, or __itemsize__ != 0. ---------- messages: 387781 nosy: bup priority: normal severity: normal status: open title: functools.partial missing __weakref__ descriptor? type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 14:08:59 2021 From: report at bugs.python.org (Piyush Patel) Date: Sat, 27 Feb 2021 19:08:59 +0000 Subject: [New-bugs-announce] [issue43342] Error while using Python C API Message-ID: <1614452939.17.0.0398730160049.issue43342@roundup.psfhosted.org> New submission from Piyush Patel : Hi, I am facing a very strange issue. I am working on a C++ application which embeds a python. As per documentation i have the dependencies added from python (/libs and /include directories) to C++ application. I am using Py_RunString() to run simple python code. Python code is simple: import os def Func(): return 10.0 The application run smoothly when i have python installation in directory like "C:\PythonXY\" but if python installation is in directory like "C:\MyPython\" or default installation path AppData\local\program\python\pythonxy\ , python code errors out. the error i am getting is "__import__ not found". I have used PyErr_Fetch to retrieve error. It's really strange that the python installation directory affects how Python code is run. It seems it have a problem running "import os" statement or any "import" statement. Could you help me how i can resolve this issue? Thanks, Piyush ---------- components: C API messages: 387783 nosy: piyush115 priority: normal severity: normal status: open title: Error while using Python C API type: compile error versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 14:57:15 2021 From: report at bugs.python.org (Chigozirim Chukwu) Date: Sat, 27 Feb 2021 19:57:15 +0000 Subject: [New-bugs-announce] [issue43343] argparse.REMAINDER missing in online documentation for 3.9.x Message-ID: <1614455835.4.0.44415044742.issue43343@roundup.psfhosted.org> New submission from Chigozirim Chukwu : Since 3.9.0, the online documentation for the argparse module is missing reference for argparse.REMAINDER. If the feature has been deprecated, can we get atleast a mention in the deprecation notes as to what one should now prefer. If it was just a mistake, then I guess I'm just here to bring some attention to it. Thanks ---------- components: Library (Lib) messages: 387786 nosy: smac89 priority: normal severity: normal status: open title: argparse.REMAINDER missing in online documentation for 3.9.x type: enhancement versions: Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sat Feb 27 17:44:17 2021 From: report at bugs.python.org (Kevin Hollingshead) Date: Sat, 27 Feb 2021 22:44:17 +0000 Subject: [New-bugs-announce] [issue43344] RotatingFileHandler breaks file type associations Message-ID: <1614465857.24.0.529577943251.issue43344@roundup.psfhosted.org> New submission from Kevin Hollingshead : The filenames generated by logging.RotatingFileHandler breaks the ability to associate a program (e.g. notepad++, sublime text, etc.) with the log files using Windows or OSX file associations because the extension is overridden by the added suffix. For example, if I specify the filename as "test.log" for a TimeBasedRotatingFileHandler with a suffix of "%Y%m%d", rolled over files are named test.log.YYYYMMDD. There is no way to associate a program with this type of file extension. A good non-breaking fix would be to add a parameter "extension" to RotatingFileHandler, and if specified would be applied to all filenames. Thus if I specify filename="test" and "extension="log" for my handler it would give "test.log" for the initial file and "test.YYYYMMDD.log" for rollover files. ---------- components: Extension Modules files: logger_bug.py messages: 387793 nosy: kh14821 priority: normal severity: normal status: open title: RotatingFileHandler breaks file type associations type: behavior Added file: https://bugs.python.org/file49840/logger_bug.py _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 28 00:18:12 2021 From: report at bugs.python.org (Paul Bryan) Date: Sun, 28 Feb 2021 05:18:12 +0000 Subject: [New-bugs-announce] [issue43345] Add __required_keys__ and __optional_keys__ to TypedDict documentation Message-ID: <1614489492.56.0.834982416077.issue43345@roundup.psfhosted.org> New submission from Paul Bryan : >From Typing-sig list: On Thu, Feb 11, 2021 at 10:54 PM Paul Bryan wrote: > I don't think __required_keys__ or __optional_keys__ are documented, at least not in https://docs.python.org/3.10/library/typing.html. Is there any reason we can't codify them in 3.10 docs? On Fri, 2021-02-12 at 14:23 -0800, Guido van Rossum wrote: > Nobody got to it yet? Maybe you'd be willing to submit a small PR for this? ---------- assignee: docs at python components: Documentation messages: 387802 nosy: docs at python, pbryan priority: normal severity: normal status: open title: Add __required_keys__ and __optional_keys__ to TypedDict documentation versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 28 17:54:01 2021 From: report at bugs.python.org (Eryk Sun) Date: Sun, 28 Feb 2021 22:54:01 +0000 Subject: [New-bugs-announce] [issue43346] subprocess.run() sometimes ignores timeout in Windows Message-ID: <1614552841.1.0.31217184811.issue43346@roundup.psfhosted.org> New submission from Eryk Sun : subprocess.run() handles TimeoutExpired by terminating the process and waiting on it. In POSIX, the exception object contains the partially read stdout and stderr bytes. For example: cmd = 'echo spam; echo eggs >&2; sleep 2' try: p = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=1) except subprocess.TimeoutExpired as e: ex = e >>> ex.stdout, ex.stderr (b'spam\n', b'eggs\n') In Windows, subprocess.run() has to finish reading output with a second communicate() call, after which it manually sets the exception's stdout and stderr attributes. The poses the problem that the second communicate() call may block indefinitely, even though the child process has terminated. The primary issue is that the pipe handles may be inherited by one or more descendant processes (e.g. via shell=True), which are all regarded as potential writers that keep the pipe from closing. Reading from an open pipe that's empty will block until data becomes available. This is generally desirable for efficiency, compared to polling in a loop. But in this case, the downside is that run() in Windows will effectively ignore the given timeout. Another problem is that _communicate() writes the input to stdin on the calling thread with a single write() call. If the input exceeds the pipe capacity (4 KiB by default -- but a pipesize 'suggested' size could be supported), the write will block until the child process reads the excess data. This could block indefinitely, which will effectively ignore a given timeout. The POSIX implementation, in contrast, correctly handles a timeout in this case. Another problem is that Popen.__exit__() closes the stdout, stderr, and stdin files without regard to the _communicate() worker threads. This may seem innocuous, but if a worker thread is blocked on synchronous I/O with one of these files, WinAPI CloseHandle() will also block if it's closing the last handle for the file in the current process. (In this case, the kernel I/O manager has a close procedure that waits to acquire the file for the current thread before performing various housekeeping operations, primarily in the filesystem, such as clearing byte-range locks set by the current process.) A blocked close() is easy to demonstrate. For example: args = 'python -c "import time; time.sleep(99)"' p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE) try: p.communicate(timeout=1) except: pass p.kill() # terminates the shell process -- not python.exe with p: pass # stdout.close() blocks until python.exe exits I think the Windows implementation of Popen._communicate() needs to be redesigned as follows: * read in chunks, with a size from 1 byte up to the maximum available, as determined by _winapi.PeekNamedPipe() * write to the child's stdin on a separate thread * after communicate() has started, ensure that synchronous I/O in worker threads has been canceled via CancelSynchronousIo() before closing the pipes. The _winapi module would need to wrap OpenThread() and CancelSynchronousIo(), plus define the TERMINATE_THREAD (0x0001) access right. With the proposed changes, subprocess.run() would no longer special case TimeoutExpired for Windows. ---------- components: Library (Lib), Windows messages: 387822 nosy: eryksun, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: subprocess.run() sometimes ignores timeout in Windows type: behavior versions: Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 28 19:44:04 2021 From: report at bugs.python.org (Raymond Hettinger) Date: Mon, 01 Mar 2021 00:44:04 +0000 Subject: [New-bugs-announce] [issue43347] IDLE crashes in Message-ID: <1614559444.76.0.552687903275.issue43347@roundup.psfhosted.org> New submission from Raymond Hettinger : I'm running a python.org Mac build on Apple silicon. Python 3.10.0a5 (v3.10.0a5:b0478d738a, Feb 2 2021, 16:30:44) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin Periodically, Python freezes and requires a force quit. I'm not certain but think the trigger event is the display of a pop-up box showing attribute completions. The box is correctly shaped but filled with a solid light gray. I suspect the problem is partly in the O/S because after the freeze, I see something similar when clicking the system ? icon, so the effect extends beyond Python. However, the problem does not occur on my Mac with Intel silicon and it does not happen with Python 3.9 running on Apple silicon. This has been occurring for a while and has persisted through O/S updates. Today, it happened on Big Sur 11.2.2. Will try to get a screen shot and more details when this happens again. The event occurs often enough to make IDLE unusable for classroom demonstrations or for development. ---------- assignee: terry.reedy components: IDLE, Tkinter messages: 387824 nosy: rhettinger, ronaldoussoren, terry.reedy priority: normal severity: normal status: open title: IDLE crashes in versions: Python 3.10 _______________________________________ Python tracker _______________________________________ From report at bugs.python.org Sun Feb 28 23:16:18 2021 From: report at bugs.python.org (Tim Magee) Date: Mon, 01 Mar 2021 04:16:18 +0000 Subject: [New-bugs-announce] [issue43348] XMLRPC behaves strangely under pythonw, not under python Message-ID: <1614572178.19.0.35807455239.issue43348@roundup.psfhosted.org> New submission from Tim Magee : Summary: I run a SimpleXMLRPCServer in pythonw. When I call an exposed function the call appears to be made twice and the connection ends abnormally. This is Python 3.8.3 Windows 64-bit, with the pywin32 additions, and under Windows 7. Boo, hiss, I know -- I won't have access to a win10 machine for a week or so, but I get the impression that that won't affect this behaviour, and the post-3.8.3 changelog doesn't have anything that (to me) looks relevant in it. I've made a small reproduction that will run on one Windows machine. You need two small source files (see below): * demosrv.py - the server * democli.py - the client The method, in a CMD window: * run: start "demosrv" python demosrv.py [ runs in its own console window ] * run: python democli.py [ one instance of notepad appears and the client exits normally ] * Ctrl+C in the demosrv window to stop that * run: pythonw demosrv.py [ runs in background ] * run: python democli.py [ TWO notepad instances pop up ] [ the client crashes with an unexpected connection ] I've pasted in the two files and an example session below. This is very much cut-down from the original. Before deciding to submit I used logging at the top of the exposed function, which appeared to show it being called twice. Logging immediately before the call in the client showed only one call. Thanks, Tim #--------------8<---- demosrv.py ----8<------------------------------ from xmlrpc.server import SimpleXMLRPCServer from subprocess import Popen, DEVNULL def notepad_me(): try: cmd = ['c:\\windows\\notepad.exe'] p = Popen(cmd, stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL) return True except Exception as e: return False class NetServer(SimpleXMLRPCServer): def __init__(self, address): super(NetServer, self).__init__(address) self.register_introspection_functions() self.register_function(notepad_me) with NetServer(("0.0.0.0", 7777)) as server: server.serve_forever() #---------------8<---- democli.py ----8<----------------------------- import sys from xmlrpc.client import ServerProxy, Error def go(): try: with ServerProxy("http://localhost:7777/") as proxy: if proxy.notepad_me(): return 0 except Error as e: pass return 1 sys.exit(go()) #-------------------------------------------------------------------- d:\temp\demo>REM Run the server under python.exe d:\temp\demo>start "demosrv" python demosrv.py d:\temp\demo>python democli.py d:\temp\demo>REM That ran up one instance of notepad d:\temp\demo>REM Ctrl+C to break out the running demosrv.py d:\temp\demo>pythonw demosrv.py d:\temp\demo>REM that runs in the background d:\temp\demo>python democli.py Traceback (most recent call last): File "democli.py", line 13, in sys.exit(go()) File "democli.py", line 7, in go if proxy.notepad_me(): File "C:\Python\lib\xmlrpc\client.py", line 1109, in __call__ return self.__send(self.__name, args) File "C:\Python\lib\xmlrpc\client.py", line 1450, in __request response = self.__transport.request( File "C:\Python\lib\xmlrpc\client.py", line 1153, in request return self.single_request(host, handler, request_body, verbose) File "C:\Python\lib\xmlrpc\client.py", line 1166, in single_request resp = http_conn.getresponse() File "C:\Python\lib\http\client.py", line 1332, in getresponse response.begin() File "C:\Python\lib\http\client.py", line 303, in begin version, status, reason = self._read_status() File "C:\Python\lib\http\client.py", line 272, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response d:\temp\demo>REM as you see that ran amok d:\temp\demo>REM and it created two instances of notepad ---------- components: Windows messages: 387837 nosy: paul.moore, steve.dower, tim.golden, tim_magee, zach.ware priority: normal severity: normal status: open title: XMLRPC behaves strangely under pythonw, not under python type: behavior versions: Python 3.8 _______________________________________ Python tracker _______________________________________