[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread Kumar Aditya


Kumar Aditya  added the comment:

> Would it be possible to enhance deepfreeze be produce a list of all 
> (immortal) code objects?

It is tricky because the deepfreeze modules are generated by the bootstrap 
interpreter in Linux/MacOS and the downloaded python from nuget interpreter on 
Windows so when the bootstrap interpreter is built there will be no list of 
code objects to begin with so it won't work as intended.
But I have an idea : If we can #define Py_DEEPFROZEN_MODULES in the final 
interpreter but not in the bootstrap one, and then in pylifecycle.c an extern 
function can free up deep-frozen modules memory if Py_DEEPFROZEN_MODULES which 
will be defined in deepfreeze.c then it should work.

--

___
Python tracker 

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



[issue46482] `typing.Annotation.__new__` is not covered

2022-01-22 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue46482] `typing.Annotation.__new__` is not covered

2022-01-22 Thread Nikita Sobolev


New submission from Nikita Sobolev :

Right now no unit test covers this line: 
https://github.com/python/cpython/blob/51c3e28c8a163e58dc753765e3cc51d5a717e70d/Lib/typing.py#L1669-L1670

I will send a simple test for it.

--
components: Tests
messages: 411352
nosy: gvanrossum, kj, sobolevn
priority: normal
severity: normal
status: open
title: `typing.Annotation.__new__` is not covered
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



[issue44642] Union of a type and the typing module function

2022-01-22 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Looks like it was fixed indeed, `NewType` is now a class. And I cannot 
reproduce it even on `3.10`:

```
Python 3.10.0 (default, Nov  1 2021, 10:24:06) [Clang 11.0.0 
(clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing

>>> int | typing.cast
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'type' and 'function'

>>> int | typing.get_type_hints
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'type' and 'function'
```

--
resolution:  -> fixed
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



[issue45606] pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename

2022-01-22 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
title: pathlib.Path.glob() does not list dangling symlink when pattern is the 
exact filenane -> pathlib.Path.glob() does not list dangling symlink when 
pattern is the exact filename
versions: +Python 3.11 -Python 3.8

___
Python tracker 

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



[issue46481] Implement vectorcall protocol for weakref_call()

2022-01-22 Thread Dong-hee Na


Change by Dong-hee Na :


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

___
Python tracker 

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



[issue46481] Implement vectorcall protocol for weakref_call()

2022-01-22 Thread Dong-hee Na


New submission from Dong-hee Na :

Triggered by Victor's suggestion:

- Well-used.
- Easy to enhance performance.
- Performance enhancement is notable.
Mean +- std dev: [weakref_base] 49.3 ns +- 2.2 ns -> [weakref_vectorcall] 27.7 
ns +- 0.9 ns: 1.78x faster

--
assignee: corona10
components: Interpreter Core
files: bench_weakref.py
messages: 411350
nosy: corona10, vstinner
priority: normal
severity: normal
status: open
title: Implement vectorcall protocol for weakref_call()
type: performance
versions: Python 3.11
Added file: https://bugs.python.org/file50578/bench_weakref.py

___
Python tracker 

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



[issue46465] Regression caused by CALL_FUNCTION specialization for C function calls

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

It seems like the following target miss CHECK_EVAL_BREAKER():

TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_FAST) 
TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O)
TARGET(CALL_NO_KW_BUILTIN_FAST)
TARGET(CALL_NO_KW_BUILTIN_O)
TARGET(CALL_NO_KW_BUILTIN_CLASS_1)

CHECK_EVAL_BREAKER() matters for signals, but also multithreading (drop the 
GIL), asynchronous exception and pending calls.

--

___
Python tracker 

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



[issue46465] Regression caused by CALL_FUNCTION specialization for C function calls

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

The problem is that the optimization no longer checks for pending signals in 
TARGET(CALL_NO_KW_BUILTIN_FAST). The patch below fix my issue. I guess that 
other opcode needs an additional CHECK_EVAL_BREAKER().

diff --git a/Python/ceval.c b/Python/ceval.c
index 9aaddd99eda..7cc0f805366 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4822,6 +4822,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, 
InterpreterFrame *frame, int thr
 */
 goto error;
 }
+CHECK_EVAL_BREAKER();
 DISPATCH();
 }

--

___
Python tracker 

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



[issue46475] typing.Never and typing.assert_never

2022-01-22 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Based on feedback here and on typing-sig I'm now leaning towards adding 
typing.Never along with typing.assert_never. I'll submit a single patch for 
these as the documentation will be closely linked.

--
title: Document use of NoReturn as a bottom type -> typing.Never and 
typing.assert_never
type:  -> enhancement
versions:  -Python 3.10, Python 3.9

___
Python tracker 

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



[issue27219] turtle.fillcolor doesn't accept a tuple of floats

2022-01-22 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
assignee: Jelle Zijlstra -> 

___
Python tracker 

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



[issue31698] Add REQ_NAME to the node.h API

2022-01-22 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

The PR was closed for lack of interest.

