[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-10-26 Thread Alexey Izbyshev


Alexey Izbyshev  added the comment:

> As a concrete example, we have a (non-Python) build system and task runner 
> that orchestrates many tasks to run in parallel. Some of those tasks end up 
> invoking Python scripts that use subprocess.run() to run other programs. Our 
> task runner intentionally passes an inheritable file descriptor that is 
> unique to each task as a form of a keep-alive token; if the child processes 
> continue to pass inheritable file descriptors to their children, then we can 
> determine whether all of the processes spawned from a task have terminated by 
> checking whither the last open handle to that file descriptor has been 
> closed. This is particularly important when a processes exits before its 
> children, sometimes uncleanly due to being force killed by the system or by a 
> user.

I don't see how such scheme could be usable in a general-purpose build system. 
Python is just one example of a program that closes file descriptors for child 
processes, but there might be arbitrary more. In general, there is no guarantee 
that a descriptor would be inherited in a process tree if it contains at least 
one process running code that you don't fully control. To properly control 
process trees, I'd suggest to consider prctl(PR_SET_CHILD_SUBREAPER) or PID 
namespaces on Linux and job objects on Windows (don't know about other OSes).

> Regarding security, PEP 446 already makes it so that any files opened from 
> within a Python program are non-inheritable by default, which I agree is a 
> good default. One can make the argument that it's not Python's job to enforce 
> a security policy on file descriptors that a Python process has inherited 
> from a parent process, since Python cannot distinguish from descriptors that 
> were accidentally or intentionally inherited.

While I agree that such argument could be made, closing FDs for children also 
affects FDs opened by C extensions, which are not subject to PEP 446. And this 
is important not only for security: for example, it's easy to create a deadlock 
if one process is blocked on a read() from a pipe, which it expects to be 
closed at a proper moment, but the pipe write end is leaked to some unrelated 
long-running process which keeps it alive indefinitely without being aware of 
it.

And again, even if subprocess didn't close FDs by default (or somehow closed 
only non-inherited FDs), how could this be used in a wider picture? Any 
third-party library (even written in Python) could still decide to close e.g. 
some range of descriptors, so one wouldn't be able to rely on FD inheritance in 
a general setting, just as one can't rely on inheritance of environment 
variables (works most of the time, but no promises). Traditional Unix things 
like inheritance across fork()/exec() and no O_CLOEXEC by default are 
convenient for quick hacks, but my impression is that such defaults are 
considered to be design bugs in the modern setting by many.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45620] A misleading url in 'Floating Point Arithmetic' page

2021-10-26 Thread Sonia


New submission from Sonia :

The url of [The Perils of Floating Point](http://www.lahey.com/float.htm) seems 
a bit weird in the page https://docs.python.org/3/tutorial/floatingpoint.html. 
It redirects me to a webpage that sells dugs. Not sure if the resource was 
meant to find this: 
http://www.stat.cmu.edu/~brian/711/week03/perils-of-floating-point.pdf

--
messages: 405070
nosy: hanhantw
priority: normal
severity: normal
status: open
title: A misleading url in 'Floating Point Arithmetic' page
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44828] tkinter.filedialog linked with Tk 8.6.11 crashes on macOS 12 Monterey, breaking IDLE saves

2021-10-26 Thread Ned Deily


Change by Ned Deily :


--
assignee: terry.reedy -> ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44828] tkinter.filedialog linked with Tk 8.6.11 crashes on macOS 12 Monterey, breaking IDLE saves

2021-10-26 Thread Ned Deily


Ned Deily  added the comment:

Marc, thanks for providing the patch for Tk. There are some issues with it, 
though, at least when used with IDLE. I built a Python 3.10.0+ universal2 
installer, like what we provide on python.org, with just the updated Tk and 
tested it on macOS 10.9, 10.13, 10.14, 10.15, 11 and 12.

First, and most important, there seems to be a typo in the fix that causes the 
dialog panel to break on macOS 10.14: 