--
resolution:  -> wont fix
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



[issue46480] Implement typing.assert_type

2022-01-22 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

Implement typing.assert_type as proposed in 
https://mail.python.org/archives/list/typing-...@python.org/thread/MITFQ6Z45RRMXY3HNM66IC3XXS3TA3JN/.
 This is a special primitive that asserts to the type checker what the type of 
an expression is.

Tentatively dropping assert_error() based on Eric's feedback.

--
assignee: Jelle Zijlstra
components: Library (Lib)
messages: 411345
nosy: AlexWaygood, Jelle Zijlstra, gvanrossum, kj, sobolevn
priority: normal
severity: normal
status: open
title: Implement typing.assert_type
type: enhancement
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



[issue46479] Implement typing.reveal_locals

2022-01-22 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

Implement typing.reveal_locals() as proposed in 
https://mail.python.org/archives/list/typing-...@python.org/thread/5MGN6HZWTJELNLIUOXTHLIXVLKZCEWY2/.
 This is a marker for type checkers that causes them to emit the types of all 
local variables.

--
assignee: Jelle Zijlstra
components: Library (Lib)
messages: 411344
nosy: AlexWaygood, Jelle Zijlstra, gvanrossum, kj, sobolevn
priority: normal
severity: normal
status: open
title: Implement typing.reveal_locals
type: enhancement
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



[issue37295] Possible optimizations for math.comb()

2022-01-22 Thread Tim Peters


Tim Peters  added the comment:

Ya, I don't expect anyone will check in a change without doing comparative 
timings in C first. Not worried about that.

I'd be happy to declare victory and move on at this point ;-) But that's me. 
Near the start of this, I noted that we just won't compete with GMP's vast 
array of tricks.

I noted that they use a special routine for division when it's known in advance 
that the remainder is 0 (as it is, e.g., in every division performed by "our" 
recursion (which GMP also uses, in some cases)).

But I didn't let on just how much that can buy them. Under 3.10.1 on my box, 
the final division alone in math.factorial(100) // 
math.factorial(50)**2 takes over 20 seconds. But a pure Python 
implementation of what I assume (don't know for sure) is the key idea(*) in 
their exact-division algorithm does the same thing in under 0.4 seconds. Huge 
difference - and while the pure Python version only ever wants the lower N bits 
of an NxN product, there's no real way to do that in pure Python except via 
throwing away the higher N bits of a double-width int product. In C, of course, 
the high half of the bits wouldn't be computed to begin with.

(*) Modular arithmetic again. Given n and d such that it's known n = q*d for 
some integer q, shift n and d right until d is odd. q is unaffected. A good 
upper bound on the bit length of q is then n.bit_length() - d.bit_length() + 1. 
Do the remaining work modulo 2 raised to that power. Call that base B.

We "merely" need to solve for q in the equation n = q*d (mod B). Because d is 
odd, I = pow(d, -1, B) exists. Just multiply both sides by I to get n * I = q 
(mod B).

No divisions of any kind are needed. More, there's also a very efficient, 
division-free algorithm for finding an inverse modulo a power of 2. To start 
with, every odd int is its own inverse mod 8, so we start with 3 good bits. A 
modular Newton-like iteration can double the number of correct bits on each 
iteration.

But I won't post code (unless someone asks) because I don't want to encourage 
anyone :-)

--

___
Python tracker 

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



[issue32007] deprecate the nis module

2022-01-22 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

PEP 549 lists nis among modules to be removed: 
https://www.python.org/dev/peps/pep-0594/#nis

For what it's worth, when I built 3.11 from source on Ubuntu 16.04 I managed to 
build the nis extension, without installing any special libraries first.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue46478] DirEntry.stat() of os.scandir() has no dir_fd parameter

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, I didn't test os.scandir() properly. If you pass a file descriptor to 
os.scandir(), it yields DirEntry entries with contains the directory FD. Ignore 
my request, Python works as expected :-D

--
resolution:  -> not a bug
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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue46474] Inefficient regular expression complexity in EntryPoint.pattern

2022-01-22 Thread Jason R. Coombs


Jason R. Coombs  added the comment:


New changeset 51c3e28c8a163e58dc753765e3cc51d5a717e70d by Jason R. Coombs in 
branch 'main':
bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 
4.10.1) (GH-30803)
https://github.com/python/cpython/commit/51c3e28c8a163e58dc753765e3cc51d5a717e70d


--

___
Python tracker 

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



[issue46240] Incorrect hint about forgetting a comma

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

Ah, thanks for the backport :-)

--
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



[issue46465] Regression caused by CALL_FUNCTION specialization for C function calls

2022-01-22 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue46478] DirEntry.stat() of os.scandir() has no dir_fd parameter

2022-01-22 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue46478] DirEntry.stat() of os.scandir() has no dir_fd parameter

2022-01-22 Thread STINNER Victor


New submission from STINNER Victor :

I read the Rust CVE-2022-21658 vulnerability of std::fs::remove_dir_all:
https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html

It's a race condition if an attacker replaces a directory with a symlink while 
Rust is removing the parent directory, Rust follows the symlink rather than 
just removing the symlink.

shutil._rmtree_safe_fd() uses os.scandir(). If 
entry.is_dir(follow_symlinks=False) is true, it calls 
entry.stat(follow_symlinks=False). It opens the directory as a file to remove 
the directory. It checks os.path.samestat(orig_st, os.fstat(dirfd)): if it's 
false, it raises an exception:

try:
# This can only happen if someone replaces
# a directory with a symlink after the call to
# os.scandir or stat.S_ISDIR above.
raise OSError("Cannot call rmtree on a symbolic "
  "link")
except OSError:
onerror(os.path.islink, fullname, sys.exc_info())

I understand that this check is in place to detect the Rust CVE-2022-21658 
vulnerability.

I noticed that the first entry.is_dir(follow_symlinks=False) call does a stat() 
syscall, but it doesn't pass the directory file descriptor. It would be even 
safer to pass it, just in case if the parent directory has been modified in the 
meanwhile as well.

--
components: Library (Lib)
messages: 411338
nosy: serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: DirEntry.stat() of os.scandir() has no dir_fd parameter
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



[issue46240] Incorrect hint about forgetting a comma

2022-01-22 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 633db1c4eb863a1340e45c353e36f2f8dcf5945c by Pablo Galindo Salgado 
in branch '3.10':
[3.10] bpo-46240: Correct the error for unclosed parentheses when the tokenizer 
is not finished (GH-30378). (GH-30819)
https://github.com/python/cpython/commit/633db1c4eb863a1340e45c353e36f2f8dcf5945c


--

___
Python tracker 

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



[issue45382] platform() is not able to detect windows 11

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b0898f4aa90d9397e23aef98a2d6b82445ee7455 by Victor Stinner in 
branch 'main':
bpo-45382: test.pythoninfo logs more Windows versions (GH-30817)
https://github.com/python/cpython/commit/b0898f4aa90d9397e23aef98a2d6b82445ee7455


--

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29006
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/30817

___
Python tracker 

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



[issue46474] Inefficient regular expression complexity in EntryPoint.pattern

2022-01-22 Thread Jason R. Coombs


Jason R. Coombs  added the comment:


New changeset 443dec6c9a104386ee90165d32fb28d0c5d29043 by Jason R. Coombs in 
branch 'main':
bpo-46474: Apply changes from importlib_metadata 4.10.0 (GH-30802)
https://github.com/python/cpython/commit/443dec6c9a104386ee90165d32fb28d0c5d29043


--

___
Python tracker 

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



[issue46425] Multiple test modules fail to run if invoked directly

2022-01-22 Thread Jason R. Coombs


Jason R. Coombs  added the comment:


New changeset d888ff5381594641126065e78dc9210dae4436a4 by Jason R. Coombs in 
branch 'main':
bpo-46425: Partially revert "bpo-46425: fix direct invocation of 
`test_importlib` (GH-30682)" (GH-30799)
https://github.com/python/cpython/commit/d888ff5381594641126065e78dc9210dae4436a4


--

___
Python tracker 

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



[issue46240] Incorrect hint about forgetting a comma

2022-01-22 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +29005
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/30819

___
Python tracker 

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



[issue46477] Enum: ensure bitwise operators on subclasses are correct

2022-01-22 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 353e3b2820bed38da16140276786eef9ba33d3bd by Ethan Furman in 
branch 'main':
bpo-46477: [Enum] ensure Flag subclasses have correct bitwise methods (GH-30816)
https://github.com/python/cpython/commit/353e3b2820bed38da16140276786eef9ba33d3bd


--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

> See also bpo-46476: Not all memory allocated by _Py_Quicken() is released at 
> Python exit.

If you apply my workaround for bpo-46476:
https://bugs.python.org/issue46476#msg411321

Python no longer leaks any memory block at exit for the simplest command!

$ ./python -I -X showrefcount -c pass
[-5 refs, 0 blocks]

Moreover, I modified deepfreeze to only freeze importlib._bootstrap and 
importlib._bootstrap_external. It confirms that bpo-46449 is causing the 
negative reference count, because with these additional local changes I get a 
positive _Py_RefTotal:

$ ./python -I -X showrefcount -c pass
[6 refs, 0 blocks]

--

___
Python tracker 

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



[issue45382] platform() is not able to detect windows 11

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote PR 30817 to log "ver" and "wmic os get Caption,Version /value" command 
output in test.pythoninfo. I would like to check if Windows Server 2022 is 
deployed on CI used by Python :-) I'm trying to understand why bpo-41682 
"[Windows] test_asyncio: Proactor 
test_sendfile_close_peer_in_the_middle_of_receiving failure" started to fail 
more often recently.

--

___
Python tracker 

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



[issue45382] platform() is not able to detect windows 11

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue46477] Enum: ensure bitwise operators on subclasses are correct

2022-01-22 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue44642] Union of a type and the typing module function

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