-   if ([NSApp macOSVersion] > 101400) {
+   if ( osVersion >= 101400 && osVersion < 12) {

That ">=" should be just an ">" as before, I think. At least, making that 
change unbreaks 10.14.

Second, while the filedialog panel now works on macOS 12 (Monterey) with the 
patch, there are some side effects, at least when using CMD-S (Save) in a new 
IDLE edit window. After pressing CMD-S, some small object appears on the screen 
very briefly (too quickly for me to recognize what it is) and then the expected 
Save filedialog panel appears; however, unlike on all the other operating 
system levels tested, the keyboard focus is not on the filename text field in 
the panel. So when the user starts typing the file name, nothing happens until 
they do something, like clicking on the file name field, to manually move the 
keyboard focus to that field. I think most users would find that confusing. I 
don't know if there's any way to change that, either in Tk, tkinter, or IDLE. 
But it does seem to be a regression. The same binaries work fine on all of the 
other macOS versions I tested.

Any ideas?

(Although it's not an IDLE bug, I've added IDLE to the components list since it 
is impacted by this issue.)

--
assignee:  -> terry.reedy
components: +IDLE
nosy: +lukasz.langa, pablogsal, terry.reedy
priority: normal -> release blocker
title: Using tkinter.filedialog crashes on macOS Python 3.9.6 -> 
tkinter.filedialog linked with Tk 8.6.11 crashes on macOS 12 Monterey, breaking 
IDLE saves
versions: +Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Ned Deily


Change by Ned Deily :


--
nosy: +lukasz.langa, mdk, pablogsal
priority: normal -> release blocker
versions: +Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45619] Mentioning structural pattern matching in the list of binding

2021-10-26 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks!

--
nosy: +gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45617] sys.stdin does not iterate correctly on '\r' line separator

2021-10-26 Thread Eryk Sun


Eryk Sun  added the comment:

> '\r' is not handled, though it is documented that it 
> should be supported.

Where is it documented that sys.stdin uses universal newlines mode? The newline 
behavior isn't documented in the sys module [1], though it should be. It's hard 
coded in create_stdio() in Python/pylifecycle.c [2]. In Windows it uses 
universal-translated mode. On all other platforms, it uses "\n", which includes 
"\r\n" but not "\r".

---
[1] https://docs.python.org/3/library/sys.html#sys.stdin
[2] https://github.com/python/cpython/blob/v3.10.0/Python/pylifecycle.c#L2216

--
nosy: +eryksun

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45619] Mentioning structural pattern matching in the list of binding

2021-10-26 Thread Arthur Milchior


Change by Arthur Milchior :


--
keywords: +patch
pull_requests: +27495
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29232

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45619] Mentioning structural pattern matching in the list of binding

2021-10-26 Thread Arthur Milchior


New submission from Arthur Milchior :

https://docs.python.org/3/reference/executionmodel.html list all of the way a 
variable may be bound. However, it seems that it was not updated. Indeed, 
structural pattern matching in 3.10 also allows to bind a variable and is not 
mentionned.

As a related issue, the sentence is far too long and really would need to be 
broken down. At the very least, the special case "and targets that are 
identifiers if" is not clear, it is not indicated whether this case extends to 
the end of the sentence or is just local

--
assignee: docs@python
components: Documentation
messages: 405066
nosy: Arthur-Milchior, docs@python
priority: normal
severity: normal
status: open
title: Mentioning structural pattern matching in the list of binding
versions: Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45616] Python Launcher Matches 3.10 instead of 3.1

2021-10-26 Thread Yu Liu


Yu Liu  added the comment:

Had a quick look at the launcher file. Maybe something like this?

diff --git a/PC/launcher.c b/PC/launcher.c
index fbfb49a..a965a9d 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -542,7 +542,7 @@ find_python_by_version(wchar_t const * wanted_ver)
 }
 for (i = 0; i < num_installed_pythons; i++, ip++) {
 n = wcslen(ip->version);
-if (n > wlen)
+if (n != wlen)
 n = wlen;
 if ((wcsncmp(ip->version, wanted_ver, n) == 0) &&
 /* bits == 0 => don't care */

--
nosy: +yuliu2016

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45616] Python Launcher Matches 3.10 instead of 3.1

2021-10-26 Thread Yu Liu


Yu Liu  added the comment:

Had a quick look in the launcher file. Maybe something like this?

diff --git a/PC/launcher.c b/PC/launcher.c
index fbfb49a..a965a9d 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -542,7 +542,7 @@ find_python_by_version(wchar_t const * wanted_ver)
 }
 for (i = 0; i < num_installed_pythons; i++, ip++) {
 n = wcslen(ip->version);
-if (n > wlen)
+if (n != wlen)
 n = wlen;
 if ((wcsncmp(ip->version, wanted_ver, n) == 0) &&
 /* bits == 0 => don't care */

--
nosy: +yuliu2016

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42738] subprocess: don't close all file descriptors by default (close_fds=False)

2021-10-26 Thread Richard Xia


Richard Xia  added the comment:

I'd like to provide another, non-performance-related use case for changing the 
default value of Popen's close_fds parameters back to False.

In some scenarios, a (non-Python) parent process may want its descendant 
processes to inherit a particular file descriptor and for each descendant 
process to pass on that file descriptor its own children. In this scenario, a 
Python program may just be an intermediate script that calls out to multiple 
subprocesses, and closing the inheritable file descriptors by default would 
interfere with the parent process's ability to pass on that file descriptor to 
descendants.

As a concrete example, we have a (non-Python) build system and task runner that 
orchestrates many tasks to run in parallel. Some of those tasks end up invoking 
Python scripts that use subprocess.run() to run other programs. Our task runner 
intentionally passes an inheritable file descriptor that is unique to each task 
as a form of a keep-alive token; if the child processes continue to pass 
inheritable file descriptors to their children, then we can determine whether 
all of the processes spawned from a task have terminated by checking whither 
the last open handle to that file descriptor has been closed. This is 
particularly important when a processes exits before its children, sometimes 
uncleanly due to being force killed by the system or by a user.

In our use case, Python's default value of close_fds=True interferes with our 
tracking scheme, since it prevents Python's subprocesses from inheriting that 
file descriptor, even though that file descriptor has intentionally been made 
inheritable.

While we are able to work around the issue by explicitly setting 
close_fds=False in as much of our Python code as possible, it's difficult to 
enforce this globally since we have many small Python scripts. We also have no 
control over any third party libraries that may possibly call Popen.

Regarding security, PEP 446 already makes it so that any files opened from 
within a Python program are non-inheritable by default, which I agree is a good 
default. One can make the argument that it's not Python's job to enforce a 
security policy on file descriptors that a Python process has inherited from a 
parent process, since Python cannot distinguish from descriptors that were 
accidentally or intentionally inherited.

--
nosy: +richardxia

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45586] Use starred expressions in subscripts