Do you recommend to just close this as "fixed"?

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 976dec9b3b35fddbaa893c99297e0c54731451b5 by Victor Stinner in 
branch 'main':
bpo-46417: _PyList_Fini() clears indexerr (GH-30815)
https://github.com/python/cpython/commit/976dec9b3b35fddbaa893c99297e0c54731451b5


--

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

> Would it be possible to enhance deepfreeze be produce a list of all 
> (immortal) code objects?

That should be simple. We could see if Kumar is interested.

--
nosy: +kumaraditya303

___
Python tracker 

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



[issue46449] Deep-freezed modules create inconsistency in sys.gettotalrefcount() (_Py_Reftotal)

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

> Is there a way to disable deepfreeze when building Python?

It looks like this isn't easy, sorry. :-( Adding Christian Heimes in case he 
has a suggestion.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

Maybe there should be a way to traverse all immortal code objects at Python 
exit and clear their PyCodeObject.co_quickened member (and maybe some other 
members).

Would it be possible to enhance deepfreeze be produce a list of all (immortal) 
code objects?

I did something similar for static types with _PyStaticType_Dealloc() in 
bpo-46417, but it's easy since the list of static type is known in advance and 
it's short (100 to 200 types).

--

I'm working on fixing the very old bug bpo-1635741: Python must release all 
memory that it called in Py_Finalize(). It matters when Python is embedded in 
an application. It makes sense to call Py_Initialize()/Py_Finalize() multiple 
times in such use case. Python should not leak any memory.

With my PR 30815 fix + my msg411321 workaround, "./python -I -X showrefcount -c 
pass" now says that Python leaks exactly *zero* memory block: so bpo-1635741 is 
basically fixed, for the simplest Python command ("pass"). Obviously, I expect 
that more work is needed for more complex workload, since there are other 
static types which are still not cleared at Python exit, and more C extension 
modules which are not ported to the multi-phase initialization API (PEP 489).

Valgrind is just one way to see the issue.

--

___
Python tracker 

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



[issue46240] Incorrect hint about forgetting a comma

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issue: the backport to 3.10 failed, PR 30390. Tests failed and 
there is now a merge conflict.

Either decide to not backport the fix, or please update the backport.

--
nosy: +vstinner
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue46266] Improve day constants (`MONDAY` ... `SUNDAY`) in `calendar.py`

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f66ef3eab62c6d262ddbc8ab16fb43c8921ad33a by Miss Islington (bot) 
in branch '3.10':
bpo-46266:  Add calendar day of week constants to __all__  (GH-30412) (GH-30424)
https://github.com/python/cpython/commit/f66ef3eab62c6d262ddbc8ab16fb43c8921ad33a


--
nosy: +vstinner

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

If any of the immortal, deep-frozen code objects is ever quickened, I suppose 
the quickening data is never freed. But when we finalize and reinitialize, the 
co_quickened flag should remain set, so this would be a one-time leak.

The question is whether the quickening cache points to any objects that *are* 
freed. If it does, that could be bad. If it doesn't, then all we lose is a 
fixed amount of memory (no further leaks if we finalize and initialize the 
runtime repeatedly).

However, if my theory holds, why would valgrind consider the memory leaked? 
(TBH I don't know what valgrind does, so maybe that's not the right question.)

--

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 486b4d3d8e1a5699a2854e310c58fe12b220b7a9 by Miss Islington (bot) 
in branch '3.10':
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801) 
(GH-30812)
https://github.com/python/cpython/commit/486b4d3d8e1a5699a2854e310c58fe12b220b7a9


--

___
Python tracker 

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



[issue45572] urllib.request:AttributeError: 'dict' object has no attribute 'get_all' in http_error_auth_reqed function

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29002
pull_request: https://github.com/python/cpython/pull/30815

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

Patch to disable _Py_Quicken(), to help me debugging other memory leaks at 
Python exit:

diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
index dfc75300315..f9cdefed2a2 100644
--- a/Include/internal/pycore_code.h
+++ b/Include/internal/pycore_code.h
@@ -146,12 +146,14 @@ int _Py_Quicken(PyCodeObject *code);
 static inline int
 _Py_IncrementCountAndMaybeQuicken(PyCodeObject *code)
 {
+#if 0
 if (code->co_warmup != 0) {
 code->co_warmup++;
 if (code->co_warmup == 0) {
 return _Py_Quicken(code) ? -1 : 1;
 }
 }
+#endif
 return 0;
 }

--

___
Python tracker 

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



[issue32007] deprecate the nis module

2022-01-22 Thread Irit Katriel


Change by Irit Katriel :


--
title: nis module fails to build against glibc-2.26 -> deprecate the nis module
type: compile error -> enhancement
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



[issue1471934] Python libcrypt build problem on Solaris 8, 9, 10 and OpenSolaris

2022-01-22 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> out of date
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



[issue1471934] Python libcrypt build problem on Solaris 8, 9, 10 and OpenSolaris

2022-01-22 Thread Irit Katriel


Irit Katriel  added the comment:

Python 2.4 and 2.5 are no longer maintained. Please create a new issue if you 
are seeing this problem on a current version (>= 3.9).

--
nosy: +iritkatriel

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
stage: patch review -> needs patch

___
Python tracker 

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



[issue46477] Enum: ensure bitwise operators on subclasses are correct

2022-01-22 Thread Ethan Furman


New submission from Ethan Furman :

Creating one's own int Flag type doesn't work properly with regards to the 
bitwise operators:

class MyIntFlag(int, Flag):
ONE = 1
TWO = 2
FOUR = 4

MyIntFlag.ONE | MyIntFlag.TWO
# 

MyIntFlag.ONE | 2
# 3

--
assignee: ethan.furman
messages: 411319
nosy: ethan.furman
priority: normal
severity: normal
status: open
title: Enum: ensure bitwise operators on subclasses are correct
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



[issue45572] urllib.request:AttributeError: 'dict' object has no attribute 'get_all' in http_error_auth_reqed function

2022-01-22 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I was wrong that the method is undocumented, it is documented but it doesn't 
explain the type of *headers* param.

The headers can also be more easily created using `email.message.Message()`.

I've added the PR documenting this param.

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-46476: Not all memory allocated by _Py_Quicken() is released at 
Python exit.

--

___
Python tracker 

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



[issue46449] Deep-freezed modules create inconsistency in sys.gettotalrefcount() (_Py_Reftotal)

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-46476: "Not all memory allocated by _Py_Quicken() is released at 
Python exit".

--

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is released at Python exit

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
title: Not all memory allocated by _Py_Quicken() is not released at Python exit 
-> Not all memory allocated by _Py_Quicken() is released at Python exit

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is not released at Python exit

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +Mark.Shannon, eric.snow, gvanrossum

___
Python tracker 

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



[issue46476] Not all memory allocated by _Py_Quicken() is not released at Python exit

2022-01-22 Thread STINNER Victor


New submission from STINNER Victor :

Python leaks around 66 memory blocks at exit. Most of them are allocated by 
_Py_Quicken() of Python/specialize.c.

int
_Py_Quicken(PyCodeObject *code) {
...
SpecializedCacheOrInstruction *quickened = allocate(entry_count, 
instr_count);
...
code->co_quickened = quickened;
...
return 0;
}

The memory is stored in PyCodeObject.co_quickened member. This member *is* 
cleared by the code object deallocator function, code_dealloc():

static void
code_dealloc(PyCodeObject *co)
{
...
if (co->co_quickened) {
PyMem_Free(co->co_quickened);
_Py_QuickenedCount--;
}
...
}

I read recently that deepfreeze creates "immortal" code objects (refcount of 
9). I guess that it's related.


I used Valgrind to look for memory leaked by Python at exit:

$ PYTHONMALLOC=malloc valgrind --show-leak-kinds=all --leak-check=full 
--log-file=valgrind.log --num-callers=50 ./python -c pass

Extract of valgrind.log:

==1266888== 5,528 bytes in 13 blocks are still reachable in loss record 33 of 33
==1266888==at 0x484186F: malloc (vg_replace_malloc.c:381)
==1266888==by 0x544DBC: _PyMem_RawMalloc (obmalloc.c:100)
==1266888==by 0x545B13: PyMem_Malloc (obmalloc.c:618)
==1266888==by 0x6AAE6F: allocate (specialize.c:231)
==1266888==by 0x6AB3F0: _Py_Quicken (specialize.c:420)
==1266888==by 0x622CE7: _Py_IncrementCountAndMaybeQuicken 
(pycore_code.h:152)
==1266888==by 0x626315: _PyEval_EvalFrameDefault (ceval.c:1792)
==1266888==by 0x622B13: _PyEval_EvalFrame (pycore_ceval.h:53)
==1266888==...
==1266888== 
==1266888== LEAK SUMMARY:
==1266888==definitely lost: 0 bytes in 0 blocks
==1266888==indirectly lost: 0 bytes in 0 blocks
==1266888==  possibly lost: 0 bytes in 0 blocks
==1266888==still reachable: 24,240 bytes in 66 blocks
==1266888== suppressed: 0 bytes in 0 blocks


See also bpo-46449: "Deep-freezed modules create inconsistency in 
sys.gettotalrefcount() (_Py_Reftotal)".

--
components: Interpreter Core
messages: 411315
nosy: vstinner
priority: normal
severity: normal
status: open
title: Not all memory allocated by _Py_Quicken() is not released at Python exit
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



[issue40066] Enum: modify __repr__, __str__; update docs

2022-01-22 Thread Ethan Furman


Change by Ethan Furman :


--
status: open -> closed

___
Python tracker 

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



[issue45572] urllib.request:AttributeError: 'dict' object has no attribute 'get_all' in http_error_auth_reqed function

2022-01-22 Thread Andrei Kulakov


Change by Andrei Kulakov :


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

___
Python tracker 

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



[issue36257] configure with --with-icc --with-cxx-main=icpc

2022-01-22 Thread Irit Katriel