2021-10-26 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Yes, I don't believe the PEP is suggesting any changes to list.__getitem__. If 
you want to suggest such enhancements, I would suggest first sending a message 
to the python-ideas mailing list or on discuss.python.org.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Maciej Olko


Change by Maciej Olko :


--
keywords: +patch
pull_requests: +27493
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29230

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Maciej Olko


Maciej Olko  added the comment:

The pin can be removed after bumping Sphinx to at least 3.5.4, which introduced 
upper limit for docutils version.

https://github.com/sphinx-doc/sphinx/commit/9263eea38379822e053c67ad1d17036d724c5e41

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Maciej Olko


Change by Maciej Olko :


--
versions: +Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Maciej Olko


Change by Maciej Olko :


--
versions:  -Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45618] Documentation builds fail with Sphinx 3.2.1

2021-10-26 Thread Maciej Olko

New submission from Maciej Olko :

Since the release of Docutils 0.18 today building Python documentation fails.

In CPython repository we have Sphinx pinned to 3.2.1, which has too loose 
requirement for Docutils version in install_requires – docutils>=0.12.

Example of failing build: 
https://github.com/python/python-docs-pl/runs/4009459257.

My suggestion is to pin down docutils in docs requirements.

--
assignee: docs@python
components: Documentation
messages: 405060
nosy: Maciej Olko, docs@python
priority: normal
severity: normal
status: open
title: Documentation builds fail with Sphinx 3.2.1
type: crash
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40915] multiple problems with mmap.resize() in Windows

2021-10-26 Thread Tim Golden


Change by Tim Golden :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40915] multiple problems with mmap.resize() in Windows

2021-10-26 Thread Tim Golden


Tim Golden  added the comment:


New changeset aea5ecc458084e01534ea6a11f4181f369869082 by Tim Golden in branch 
'main':
bpo-40915: Fix mmap resize bugs on Windows (GH-29213)
https://github.com/python/cpython/commit/aea5ecc458084e01534ea6a11f4181f369869082


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42260] [C API] Add _PyInterpreterState_SetConfig(): reconfigure an interpreter

2021-10-26 Thread Steve Dower


Change by Steve Dower :


--
pull_requests:  -27312

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44828] Using tkinter.filedialog crashes on macOS Python 3.9.6

2021-10-26 Thread lance robotson


lance robotson  added the comment:

This issue is happening for me in with my installation of python 3.10 running 
the release version of mac os monterey 12.0.1 running on an intel mac, I 
noticed this behavior trying to open or save files in IDLE.

--
nosy: +robotson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45617] sys.stdin does not iterate correctly on '\r' line separator

2021-10-26 Thread Kelly Brazil


Change by Kelly Brazil :


--
components: +Library (Lib)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45504] [argparse] Entering a partial config_parser flag works with subparsers

2021-10-26 Thread paul j3


Change by paul j3 :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45617] sys.stdin does not iterate correctly on '\r' line separator

2021-10-26 Thread Kelly Brazil


New submission from Kelly Brazil :

When iterating on sys.stdin lines, '\r\n' and '\n' are handled correctly, but 
'\r' is not handled, though it is documented that it should be supported.

Example code:
import sys

for line in sys.stdin:
print(repr(line))

Results in Python 3.8.9:
$ echo -e 'line1\nline2\nline3' | python3 linetest.py 
'line1\n'
'line2\n'
'line3\n'