Irit Katriel  added the comment:

3.7 is no longer maintained. Please create a new issue if you are having this 
problem with a current version (>= 3.9).

--
nosy: +iritkatriel
resolution:  -> out of date
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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread miss-islington


miss-islington  added the comment:


New changeset ba932d90244252f6d4073263f25989507a183f79 by Miss Islington (bot) 
in branch '3.9':
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801)
https://github.com/python/cpython/commit/ba932d90244252f6d4073263f25989507a183f79


--

___
Python tracker 

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



[issue33936] OPENSSL_VERSION_1_1 never defined in _hashopenssl.c

2022-01-22 Thread Irit Katriel


Irit Katriel  added the comment:

Christian is this fixed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

My work on bpo-46417 reduces the number of leak references from around 10k to 
... minus 4 references :-) Clearing static types and a few "static" objects 
helped a lot!

> New changeset a1444f43584af0f7a0af72aa06ba0a86ae5a87a2 by Victor Stinner in 
> branch 'main':
> bpo-46417: Fix _PyStaticType_Dealloc() (GH-30810)
> https://github.com/python/cpython/commit/a1444f43584af0f7a0af72aa06ba0a86ae5a87a2

At commit a1444f43584af0f7a0af72aa06ba0a86ae5a87a2, I get:

$ ./python -I -X showrefcount -c pass
[-4 refs, 61 blocks]

I have to investigate why it's negative. It may be caused by bpo-46449 issue.

See also: https://bugs.python.org/issue46417#msg411307

--

___
Python tracker 

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



[issue46285] protocol_version in http.server.test can be ignored

2022-01-22 Thread Éric Araujo

Change by Éric Araujo :


--
nosy: +maggyero, matrixise

___
Python tracker 

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



[issue46285] protocol_version in http.server.test can be ignored

2022-01-22 Thread Éric Araujo

Éric Araujo  added the comment:

I think we have a valid bug, and you correctly attributed it to the use of 
partial!

(No worry about your English — thank you for reporting the problem here!)


To answer your questions:

1) partial:

Imagine we have a function with many parameters:

  def frob(source, target, backup=False): ...

and we want to call it many times without passing backup=True every time; we 
can make a lambda:

  frob_backup = lambda source, target: frob(source, target, backup=True)
  # later in the file
  frob_backup(src1, tgt1)
  frob_backup(src2, tgt2)

or a partial:

  frob_backup = partial(frob, backup=True)
  # then
  frob_backup(src3, tgt3)

As you can see, they both work in the same way.  They are equivalent ways of 
making a shortcut to call a function with some parameters pre-defined.  When 
called, the lambda will call the frob function and return its return value.  
When called, the partial object will call the frob function and return its 
return value.


2) closures:

Closures are variables that are resolved in the parent scope (namespace) of the 
normal scope.
A function (including a function created by a lambda) can have closures.

  def make_callback(backup_default):  
  callback = lambda source, target: frob(source, target, backup_default)
  return callback

Here when callback is called, the backup_default variable is not found in the 
local variables of the callback function, but in the scope of make_callback.  
It will be true or false depending on how make_callback was called.


3) http.server.test

There aren’t any closures in http.server.test; the issue is that HandlerClass 
(defined in the `if name is main` block and passed to `test`) is a proper 
handler class in one case, or a partial object!  So inside test, setting 
attributes on the passed handler class will do nothing if that class is 
actually a partial instance.  When it is called, it will return an instance of 
SimpleHttpRequestHandler, which won’t see the protocol attribute that we wanted.


Conclusion:
- maybe we should pass all parameters to test instead of smuggling through 
params
- setting class attributes seems fishy to me
- cgi handler and regular handler should have the same features (see #46436)

--
nosy: +Jelle Zijlstra
resolution: not a bug -> 
stage: resolved -> needs patch
status: closed -> open
title: http/server.py wont respect its protocol_version -> protocol_version in 
http.server.test can be ignored
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue46475] Document use of NoReturn as a bottom type

2022-01-22 Thread Alex Waygood


Alex Waygood  added the comment:

I also agree that documenting this is a great idea. It's already been adopted 
by large swathes of the typing community for use in this context. The value of 
having NoReturn act as a "bottom type" is evident. Time to make it official, in 
my opinion.

--

___
Python tracker 

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



[issue46449] Deep-freezed modules create inconsistency in sys.gettotalrefcount() (_Py_Reftotal)

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

Is there a way to disable deepfreeze when building Python?

It makes the Python build way slower. For example, a full build (after "make 
clean") of Python 3.10 takes 14.9 seconds on my laptop, whereas Python 3.11 
takes 24.6 seconds (1.6x slower). It makes my workflow (trial-and-error based 
;-)) less efficient.

Moreover, I would like to disable it to investigate why _Py_RefTotal is now 
negative at Python exit:
https://bugs.python.org/issue46417#msg411307

Note: I pushed many changes in bpo-46417 to clear static types and a few 
"static" objects at Python exit (in Py_Finalize()).

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