$ echo -e 'line1\r\nline2\r\nline3' | python3 linetest.py 
'line1\r\n'
'line2\r\n'
'line3\n'

$ echo -e 'line1\rline2\rline3' | python3 linetest.py 
'line1\rline2\rline3\n'

--
messages: 405057
nosy: kbrazil
priority: normal
severity: normal
status: open
title: sys.stdin does not iterate correctly on '\r' line separator
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 26.10.2021 20:47, Marc-Andre Lemburg wrote:
>> Brett removed a lot of stuff in 01cf4fb9c1aa567484c2ffb1b11f9b3fe9949b05 to 
>> make the file more readable. I removed unnecessary -D, -I, and -L to make 
>> the file even more readable. You can pass custom flags to ./configure.
> 
> Could Brett or you please add those notes back ? There's no other place
> where such details are documented. We've lost important information and
> I would like to get this back into Setup and ideally add more
> information to make it easier for users or admins to customize
> their build.

I could also edit the file and add those back, after you're done
with the refactoring.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 26.10.2021 19:42, Christian Heimes wrote:
> 
> Brett removed a lot of stuff in 01cf4fb9c1aa567484c2ffb1b11f9b3fe9949b05 to 
> make the file more readable. I removed unnecessary -D, -I, and -L to make the 
> file even more readable. You can pass custom flags to ./configure.

Could Brett or you please add those notes back ? There's no other place
where such details are documented. We've lost important information and
I would like to get this back into Setup and ideally add more
information to make it easier for users or admins to customize
their build.

Regarding the -I and -L flags, my question was whether these are
now added elsewhere, since the code would not compile without
e.g. -I$(srcdir)/Include/internal.

I've gone through the Makefile and found that these are already
added via PY_CFLAGS_NODIST, so they are indeed not needed in Setup.
That's great :-)

Please be careful when moving e.g. -I or -L options which point to
non-Python directories. If such options get moved into e.g.
PY_CFLAGS_NODIST, there's no way to override them via options
given in Setup.

Having the -D defined in the relevant code is a lot better. Thanks
for that :-)

> Setup should not be edited by hand. Customizations go to Setup.local.

Editing Setup.local instead of Setup is not documented anywhere ?!
Both files are read, so I guess it's not all that relevant which
of the two are edited.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42367] Restore os.makedirs ability to apply mode to all directories created

2021-10-26 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
versions: +Python 3.11 -Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45616] Python Launcher Matches 3.10 instead of 3.1

2021-10-26 Thread Gabe R.


New submission from Gabe R.  :

I have both Python 3.1-64 and 3.10-64 installed on the same Windows machine. If 
I attempt to launch Python 3.1 using the command `py -3.1-64`, the launcher 
incorrectly starts Python 3.10.

--
components: Windows
messages: 405054
nosy: Marsfan, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Python Launcher Matches 3.10 instead of 3.1
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Christian Heimes


Christian Heimes  added the comment:

Brett removed a lot of stuff in 01cf4fb9c1aa567484c2ffb1b11f9b3fe9949b05 to 
make the file more readable. I removed unnecessary -D, -I, and -L to make the 
file even more readable. You can pass custom flags to ./configure.

Setup should not be edited by hand. Customizations go to Setup.local.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45545] chdir __exit__ is not safe

2021-10-26 Thread Jeremy


Jeremy  added the comment:

> How common do you expect such errors to be though?  Do you expect them to be 
> more or less common than with os.chdir()?  Do you expect the mitigations to 
> be any different than with a failing os.chdir()?

It has come up for me with some frequency. But I'm sure my use case is an 
outlier, stress testing filesystems and working on backup/restore. The thing 
about needing to access long paths is that you have to do it with these leaps 
of <= PATH_MAX until you get close enough to the end. Whether you use relative 
paths or open fds, you have to get there slowly and then walk back along the 
same path. This would be greatly simplified by contextlib.chdir if it isn't 
restricted to absolute paths; otherwise it will remain as much a manual effort 
as ever.

It also has to do with the scope of any try block. If we leave any exceptions 
to bubble up to the caller, then any code in the with block is also being 
guarded. Presumably the caller used chdir because they want to do more os 
operations in the with block, but they won't be able to sort out if the ENOENT 
or similar error was from the context manager or their own, perhaps more 
critical, os operations.


> If the context manager isn't going to address the long-path case reliably 
> using either a file-descriptor approach or repeated relative chdir() calls, 
> then I think failing early like this is the next best choice.

I thought about going down the fd road but as not every platform can chdir to a 
fd, the relative way back would have to be implemented anyways. It didn't seem 
worth it to have different platforms behave differently on exiting the context 
manager.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45591] PathFinder does not find namespace packages children

2021-10-26 Thread Filipe Laíns

Filipe Laíns  added the comment:

Thank you for clarifying, that does work. This is surprising behavior to me, do 
you recall what was the reasoning for this design? Or is there some discussion 
you can point me to? And sorry for bothering, I know I am asking too many 
questions, but I'd like to understand the importlib design 😅

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45615] Missing test for type of error when printing traceback for non-exception

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45591] PathFinder does not find namespace packages children

2021-10-26 Thread Brett Cannon


Brett Cannon  added the comment:

> I am curious, what is `fullname` supposed to mean then? "full" in what sense?

You can still specify the full name of the module you're trying to import, but 
you also need to pass in the location information for that module. So the code 
does `fullname.rpartition(".")[-1]` to get the name of the module that you're 
looking for. So `PathFinder.find_spec('namespace.a', 
path=spec.submodule_search_locations)` should also work.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Martin: It's true that exceptions raised in other methods called from __init__ 
would still have this issue, but I feel like ~90% of it would be solved by the 
proposed fix.

It does introduce an inconsistency but it does so because it reflects the 
inconsistency of `self` being NOT initialized in __init__ and `self` being 
initialized in all other methods used after __init__. It makes intuitive sense 
that you don't get a repr of an object before it exists in a full state.

The doc fix is useful in itself, but I'm not sure it's enough given the issue 
reported by Joe with new students getting this error. When they get this error, 
they will not understand why it happens, what's the connection between the 
error and the argument that needs to be provided to fix it, and whether it's 
the correct fix or not.

If they *do* understand it, fixing the __repr__ is probably the best solution, 
and then no fix on our side is required.

My concern with adding a safe repr argument is that code using that argument 
can be copy pasted unknowingly and then it's not explicit/obvious that it will 
silence the errors raised due to broken __repr__'s. (including __repr__'s that 
are broken even outside of __init__ method).

If such an parameter is added, it's much better to make it a new parameter, to 
avoid backwards incompatible change, which means it can be backported.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45235] argparse does not preserve namespace with subparser defaults

2021-10-26 Thread paul j3


Change by paul j3 :


--
stage: resolved -> test needed
status: closed -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42367] Restore os.makedirs ability to apply mode to all directories created

2021-10-26 Thread Kartik Subbarao


Change by Kartik Subbarao :


--
nosy: +kartiksubbarao

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45615] Missing test for type of error when printing traceback for non-exception

2021-10-26 Thread Irit Katriel


New submission from Irit Katriel :

In C code, there is a check in print_exception that the value passed in is of 
type exception, and it raises TypeError otherwise. This check is not covered by 
tests, and indeed it is hard to reach it with tests because the _testcapi 
module has this check as well, which blocks it before the interpreter's check 
is reached.


In traceback.py, there is no such check so this happens: 
>>> traceback.print_exception(12)
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/iritkatriel/src/cpython-654/Lib/traceback.py", line 121, in 
print_exception
value, tb = _parse_value_tb(exc, value, tb)
^^^
  File "/Users/iritkatriel/src/cpython-654/Lib/traceback.py", line 102, in 
_parse_value_tb
raise TypeError(f"Expected exception, got {exc}")
^
TypeError: Expected exception, got 12

--
components: Interpreter Core, Library (Lib)
messages: 405048
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: Missing test for type of error when printing traceback for non-exception
type: behavior
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 26.10.2021 16:17, Christian Heimes wrote:
> 
> Christian Heimes  added the comment:
> 
> Brett, we can use AM_CONDITIONAL() to conditionally enable/disable a feature 
> and AC_CONFIG_FILES() to create a Modules/Setup from a template:
> 
> Example:
> 
> The conditional
> 
> AM_CONDITIONAL([HAVE_SCPROXY], [test "$ac_sys_system" = "Darwin"])
> 
> sets HAVE_SCPROXY_FALSE and HAVE_NIS_SCPROXY based on the check.

I think it would be more helpful (and generate a lot fewer such
macros), if we'd just test for platforms and then use those in the
Setup.in template.

Some other things:

I saw that you stripped off lots of -I and -L options from the Setup
lines. Are those now unconditionally taken from somewhere else,
without possibility to override them ?

You also removed the structure of the listings, which makes things
like dependencies between e.g. _multibytecodec and the CJK codecs
unclear, the notes about audio, the comments on building the _md5
and sha* modules, etc.

Since Setup is a (potentially) hand edited file, it's good to leave
as much useful information in that file as possible, to not
accidentally create setups which don't work and to have references
which may help in finding the right compile options.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16235] Add python-config.sh for use during cross compilation.

2021-10-26 Thread Éric Araujo

Change by Éric Araujo :


--
Removed message: https://bugs.python.org/msg405026

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Christian Heimes


Christian Heimes  added the comment:

Typo, the last line should read "@HAVE_SCPROXY_FALSE@_scproxy"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Christian Heimes