> New changeset a1444f43584af0f7a0af72aa06ba0a86ae5a87a2 by Victor Stinner in 
> branch 'main':
> bpo-46417: Fix _PyStaticType_Dealloc() (GH-30810)
> https://github.com/python/cpython/commit/a1444f43584af0f7a0af72aa06ba0a86ae5a87a2

At this commit, Py_Finalize() no longer leaks references. It exceeded my 
expectations, it even makes _Py_RefTotal negative :-D

$ ./python -I -X showrefcount -c pass
[-4 refs, 61 blocks]

I'm not sure why it's negative, but bpo-46449 should be investigate first.

--

___
Python tracker 

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



[issue46436] Pass the -d/--directory command-line option to http.server.CGIHTTPRequestHandler

2022-01-22 Thread Éric Araujo

Éric Araujo  added the comment:

The use of partial may cause bugs!

Here is reported that the `protocol` parameter (of the `test` function) is 
ignored because it’s set on the partial object instead of the handler class: 
https://bugs.python.org/issue46285

--
nosy: +eric.araujo

___
Python tracker 

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



[issue46421] unittest ValueError when invoking as module

2022-01-22 Thread Bader Zaidan


Change by Bader Zaidan :


--
versions: +Python 3.7, Python 3.8

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

cannot_deallocate2.patch: updated patch to debug which types are not cleared at 
exit.

--
Added file: https://bugs.python.org/file50577/cannot_deallocate2.patch

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:

The _PyStaticType_Dealloc() function cannot call PyObject_ClearWeakRefs() if 
the refcount is not zero. I am not sure if it's a real issue or not. Maybe the 
weakref list must be cleared (release memory), but callbacks must not be called?

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a1444f43584af0f7a0af72aa06ba0a86ae5a87a2 by Victor Stinner in 
branch 'main':
bpo-46417: Fix _PyStaticType_Dealloc() (GH-30810)
https://github.com/python/cpython/commit/a1444f43584af0f7a0af72aa06ba0a86ae5a87a2


--

___
Python tracker 

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



[issue45995] string formatting: normalize negative zero

2022-01-22 Thread John Belmonte


John Belmonte  added the comment:

Thank you Mark and Eric.

> I'll note that the paper is proposing a 'z' modifier to the sign, so I guess 
> for us that would translate to: [sign[optional-z]] instead of just sign.  I'd 
> have to noodle through the differences between that the proposed [sign][~].

The C++ paper proposes [sign][z] (i.e. you can have the `z` alone without an 
explicit +/-), and this is what I implemented in the Python PR.  My original 
proposal with tilde was discarded.