Christian Heimes  added the comment:

Brett, we can use AM_CONDITIONAL() to conditionally enable/disable a feature 
and AC_CONFIG_FILES() to create a Modules/Setup from a template:

Example:

The conditional

AM_CONDITIONAL([HAVE_SCPROXY], [test "$ac_sys_system" = "Darwin"])

sets HAVE_SCPROXY_FALSE and HAVE_NIS_SCPROXY based on the check.

On macOS:

HAVE_SCPROXY_FALSE='#'
HAVE_SCPROXY_TRUE=''

On Linux:

HAVE_SCPROXY_FALSE=''
HAVE_SCPROXY_TRUE='#'

We can either do something like:

*shared*
@HAVE_SCPROXY_TRUE@_scproxy _scproxy.c -framework SystemConfiguration 
-framework CoreFoundation

or:

*disabled*
@HAVE_SCPROXY_FALSE*_scproxy

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45395] Frozen stdlib modules are discarded if custom frozen modules added.

2021-10-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

On 26.10.2021 16:02, Eric Snow wrote:
> 
> FYI, I figured out the problem on my end.  I wasn't using an installed 
> python.  Once I did it worked fine.

Oh, you mean you tried using it directly from the source tree ?
I don't think I ever tried that direct route.

When building PyRun, I first install to a temporary directory and
then use this to run the freeze.py tool, generate the frozen .c
files and run make to have the executable built.

I've pretty much finished the port to 3.10.

I'll try the main version in the next couple of days. There's currently
a lot of work going on for the makesetup / Setup files
(https://bugs.python.org/issue45548). I'm waiting for that to stabilize.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-10-26 Thread Petr Viktorin


Petr Viktorin  added the comment:

PEP 630 has motivations and technical notes. What needs to be documented better 
is how both applies to stdlib.
Specifically:
- list the behavior changes when static types are converted to heap types 
(mutability, pickleability, any more?), and document how to undo them when the 
new behavior is not better
- explain performance impacts, how to measure and analyze this
- what to watch out for and test

Whether that should be a new PEP or added to 630 doesn't matter much, IMO.

Then, any introduction of PEP 630 should be done deliberately, analyzing the 
pros and cons for each module separately. It should not be a mass change, and 
it should involve explaining the motivations & specific implications to module 
maintainers.

Since this is out of scope in this issue (and any other one on bpo, as far as I 
know), I invite discussion over at https://github.com/encukou/abi3/issues/21

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45395] Frozen stdlib modules are discarded if custom frozen modules added.

2021-10-26 Thread Eric Snow


Eric Snow  added the comment:

FYI, I figured out the problem on my end.  I wasn't using an installed python.  
Once I did it worked fine.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40512] [subinterpreters] Meta issue: per-interpreter GIL

2021-10-26 Thread Mark Shannon


Change by Mark Shannon :


--
nosy: +Mark.Shannon
nosy_count: 9.0 -> 10.0
pull_requests: +27492
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29228

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45614] traceback of exception with non-unicode __module__

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

BTW, I've verified that the overhead of adding this query is negligible.

$ python -m pyperf compare_to --min-speed 1 main.json patched.json 
Benchmark hidden because not significant (1): sqlite_synth

git switch -
Switched to branch 'main'
$ ./python.exe -m timeit "import sqlite3; sqlite3.threadsafety"
100 loops, best of 5: 225 nsec per loop
$ git switch -
Switched to branch 'sqlite-threadsafety'
$ ./python.exe -m timeit "import sqlite3; sqlite3.threadsafety"
100 loops, best of 5: 221 nsec per loop

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
keywords: +patch
pull_requests: +27491
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29227

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

FYI, it is also possible to change the threaded mode using sqlite3_config(), 
however that API is not exposed to the sqlite3 module, and there is no plans 
for doing so in the near future :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

+1 on setting the attributes dynamically. Other DB-API modules use a
similar approach.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45614] traceback of exception with non-unicode __module__

2021-10-26 Thread Irit Katriel


Irit Katriel  added the comment:

In C it is missing the '.' between  and the qualname. In python it 
raises an exception when trying to + the module field with a string.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

Currently, the sqlite3 DB-API 2.0 attribute 'threadsafety' is hard-coded to 1, 
meaning "threads may share the module, but not connections". This is not always 
true, since it depends on the default SQLite threaded mode, selected at 
compile-time with the SQLITE_THREADSAFE define.

SQLite's default compile-time threaded mode is SQLITE_THREADSAFE=1, also known 
as "serialized threaded mode", meaning SQLite can be safely used by multiple 
threads with no restriction. This mode equals DB-API 2.0 threadsafety level 3: 
threads may share the module, connections and cursors.

On macOS 11.6, the system supplied Python 3 and SQLite 3 uses 
SQLITE_THREADSAFE=2 (also known as "multi-thread mode"), meaning SQLite can be 
safely used by multiple threads provided that no single database connection is 
used simultaneously in two or more threads. This mode equals DB-API 2.0 
threadsafety level 1: threads may share the module, but not connections.

With SQLITE_THREADSAFE=0 (also known as "single-thread mode"), meaning all 
mutexes are disabled and SQLite is unsafe to use in more than a single thread 
at once. This mode equals DB-API 2.0 threadsafety level 0: threads may not 
share the module.


Suggesting to set the 'treadsafety' dynamically at sqlite3 module load time, 
either via Lib/sqlite3/dbapi2.py, or in C during module init (slightly faster).


See also:

- https://www.python.org/dev/peps/pep-0249/
- https://sqlite.org/threadsafe.html
- 
https://discuss.python.org/t/is-sqlite3-threadsafety-the-same-thing-as-sqlite3-threadsafe-from-the-c-library/11463/11

--
assignee: erlendaasland
components: Extension Modules
messages: 405035
nosy: erlendaasland, lemburg
priority: normal
severity: normal
status: open
title: [sqlite3] set threadsafety attribute based on default SQLite threaded 
mode
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +paul.moore

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45614] traceback of exception with non-unicode __module__

2021-10-26 Thread Irit Katriel


New submission from Irit Katriel :

This test currently fails for both C and python tracebacks:

def test_exception_modulename_not_unicode(self):
class X(Exception):
def __str__(self):
return "I am X"

X.__module__ = 42

err = self.get_report(X())
exp = f'.{X.__qualname__}: I am X'
self.assertEqual(exp, err)

--
components: Interpreter Core, Library (Lib)
messages: 405037
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: traceback of exception with non-unicode __module__
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2628] ftplib Persistent data connection

2021-10-26 Thread mike mcleod


mike mcleod  added the comment:

Hi Ethan,

Thanks, awaiting reply..

Regards,
Mike

On Tue, 26 Oct 2021 at 01:36, Ethan Furman  wrote:

>
> Ethan Furman  added the comment:
>
> We don't have a CLA from jbell.  I've sent an email asking him to do so...
> we'll see what happens.
>
> --
> nosy: +ethan.furman
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45613] [sqlite3] set threadsafety attribute based on default SQLite threaded mode

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37095] [Feature Request]: Add zstd support in tarfile

2021-10-26 Thread Chih-Hsuan Yen


Change by Chih-Hsuan Yen :


--
nosy:  -yan12125

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45438] inspect not capturing type annotations created by __class_getitem__

2021-10-26 Thread Martin Rueckl


Martin Rueckl  added the comment:

Just my two cents as a new contributor but long time user:

- isinstance(list[int], type) returning False seems incredibly un-intuitive to 
me. I always see generics (e.g. list without type parameter) as higher kinded 
types, where passing a type argument via [] turns the hkt into a concrete type.

- Backporting to 3.9 and 3.10 should be no issue

- I am not deep enough in pythons type system to judge whether my PR is 
consistent/good. I really just tried out what works and "feels consistent".

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45604] multiprocessing.log_to_stderr missing documentation for parameter

2021-10-26 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
nosy: +sobolevn
nosy_count: 2.0 -> 3.0
pull_requests: +27490
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29226

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Irit Katriel


Irit Katriel  added the comment:

Martin, how about something like:

"This is typically used for debugging, so it is important that the 
representation is information-rich and unambiguous. Furthermore, this function 
should not raise exceptions because that can make it inappropriate for use in 
some debugging contexts. "

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset b5ee79494b2e0d484b7cf59f6746010e22567702 by Christian Heimes in 
branch 'main':
bpo-45548: makesetup improvements (GH-29225)
https://github.com/python/cpython/commit/b5ee79494b2e0d484b7cf59f6746010e22567702


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10572] Move test sub-packages to Lib/test

2021-10-26 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

A side-effect of keeping tests inside the package, is that they appear in the 
package contents module docstring, which may be slightly confusing to new users.

>>> import sqlite3
>>> help(sqlite3)
Help on package sqlite3:

NAME
sqlite3

DESCRIPTION

[...]

PACKAGE CONTENTS
dbapi2
dump
test (package)



Regarding history: Serhiy already moved the sqlite3 test files (see commit 
3e19409d6443c66a6a7d62f58b2bb4e8330e56c4 of 2021-09-13). If one worries about 
needing to add the --follow switch to git log, or possibly backporting issues, 
that train already left the station:

$ git log --oneline Lib/sqlite3/test/test_dbapi.py | wc -l
   4
$ git log --follow --oneline Lib/sqlite3/test/test_dbapi.py | wc -l
  71