> My only reservation is Mark's comment:  """For Decimal, we'd need to "own" 
> the string formatting, taking that responsibility away from mpdecimal, but 
> there are already other reasons to do that."""

In the PR I was able to avoid taking that on by preprocessing the format string 
before handing it to mpdecimal.  The code was already doing such things to 
handle the NULL fill character.

--

___
Python tracker 

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



[issue46475] Document use of NoReturn as a bottom type

2022-01-22 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

I agree.

Plus, I cannot refrain from saying that it is generally quite hard to teach 
what "NoReturn" is.

I start by explaining what bottom type and `void` is and then just say that in 
Python it is called `NoReturn`. I remember that there was a discussion about 
`Never` alias for it.

Jelle, will you please push it? :)

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 12f4ac3bc848244242d6b8a7ee158b985fd64744 by Victor Stinner in 
branch 'main':
bpo-46417: Clear symtable identifiers at exit (GH-30809)
https://github.com/python/cpython/commit/12f4ac3bc848244242d6b8a7ee158b985fd64744


--

___
Python tracker 

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



[issue46465] Regression caused by CALL_FUNCTION specialization for C function calls

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
title: test_unittest: TestBreakSignalDefault.testInstallHandler() fails if run 
after TestBreak -> Regression caused by CALL_FUNCTION specialization for C 
function calls

___
Python tracker 

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



[issue46454] '0 -> /dev/null' is lost

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29000
pull_request: https://github.com/python/cpython/pull/30812

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 11.0 -> 12.0
pull_requests: +28999
pull_request: https://github.com/python/cpython/pull/30811

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1ded8ed8e817b8f9dae1a0ef92d97983afbc844e by Nikita Sobolev in 
branch 'main':
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801)
https://github.com/python/cpython/commit/1ded8ed8e817b8f9dae1a0ef92d97983afbc844e


--
nosy: +vstinner

___
Python tracker 

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



[issue44642] Union of a type and the typing module function

2022-01-22 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

It does not happen anymore on `main` (3.11):

```
Python 3.11.0a4+ (heads/main-dirty:ef3ef6fa43, Jan 20 2022, 20:48:25) [Clang 
11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing

>>> int | typing.cast
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'type' and 'function'

>>> int | typing.get_type_hints
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'type' and 'function' 
```

--
nosy: +sobolevn

___
Python tracker 

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



[issue46475] Document use of NoReturn as a bottom type

2022-01-22 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
components: +Library (Lib)
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



[issue46475] Document use of NoReturn as a bottom type

2022-01-22 Thread Jelle Zijlstra


New submission from Jelle Zijlstra :

At the moment, https://docs.python.org/3.10/library/typing.html#typing.NoReturn 
simply says:

Special type indicating that a function never returns.

In practice, type checkers accept NoReturn as a bottom type in other positions 
too. We should document this behavior.

--
assignee: Jelle Zijlstra
messages: 411297
nosy: AlexWaygood, Jelle Zijlstra, gvanrossum, kj, sobolevn
priority: normal
severity: normal
status: open
title: Document use of NoReturn as a bottom type

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28998
pull_request: https://github.com/python/cpython/pull/30810

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28997
pull_request: https://github.com/python/cpython/pull/30809

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 9c8e490b8f9e40a6fe9815be58bacaecab5369ee by Victor Stinner in 
branch 'main':
bpo-46417: Clear _io module static objects at exit (GH-30807)
https://github.com/python/cpython/commit/9c8e490b8f9e40a6fe9815be58bacaecab5369ee


--

___
Python tracker 

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



[issue45995] string formatting: normalize negative zero

2022-01-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

Wow, thanks, Mark!

I'm generally in favor. The selling points to me are that it needs to happen 
post-rounding, and the C++ discussion. It would be better if this were already 
accepted in C++. I'll note that the paper is proposing a 'z' modifier to the 
sign, so I guess for us that would translate to: [sign[optional-z]] instead of 
just sign. I'd have to noodle through the differences between that the proposed 
[sign][~]. I guess this would all be worked out in a PEP.

My only reservation is Mark's comment:  """For Decimal, we'd need to "own" the 
string formatting, taking that responsibility away from mpdecimal, but there 
are already other reasons to do that."""

If Mark is okay with that (right back at you, Mark!), then I think a PEP is the 
next step. It doesn't need to be huge, sort of like PEP 378.

--

___
Python tracker 

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



[issue46375] io.BytesIO does not have peek()

2022-01-22 Thread Marcel Martin

Marcel Martin  added the comment:

I opened a PR, but I now wonder whether the missing peek() is by design.

First, I noticed that instead of using BytesIO directly, I can wrap the 
instance in an io.BufferedReader, which does have peek(). (It’s just a bit 
inconvenient.)

The second thing is that BytesIO is currently documented to inherit from 
BufferedIOBase, but if peek() is implemented, one could argue that BytesIO now 
should inherit from BufferedReader because it then has all the methods. And 
that seems to great a change from my perspective.

I’ll defer to someone more knowledgeable and do not mind at all if this issue 
is closed without action.

--

___
Python tracker 

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



[issue46375] io.BytesIO does not have peek()

2022-01-22 Thread Marcel Martin


Change by Marcel Martin :


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

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

Previously, this failure was more sporadic; now it happens almost every single 
run on the Azure CI. Has there been updates on the Azure CI lately?

--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28995
pull_request: https://github.com/python/cpython/pull/30807

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1626bf4ac7aef1244e6f886e63a31f7ed65fbd10 by Victor Stinner in 
branch 'main':
bpo-46417: Clear Unicode static types at exit (GH-30806)
https://github.com/python/cpython/commit/1626bf4ac7aef1244e6f886e63a31f7ed65fbd10


--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28994
pull_request: https://github.com/python/cpython/pull/30806

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 621a45ccacd121f9ae4d8a539f040410c74b253b by Victor Stinner in 
branch 'main':
bpo-46417: Py_Finalize() clears static exceptioins (GH-30805)
https://github.com/python/cpython/commit/621a45ccacd121f9ae4d8a539f040410c74b253b


--

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28993
pull_request: https://github.com/python/cpython/pull/30805

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-22 Thread Oleg Iarygin


Change by Oleg Iarygin :


--
nosy: +arhadthedev

___
Python tracker 

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



[issue46417] Clear static types in Py_Finalize() for embedded Python

2022-01-22 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f1bcdeaca6e912a2bec1fbcff76cc49e7f761d38 by Victor Stinner in 
branch 'main':
bpo-46417: Factorize _PyExc_InitTypes() code (GH-30804)
https://github.com/python/cpython/commit/f1bcdeaca6e912a2bec1fbcff76cc49e7f761d38


--

___
Python tracker 

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



[issue46431] Trouble subclassing ExceptionGroup

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

Is this a matter of adding some documentation showing how it should be done? 
Even if we don't want to encourage such subclassing, we do have APIs to support 
it, and I think we ought to show how to do it, given that you have to 
coordinate a bunch of things.

How feasible is it to improve the error? (If that error is what you always get 
when __init__ and __new__ don't agree, maybe that could be a separate, more 
general issue?)

--

___
Python tracker 

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



[issue46465] test_unittest: TestBreakSignalDefault.testInstallHandler() fails if run after TestBreak

2022-01-22 Thread Guido van Rossum


Guido van Rossum  added the comment:

@kj, are you looking into this?

--

___
Python tracker 

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



  1   2   >