So, I'm +1 regarding moving the sqlite3 tests :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45548] Update Modules/Setup

2021-10-26 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +27489
pull_request: https://github.com/python/cpython/pull/29225

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45612] [doc] add sqlite3 module docstring

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
keywords: +patch
pull_requests: +27488
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29224

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45612] [doc] add sqlite3 module docstring

2021-10-26 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

Currently, the sqlite3 module docstring is the old pysqlite copyright comment 
in the start of Lib/sqlite3/__init__.py. This is not very helpful to the 
general user. Suggesting to add a more helpful docstring, a la the 're' or 
'array' modules (those two were randomly picked among stdlib modules with 
helpful docstrings).

--
assignee: docs@python
components: Documentation
messages: 405030
nosy: docs@python, erlendaasland
priority: normal
severity: normal
status: open
title: [doc] add sqlite3 module docstring
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45586] Use starred expressions in subscripts

2021-10-26 Thread Jacob Nilsson


Jacob Nilsson  added the comment:

Ok, I see.

>>> a[1, 2, *[3, 4]]
Would still faith with PEP 646 because lists don't accept tuples, right?
>>> a[(1, 2, *[3, 4])]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: list indices must be integers or slices, not tuple

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43656] TracebackException or StackSummary.extract with capture_locals=True fail to catch exceptions raised by repr() on value of frame local variable in FrameSummary.__init__.

2021-10-26 Thread Martin


Martin  added the comment:

Irit, I'm unsure about the wording. Something like ":meth:`__repr__` should 
always succeed, even if errors prevent a full description of the object."? "... 
even if the object is only partly initialized."?

Andrei, I think you can not simply omit the first argument. For virtually all 
methods, `self` is an important value for debugging. It could be omitted for 
__init__, but that would break consistency. Also, __init__ could call other 
methods that help initialize the object and therefore also deal with partly 
initialized objects.

I really think one important part of the solution to this problem is making 
people aware, that under some rare conditions, repr might receive a partly 
initialized object.

I'm also still convinced that the other part of the solution is a way to 
customize the behavior of StackSummary.extract and friends.
Context: I have written a tool (https://github.com/moi90/experitur) to run 
batches of (machine learning) experiments (so it is not interactive). In case 
of an error, the traceback is dumped into a file, together with the respective 
local variables (using 
`traceback.TracebackException.from_exception(...).format()`). I want this to 
succeed *in any case*, even if I was too ignorant to implement correct 
`__repr__`s in my experiment code (which is mostly on-time-use, so why should I 
care).

In the end, this whole problem only affects users of `capture_locals=True`, so 
we could just change the semantics of this parameter a bit:
False: do nothing, True: use repr (as before), : use this 
callable to convert the value to a string.
This way, we could avoid adding an additional parameter to many of the methods 
in traceback AND give users an easy way to customize exception formatting for 
easy debugging.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45611] pprint - low width overrides depth folding

2021-10-26 Thread Ian Currie


New submission from Ian Currie :

Reproducible example:

>>> from pprint import pprint
>>> data = [["aa"],[2],[3],[4],[5]]
>>> pprint(data)
[["aa"], [2], [3], [4], [5]]

>>> pprint(data, depth=1)
[[...], [...], [...], [...], [...]]

>>> pprint(data, depth=1, width=7)
[[...],
 [...],
 [...],
 [...],
 [...]]

>>> pprint(data, depth=1, width=6)
[['aa'],
 [2],
 [3],
 [4],
 [5]]

The depth "folds" everything deeper than 1 level. Then if you lower the width 
of the output enough, what was once on one line, will now be split by newlines.

The bug is, if you lower the width below seven characters. Which is the length 
of `[[...],`  It seems to override the `depth` parameter and print the 
everything with no folding. This is true of deeply nested structures too.

Expected behavior: for the folding `...` to remain.

Why put the width so low?

I came across this because of the behavior of `compact`:

By default, if a data structure can fit on one line, it will be displayed on 
one line. `compact` only affects sequences that are longer than the given width.

**There is no way to force compact as False for short items**, so as to make 
sure all items, even short ones, appear on their own line.

[1,2,3] - will always appear on its own line, there is no way to make it appear 
like:

[1,
 2,
 3]

The only way is by setting a very low width.

--
components: Library (Lib)
messages: 405027
nosy: iansedano
priority: normal
severity: normal
status: open
title: pprint - low width overrides depth folding
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37095] [Feature Request]: Add zstd support in tarfile

2021-10-26 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16235] Add python-config.sh for use during cross compilation.

2021-10-26 Thread surbhi nahta


surbhi nahta  added the comment:

Hi,

I am also having the same issue and found the best answer on the below site -

https://python-9.jimdosite.com/

--
nosy: +nahtasurbhi123

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com