[issue46426] Improve tests for the dir_fd argument

2022-01-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 54610bb448a9cf5be77d53b66169fca4c11be6cb by Serhiy Storchaka in 
branch 'main':
bpo-46426: Improve tests for the dir_fd argument (GH-30668)
https://github.com/python/cpython/commit/54610bb448a9cf5be77d53b66169fca4c11be6cb


--

___
Python tracker 

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



[issue46426] Improve tests for the dir_fd argument

2022-01-20 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +28926
pull_request: https://github.com/python/cpython/pull/30739

___
Python tracker 

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



[issue30512] CAN Socket support for NetBSD

2022-01-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.11 -Python 3.7

___
Python tracker 

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



[issue30512] CAN Socket support for NetBSD

2022-01-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 40fcd16889028bd3cd2289e0f8a2af43f17a5824 by Thomas Klausner in 
branch 'main':
bpo-30512: Add CAN Socket support for NetBSD (GH-30066)
https://github.com/python/cpython/commit/40fcd16889028bd3cd2289e0f8a2af43f17a5824


--

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2022-01-20 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 9.0 -> 10.0
pull_requests: +28924
pull_request: https://github.com/python/cpython/pull/30737

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2022-01-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28925
pull_request: https://github.com/python/cpython/pull/30738

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2022-01-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset cfadcc31ea84617b1c73022ce54d4ae831333e8d by andrei kulakov in 
branch 'main':
bpo-21987: Fix TarFile.getmember getting a dir with a trailing slash (GH-30283)
https://github.com/python/cpython/commit/cfadcc31ea84617b1c73022ce54d4ae831333e8d


--

___
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-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 22f73bd9f1fc573d5c998f345b66c29f7ca6614d by Nikita Sobolev in 
branch 'main':
bpo-46425: Fix direct invocation of `test_contextlib` (GH-30681)
https://github.com/python/cpython/commit/22f73bd9f1fc573d5c998f345b66c29f7ca6614d


--

___
Python tracker 

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



[issue19479] textwrap.dedent doesn't work properly with strings containing CRLF

2022-01-20 Thread Georg Brandl


Change by Georg Brandl :


--
nosy:  -georg.brandl

___
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-20 Thread Géry

Change by Géry :


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



[issue46448] TypedDict inspect.signature error

2022-01-20 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread Tim Peters


Tim Peters  added the comment:

>> the meanings of "predecessor" and "successor" are
>> universally agreed upon

> I disagree.

I can post literally hundreds of citations that all agree: in u -> v, u is a 
direct predecessor of v, and v is a direct successor of u.

Here's one:

http://pages.cs.wisc.edu/~vernon/cs367/notes/13.GRAPH.html

Here's another from a Python context:

https://networkx.org/documentation/stable/reference/classes/generated/networkx.DiGraph.predecessors.html

"""
A predecessor of n is a node m such that there exists a directed edge from m to 
n.
"""

On & on & on. Hence my "universal".

Can you link to any that disagree?

As to the meaning of "point to", in "u -> v" it's obvious that the arrow points 
_from_ u _to_ v. I very strongly doubt you can find a credible source disputing 
that either.

--

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

> It's not obvious if the "predecessor" should be the start or the end point of 
> the edge

https://en.wikipedia.org/wiki/Directed_graph#Basic_terminology :
"""If a path leads from x to y, then y is said to be a successor of x and 
reachable from x, and x is said to be a predecessor of y."""

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> you're not actually confused.

I was when I first read it!


> the meanings of "predecessor" and "successor" are universally agreed upon

I disagree. The universally agreed upon terms are "directed edge u -> v". It's 
not obvious if the "predecessor" should be the start or the end point of the 
edge, and this is why the docs explicitly state the edge direction:

> If the optional graph argument is provided it must be a dictionary 
> representing a directed acyclic graph where the keys are nodes and the values 
> are iterables of all [...] the nodes that have edges that point to the value 
> in the key.

--

___
Python tracker 

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



[issue46451] Possibly bad interaction with tracing and cython?

2022-01-20 Thread Sebastian Berg


Sebastian Berg  added the comment:

Ahh, a further data-point.  The name from the module scope that is overwritten 
IS a parameter name used in the function locals.  Strangly, if I modify the 
tracing to print more:

stop = 0
def trace(frame, event, arg):
global stop
if stop > 10:
return None

if np.core.numeric.dtype is not np.dtype:
#print("Something happened here, `np.core.numeric.dtype IS np.dtype`")
print(np.core.numeric.dtype)
print(frame, event, arg)
stop += 1
else:
print(frame, event, arg)

return trace

Then what I get is:

None
 call None
None
 line None
None
 line None
None
 line None
None
 line None
bool


So, upon entering the function, the value is (already) cleared/set to None 
(which is correct of course for `dtype=None`) and then while the function runs 
storing into the function locals _mutates_ the module global?

For the fact that it keeps changing during the function run, points very 
strongly at CPython?

--

___
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-20 Thread Guido van Rossum


Guido van Rossum  added the comment:

Hm, the deep-frozen objects are statically initialized with a very large 
refcount that isn't accounted for (they are intended to be immortal). It seems 
that Py_Finalize() somehow decrefs those objects. I guess this means we need 
some kind of flag indicating certain objects are immortal (Eric has proposed 
several schemes), then we could just mark these objects as immortal.

This reminds me, since https://github.com/python/cpython/pull/30715 (which I 
merged yesterday) the deep-frozen objects also reference the small ints 
directly, as well as the singleton for b"". Is this even safe across 
Py_Finalize()/Py_Initialize()? If not, we'll need to roll that back as well.

--

___
Python tracker 

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



[issue46451] Possibly bad interaction with tracing and cython?

2022-01-20 Thread Sebastian Berg


New submission from Sebastian Berg :

Starting here, but there could be Cython interaction or something else in 
theory.  But, when running the following:

* Python 3.10.1 (not 3.9.9, debug version or not)
* Setting a tracing function  (not setting a trace-function will fix the issue)
* Running Cython (maybe also C code) calling back into Python (the best I can 
tell)

It can happen that module globals in the called funtions scope seem to be 
modified.  Oddly enough to a value used in the locals of that function?!

The pandas issue:

https://github.com/pandas-dev/pandas/issues/41935

has a reproducer (sorry that it takes NumPy and pandas for now).  I will paste 
it at the end here also.

I can find that the value is modified by the time the `trace` function is 
called.  No other "trace" triggers are processed before in this example (Cython 
calls other functions in NumPy, but all of those are C implemented, so I guess 
that is why).
The function in question (unlike all?) should further be called with 
`__Pyx_PyFunction_FastCall`, so that is probably an important data point: 
Fastcall protocol seems involved.

(Reproducible using NumPy 1.21.5 and Pandas 1.3.5, but except maybe pandas due 
to the Cython version, I don't expect version dependency.)

The output of the script is very brief:

Something happened here, `np.core.numeric.dtype IS np.dtype`
 call None


The full reproducer script is:


import sys
import numpy as np
import pandas as pd

from numpy.core import numeric

stop = False
def trace(frame, event, arg):
global stop
if stop:
return None

if np.core.numeric.dtype is not np.dtype:
print("Something happened here, `np.core.numeric.dtype IS np.dtype`")
print(frame, event, arg)
stop = True
else:
print(frame, event, arg)

return trace

sys.settrace(trace)

pd._libs.lib.maybe_convert_objects(np.array([None], dtype=object))


For completeness, the Cython code calling the NumPy function in question, is 
(likley, there is more, this is Cython, I just cut it out a bit :)):

  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_6, Py_False};
__pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 
2+__pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2441, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_GOTREF(__pyx_t_15);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif

--
components: Interpreter Core
messages: 411082
nosy: seberg
priority: normal
severity: normal
status: open
title: Possibly bad interaction with tracing and cython?
type: crash
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



[issue46415] ipaddress.ip_{address, network, interface} raises TypeError instead of ValueError if given a tuple as address

2022-01-20 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Duplicate of issue46141.

--
nosy: +Jelle Zijlstra
resolution:  -> duplicate
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



[issue46450] namedtuple leaks data between instances when field's default value is empty list

2022-01-20 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

This seems to be the standard confusion people have with mutable defaults, just 
with namedtuple defaults rather than function defaults.

Similar behavior elsewhere in Python:

>>> def f(x, y=[]):
... y.append(x)
... print(y)
... 
... 
>>> f(1)
[1]
>>> f(2)
[1, 2]
>>> f(15)
[1, 2, 15]

Or even

>>> a = []
>>> b = a
>>> b.append(4)
>>> a
[4]

This happens because the values you provide as defaults are *objects*, not 
*expressions* to be re-evaluated. If you make one of the defaults a list, you 
ask the namedtuple to "give me this particular list every time", and it will 
give you that same list, even if it has been modified.

There is currently no support for "construct a brand new list every time" in 
namedtuples. You could look to the dataclasses module for such a feature, where 
you can specify default_factory=list, and it will make a new list for each 
instance.

https://docs.python.org/3/library/dataclasses.html#dataclasses.field

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46450] namedtuple leaks data between instances when field's default value is empty list

2022-01-20 Thread Curtis M


New submission from Curtis M <3ed7qja...@liamekaens.com>:

Example code to replicate issue on python 3.10.2 is attached.

How to replicate issue:
1. Define a namedtuple where all fields have default values. At least one 
field's default value will be an empty list: []
2. Instantiate 2 instances of the namedtuple.
3. In the first instance, use namedtuple._replace() to add a replacement list 
into a field that defaults to [].
4. Now look at the contents of both namedtuples. *Both* of them are modified, 
even though the code only modified the first object.


***

Output from attached example code:

g.P5 1: myNamedTuple(P1='hello', P2='world', P3=None, P4='', P5=[], P6=[])
h.P5 1: myNamedTuple(P1='good', P2='morning', P3=None, P4='', P5=[], P6=[])
Expected: g.P5: []
Actual:   g.P5: []
Expected: h.P5: []
Actual:   h.P5: []
g.P5 2: myNamedTuple(P1='hello', P2='world', P3=None, P4='', P5=['a', 'b'], 
P6=[])
h.P5 2: myNamedTuple(P1='good', P2='morning', P3=None, P4='', P5=['a', 'b'], 
P6=[])
Expected: g.P5: ['a', 'b']
Actual:   g.P5: ['a', 'b']
Expected: h.P5: []
Actual:   h.P5: ['a', 'b']
g.P5 3: myNamedTuple(P1='hello', P2='world', P3=None, P4='', P5=['a', 'b', 'c', 
'd'], P6=[])
h.P5 3: myNamedTuple(P1='good', P2='morning', P3=None, P4='', P5=['a', 'b', 
'c', 'd'], P6=[])
Expected: g.P5: ['a', 'b', 'c', 'd']
Actual:   g.P5: ['a', 'b', 'c', 'd']
Expected: h.P5: []
Actual:   h.P5: ['a', 'b', 'c', 'd']

--
components: Library (Lib)
files: namedtuple_example.py
messages: 411079
nosy: user027.7
priority: normal
severity: normal
status: open
title: namedtuple leaks data between instances when field's default value is 
empty list
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50568/namedtuple_example.py

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread Tim Peters


Tim Peters  added the comment:

I think you should give up on this. But suit yourself ;-)

Exactly the same information is conveyed whether representing a graph by 
successor or predecessor dicts. Some operations are more convenient in one 
representation than the other, but each is easily derived from the other.

For your

> The issue with the current form is that you can not traverse
> the graph, at least not forwards.

is the equal and opposite complaint that with "your" (successor) form, you 
cannot traverse the graph, at least not backwards.

What of it? _Some_ packages maintain both predecessor and successor dicts in 
lockstep. For example, Kosaraju's elegant algorithm for finding strongly 
connected components requires efficient traversal in both directions.

The topsort algorithm couldn't care less how you want to represent your graphs. 
But it does have a specific representation it requires if you want to use the 
optional `graph=` constructor argument. It's documented and works fine if used 
as documented.

> What is important about the topo-sort is that it makes all of the
> edges point in the *same* direction.

Not following that. topsort applies to directed graphs, where the meanings of 
"predecessor" and "successor" are universally agreed upon. By definition, a 
topsort must begin with an element having no predecessors. The directions of 
the arrows are crucial to that.

> It doesn't actually matter which direction that is. And credit where due, the
> library picked the more-useful direction. It was a pragmatic choice, driven
> by the real use case of dependency resolution.

Not really. It was driven by the definition of what "topological sort" means. 
Most of the API was actually driven by making it easy to use correctly 
(race-free, deadlock-free) in a dynamic (there's no way to guess from one run 
to the next which order will end up being used) multiprocessing context, 
something few topsort packages even attempt to address.

> But having the graph with arrows pointing in the wrong direction is
> going to cause endless confusion.

Starting when? ;-) Seriously, this is the first complaint I've seen, and you're 
not actually confused.

> For an example of the confusion this causes, look at the API itself. The "add"
> method explicitly calls out the fact that you can add nodes with no 
> predecessors.

And what about that is confusing? If every node has to have a predecessor, a 
topsort can't even exist!

More generally, any usable implementation of "directed graph" has to allow for 
isolated nodes too. Historically, the docs pointed that out to contrast it with 
other APIs under consideration that required special tricks to convince the 
function that a graph had isolated nodes. In this API, it's dead easy: just add 
the node with no predecessors.

> This is obviously also possible with the graph argument as it currently is.

Of course. Are you going to seriously contend this is "a problem", but the 
obvious workalike for successor dicts would not be "a problem"? (In a successor 
dict, it's equally easy to specify a node with no successors. Good! For a total 
ordering to exist, there must be at least one node with no predecessor and at 
least one with no successor - these aren't "problems", they're essentials.)

In any case, the docs say what was intended and implemented from the start: the 
optional `graph` argument is a predecessor dict representation. You're not 
required to like that decision, but there's no case here - to my eyes - made 
for saying "it's a bug".

--

___
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-20 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +eric.snow, gvanrossum

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d013b241352e902389f955f8f99d75f16c124ee2 by Victor Stinner in 
branch 'main':
bpo-46417: signal uses PyStructSequence_NewType() (GH-30735)
https://github.com/python/cpython/commit/d013b241352e902389f955f8f99d75f16c124ee2


--

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:

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

--

___
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-20 Thread STINNER Victor


New submission from STINNER Victor :

Using the C program below, I see that _Py_RefTotal is decreasing at each 
iteration:
---
#include 
int main(int argc, char *argv[])
{
for (int i=1; i <= 100; i++) {
Py_SetProgramName(L"./_testembed");
Py_Initialize();
Py_Finalize();
printf("Loop #%d: %zd refs\n", i, _Py_RefTotal);
}
}
---

Example of output:
---
...
Loop #96: 9557 refs
Loop #97: 9544 refs
Loop #98: 9531 refs
Loop #99: 9518 refs
Loop #100: 9505 refs
---

It seems to be a regression caused by this change:

commit 1cbaa505d007e11c4a1f0d2073d72b6c02c7147c
Author: Guido van Rossum 
Date:   Wed Nov 10 18:01:53 2021 -0800

bpo-45696: Deep-freeze selected modules (GH-29118)

This gains 10% or more in startup time for `python -c pass` on UNIX-ish 
systems.

The Makefile.pre.in generating code builds on Eric's work for bpo-45020, 
but the .c file generator is new.

Windows version TBD.


Before the change, _Py_RefTotal was stable: 
---
...
Loop #97: 10805 refs
Loop #98: 10805 refs
Loop #99: 10805 refs
Loop #100: 10805 refs
---

I found this issue while working on bpo-46417 which is related to bpo-1635741.

--
components: Interpreter Core
messages: 411075
nosy: vstinner
priority: normal
severity: normal
status: open
title: Deep-freezed modules create inconsistency in sys.gettotalrefcount() 
(_Py_Reftotal)
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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> The argument passed is the predecessor form of the graph B -> A

where graph = {'A' : ['B']}

This is part that I'm objecting to. The form of the graph should be A -> B, not 
B -> A.

The issue with the current form is that you can not traverse the graph, at 
least not forwards. When I say traverse forwards I mean that you follow the 
edges in the direction of the arrows. If you look up 'A' in the current graph 
you get  all of the nodes that point  *to* A, but that doesn't help you get 
*from* A to anywhere else.

There are two conventions:
1) Graphs should be traverse-able, by following the arrows.
2) Topological sorting makes the arrows point to the right.

Convention #1 was broken to satisfy convention #2.

What is important about the topo-sort is that it makes all of the edges point 
in the *same* direction. It doesn't actually matter which direction that is. 
And credit where due, the library picked the more-useful direction. It was a 
pragmatic choice, driven by the real use case of dependency resolution.

But having the graph with arrows pointing in the wrong direction is going to 
cause endless confusion.

For an example of the confusion this causes, look at the API itself. The "add" 
method explicitly calls out the fact that you can add nodes with no 
predecessors. This is obviously also possible with the graph argument as it 
currently is.

> It is possible to add a node with no dependencies (predecessors is not 
> provided)
   
https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter.add

--

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1781d55eb34f94029e50970232635fc5082378cb by Victor Stinner in 
branch 'main':
bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736)
https://github.com/python/cpython/commit/1781d55eb34f94029e50970232635fc5082378cb


--

___
Python tracker 

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



[issue46427] Correct MSBuild's configuration for _freeze_module.exe

2022-01-20 Thread neonene


neonene  added the comment:

> +  

This is bad if ARM64 machine takes the blank value as not "ARM64" but "ARM", as 
"ARM" tools are not necessary to install. Then, I agree with the  proposal of 
the OP (PR28491) below:

> Would it be acceptable if a new host platform property is added to
> the project file and keep x64 or x86 as default (depends on target)
> but allow users to configure a different host platform to allow
> native arm64 compilation?

--

___
Python tracker 

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



Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Abdur-Rahmaan Janhangeer
Well, this one is a newspaper as opposed to being a newsletter.

Newsletters are a collection of links. See

AwesomePython
PythonWeekly
PyCoders Weekly

Newspapers also contain articles, the above don't.

As some mails pointed out above, this is like
the lwn of Python

I have been avoiding the topics and formats used by existing
newsletters by focusing on news among others.

But its funny to see one of them starting to cover news
by writing an external article on a website they own
then link it in the newsletter. It's what you call
competition i guess XD

The focus of this one is and remains mailing lists / discuss platforms.
A look at the archives and you can see publishing
interesting mails. Something you don't have with newsletters.

The main aim of it is getting myself updated with
discussions and pep status and sharing it with the world.
Something i feel i was not getting with existing resources.
I had cool tutos/articles, new libs, popular posts,
job openings, events but not a complete overview
of meta posts.

On Fri, 21 Jan 2022, 02:13 Dan Stromberg,  wrote:

>
> There's also Python Weekly:
> https://www.pythonweekly.com/
>
> On Sat, Jan 8, 2022 at 10:29 PM Abdur-Rahmaan Janhangeer <
> arj.pyt...@gmail.com> wrote:
>
>> Well yes XD though LWN covers Py topics well when it wants
>>
>>
>> 1. Yes sure, did not expect RSS interest
>> 2. Excuse my blunder, will do!
>>
>>
>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2022-01-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28923
pull_request: https://github.com/python/cpython/pull/30736

___
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-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28922
pull_request: https://github.com/python/cpython/pull/30735

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 17f268a4ae6190b2659c89c6f32ad2d006e0e3c8 by Victor Stinner in 
branch 'main':
bpo-46417: time module uses PyStructSequence_NewType() (GH-30734)
https://github.com/python/cpython/commit/17f268a4ae6190b2659c89c6f32ad2d006e0e3c8


--

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f389b37fb1cebe7ed66331cdd373a014695261f6 by Victor Stinner in 
branch 'main':
bpo-46417: _thread uses PyStructSequence_NewType() (GH-30733)
https://github.com/python/cpython/commit/f389b37fb1cebe7ed66331cdd373a014695261f6


--

___
Python tracker 

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



[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2022-01-20 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

This behavior is definitely unfortunate, but by now it's also been baked into 
more than a decade of Python 3 releases, so backward compatibility constraints 
make it difficult to fix.

How can we be sure this change won't break users' code?

For reference, here are a few uses of the function I found in major open-source 
packages:
- 
https://github.com/httplib2/httplib2/blob/cde9e87d8b2c4c5fc966431965998ed5f45d19c7/python3/httplib2/__init__.py#L1608
 - this assumes it only ever hits the (bytes, encoding) case.
- 
https://github.com/cherrypy/cherrypy/blob/98929b519fbca003cbf7b14a6b370a3cabc9c412/cherrypy/lib/httputil.py#L258
 - this assumes it only gets (str, None) or (bytes, encoding) pairs, which 
seems unsafe. But if it currently sees (str, None) and would see (bytes, None) 
with this change, it would break.

An alternative solution could be a new function with a sane return type.

Even if we decide to not change anything, we should document the surprising 
return type at https://docs.python.org/3.10/library/email.header.html.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread Tim Peters


Tim Peters  added the comment:

I'm going to leave this to Pablo - adding the `graph` argument was his idea ;-)

It would, I think, have been better if this argument had been named, say, 
"preds" instead of "graph".

The docs, to my eyes, are entirely clear about that `graph` is a representation 
based on mapping a node to its predecessors:

"""
If the optional graph argument is provided it must be a dictionary representing 
a directed acyclic graph where the keys are nodes and the values are iterables 
of all predecessors of that node in the graph (the nodes that have edges that 
point to the value in the key). 
"""

but it could perhaps be usefully emphasized that "the usual" graph 
representation in Python maps a node to its successors instead.

The stuff about "direction" continues to make no sense to me, though. The class 
computes the (forward!) topsort of the graph passed to it, given that the graph 
is presented as mapping nodes to predecessors. It's only "reversed" if you 
refuse to believe the docs, and insist that `graph` is mapping a node to its 
successors. But it's not.

>>> import graphlib
>>> ts = graphlib.TopologicalSorter({'A' : ['B']})
>>> list(ts.static_order())
['B', 'A']

Nothing is "reversed". The argument passed is the predecessor form of the graph 
B -> A, and [B, A] is the forward topsort of that graph.

--

___
Python tracker 

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



[issue46399] Addition of `mapping` attribute to dict views classes has inadvertently broken type-checkers

2022-01-20 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy:  -gvanrossum

___
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-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28921
pull_request: https://github.com/python/cpython/pull/30734

___
Python tracker 

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



[issue45384] Accept Final as indicating ClassVar for dataclass

2022-01-20 Thread Mehdi2277


Mehdi2277  added the comment:

I recently hit this issue working on a config/parsing runtime type checking 
library (similar in spirit to pydantic).

The one other special typeform I was using these with that led me to discover 
this issue was Annotated. I use Annotated a fair amount to do some runtime 
analysis and I was used to `Annotated[typeform]` always works. But ClassVar and 
Final are special and `Annotated[ClassVar[...]] `and `Annotated[Final[...]]` 
both fail. I find `Annotated` interaction also weird. I ended up working around 
it by doing `ClassVar[Annotated[...]]` and stripping the classvar/final to look 
for the annotation metadata.

I think all 3 of annotated/final/classvar should be order compatible as they 
all serve to add information on the type they contain. 

If we ignore Annotated, I would say ClassVar/Final should be order compatible 
and a rule that Final[ClassVar[...]] works but not ClassVar[Final[...]] or vice 
versa would be weird.

--
nosy: +med2277

___
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-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28920
pull_request: https://github.com/python/cpython/pull/30733

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 6415e2ee4955b1a995c1e75544e2506b03780c3d by Victor Stinner in 
branch 'main':
bpo-46417: _testembed.c avoids Py_SetProgramName() (GH-30732)
https://github.com/python/cpython/commit/6415e2ee4955b1a995c1e75544e2506b03780c3d


--

___
Python tracker 

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



[issue46399] Addition of `mapping` attribute to dict views classes has inadvertently broken type-checkers

2022-01-20 Thread Inada Naoki


Inada Naoki  added the comment:

> If we literally ignore the attribute, any usage of `.mapping` will be an 
> error, which basically makes the whole `.mapping` feature useless for 
> statically typed code. It also wouldn't appear in IDE autocompletions.

`.mapping` is not exist between Python 3.0~3.9. And it is not feature that is 
long awaited by many users.

See https://bugs.python.org/issue40890#msg370841
Raymond said:

  Traditionally, we do expose wrapped objects:  property() exposes fget,  
partial() exposes func, bound methods expose __func__, ChainMap() exposes maps, 
etc.
  Exposing this attribute would help with introspection, making it possible to 
write efficient functions that operate on dict views.

Type hints is very useful for application code, especially when it is large.
But introspection is very rarely used in such typed code bases. I don't think 
`.mapping` is useful for many users, like `.fget` of the property.
So adding `# type: ignore` in such lines is the "lesser evil".


> If we add it to `KeysView` and `ValuesView`, library authors will end up 
> using `.mapping` with arguments annotated as `Mapping` or `MutableMapping`, 
> not realizing it is purely a dict thing, not required from an arbitrary 
> mapping object.

It doesn't make sense at all, IMO.
If we really need `.mapping` in typeshed, we should add it to 
`KeysViewWithMapping`.
So mapping classes that don't inherit dict shouldn't be forced to implement 
`.mapping`.


> If we keep `.mapping` in dict but not anywhere else, as described already, it 
> becomes difficult to override .keys() and .values() in a dict subclass. You 
> can't just return a KeysView or a ValuesView. If that was allowed, how should 
> people annotate code that uses `.mapping`? You can't annotate with `dict`, 
> because that also allows subclasses of dict, which might not have a 
> `.mapping` attribute.

`# type: ignore`.


> Yet another option would be to expose `dict_keys` and `dict_values` somewhere 
> where they don't actually exist at runtime. This leads to code like this:
>
> from typing import Any, TYPE_CHECKING
> if TYPE_CHECKING:
> # A lie for type checkers to work.
> from something_that_doesnt_exist_at_runtime import dict_keys, dict_values
> else:
> # Runtime doesn't check type annotations anyway.
> dict_keys = Any
> dict_values = Any
>
> While this works, it isn't very pretty.

What problem this problem solve? `SortedDict.keys()` can not return `dict_keys`.
As far as I think, your motivation is making dict subclass happy with type 
checkers.
But this option doesn't make dict subclass happy at all.

--

___
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-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28919
pull_request: https://github.com/python/cpython/pull/30732

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset e9e3eab0b868c7d0b48e472705024240d5c39d5c by Victor Stinner in 
branch 'main':
bpo-46417: Finalize structseq types at exit (GH-30645)
https://github.com/python/cpython/commit/e9e3eab0b868c7d0b48e472705024240d5c39d5c


--

___
Python tracker 

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



[issue46070] [subinterpreters] crash when importing _sre in subinterpreters in parallel (Python 3.9 regression)

2022-01-20 Thread STINNER Victor


Change by STINNER Victor :


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

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:

Another measure using the command:

PYTHONHASHSEED=0 ./python -X showrefcount -c pass

I had to run the command 20 times to get a stable value, I don't know why.

main branch: [21981 refs, 5716 blocks]
PR: [21887 refs, 5667 blocks]

=> the PR removes 94 references and 49 memory blocks.

--

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> If the way the user collects their data stores only successor links (which, 
> as above, seems odd in applications that actually use topsorts), then they 
> need something like this instead:

Actually they only need to do this:

ts = TopologicalSorter(my_forward_graph).static_order()
ts = reversed(ts)


I think part of the issue here is that the document uses two terms to describe 
the same thing: "predecessor" and "edge-direction". Everywhere it discusses 
predecessors it gets it right, but the edge direction is hopelessly confused 
because they tried to use the "normal" definition of topo-sort and the only way 
to make that work is to also reverse the direction of the graph's edges to 
compensate (and the two reversals cancel each other out).

The edge direction is only mentioned twice in the whole document, once to 
define topo-sort and again to define the graph format.

If the users problem fits into the task dependency paradigm, then this library 
makes a lot of sense. But for users who just have a directed graph, the 
documentation is really really confusing. 

I think it would be much better if the document explained that this was a 
"reversed" topological sort with a slightly different definition, and used a 
"bog standard" graph format like for example in this tutorial: 
https://www.python.org/doc/essays/graphs/

--

___
Python tracker 

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



[issue46400] Please update bundled libexpat to 2.4.3 with security fixes

2022-01-20 Thread Ned Deily


Change by Ned Deily :


--
nosy:  -ned.deily, paul.moore, ronaldoussoren, steve.dower, tim.golden, 
zach.ware

___
Python tracker 

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



[issue46400] Please update bundled libexpat to 2.4.3 with security fixes

2022-01-20 Thread Ned Deily


Ned Deily  added the comment:

The bundled expat is potentially used by all Python builds, not just Windows or 
Mac builds.

--

___
Python tracker 

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



[issue19479] textwrap.dedent doesn't work properly with strings containing CRLF

2022-01-20 Thread Irit Katriel


Change by Irit Katriel :


--
type: behavior -> enhancement
versions: +Python 3.11 -Python 2.7, Python 3.3

___
Python tracker 

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



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

The "reverse-toposort" is actually quite a good idea. The end-user is usually 
going to want to iterate over the sorted output in the "reverse" order anyways, 
especially if they're doing task ordering / dependency resolution.

Also, the underlying algorithm produces the "reverse" ordering by default. In 
my experience from writing and using my own topological sorting programs using 
the "correct" definition: the toposorter reverses the list, and then the users 
iterates over it in reverse order.

--

___
Python tracker 

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



[issue46427] Correct MSBuild's configuration for _freeze_module.exe

2022-01-20 Thread neonene


neonene  added the comment:

> When cross-compiling, tools that are executed as part of the build need to be 
> built for the tool platform, not the target platform.

My PR does not against that at this point, as proposed codes are based on your 
PR28322 (09b4ad11f323f8702cde795e345b75e0fbb1a9a5).
If we now need to prepare for future MSVC *on* ARM, then current _freeze_module 
configurations in "pcbuild.sln" also need to be reconsidered:

{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM.ActiveCfg = Debug|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM.Build.0 = Debug|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM64.ActiveCfg = Debug|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Debug|ARM64.Build.0 = Debug|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGInstrument|ARM.ActiveCfg = 
Release|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGInstrument|ARM.Build.0 = Release|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGInstrument|ARM64.ActiveCfg = 
Release|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGInstrument|ARM64.Build.0 = Release|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGUpdate|ARM.ActiveCfg = Release|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.PGUpdate|ARM64.ActiveCfg = Release|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Release|ARM.ActiveCfg = Release|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Release|ARM.Build.0 = Release|Win32
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Release|ARM64.ActiveCfg = Release|x64
{19C0C13F-47CA-4432-AFF3-799A296A4DDC}.Release|ARM64.Build.0 = Release|x64


Anyway, what I care about is the usage of "PreferredToolArchitecture" property 
in the current configuration.
The property has nothing to do with whether the host is ARM* or not. Another 
property will do in the future.

When building x86 python with 64bit compiler (set 
PreferredToolArchitecture=x64), _freeze_module gets a x64 executable.

The following change is acceptable?

-  $(PreferredToolArchitecture)
+  

They are the same with no envvar. _freeze_module is always 32bit, though.

--

___
Python tracker 

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



[issue28982] multiprocessing.Queue.get(block=True, timeout=0) always raises queue.Empty

2022-01-20 Thread Irit Katriel


Irit Katriel  added the comment:

On 3.11 I get this on both Mac and windows:

>>> from multiprocessing import Queue
>>> q = Queue()
>>> q.put('foo')
>>> q.get(True, 0)  # raises Empty
'foo'

--
nosy: +iritkatriel
resolution:  -> out of date
status: open -> pending

___
Python tracker 

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



[issue46080] argparse.BooleanOptionalAction with default=argparse.SUPPRESS and help specified raises exception

2022-01-20 Thread miss-islington


miss-islington  added the comment:


New changeset c6691a7ccbd027298ea2486014b55db037fffc9f by Miss Islington (bot) 
in branch '3.9':
bpo-46080: fix argparse help generation exception in edge case (GH-30111)
https://github.com/python/cpython/commit/c6691a7ccbd027298ea2486014b55db037fffc9f


--

___
Python tracker 

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



[issue46448] TypedDict inspect.signature error

2022-01-20 Thread jhwang


New submission from jhwang :

I have Python 3.10.1 (Dec, 2021) installed and I see an error when inspecting 
signature of TypedDict class. This is the same issue reported on Issue43006 
(msg385535 - (view)). It was marked as resolved but the error looks persistent. 
Can someone confirm if this was fixed or any release version with the fix? 


import inspect

class T(typing.TypedDict):
a: int

print(inspect.signature(T))

was `(*args, **kwargs)` and now raises `ValueError: no signature found for 
builtin type `

--
components: Library (Lib)
messages: 411056
nosy: jhwang
priority: normal
severity: normal
status: open
title: TypedDict inspect.signature error
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



[issue27302] csv.Sniffer guesses wrong when unquoted fields contain quotes

2022-01-20 Thread Irit Katriel


Change by Irit Katriel :


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



Re: Puzzling behaviour of Py_IncRef

2022-01-20 Thread Chris Angelico
On Fri, 21 Jan 2022 at 10:10, Greg Ewing  wrote:
>
> On 20/01/22 12:09 am, Chris Angelico wrote:
> > At this point, the refcount has indeed been increased.
> >
> >>   return self;
> >>  }
> >
> > And then you say "my return value is this object".
> >
> > So you're incrementing the refcount, then returning it without
> > incrementing the refcount. Your code is actually equivalent to "return
> > self".
>
> Chris, you're not making any sense. This is C code, so there's no
> way that "return x" can change the reference count of x.

Yeah, I wasn't clear there. It was equivalent to *the Python code*
"return self". My apologies.

>  > The normal thing to do is to add a reference to whatever you're
>  > returning. For instance, Py_RETURN_NONE will incref None and then
>  > return it.
>  >
>
> The OP understands that this is not a normal thing to do. He's
> trying to deliberately leak a reference for the purpose of diagnosing
> a problem.
>
> It would be interesting to see what the actual refcount is after
> calling this function.
>

Yes, and that's why I was saying it would need a *second* incref.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46080] argparse.BooleanOptionalAction with default=argparse.SUPPRESS and help specified raises exception

2022-01-20 Thread miss-islington


miss-islington  added the comment:


New changeset e5edc8d737a45d9d8b9b93b8be52f85d79d0f417 by Miss Islington (bot) 
in branch '3.10':
bpo-46080: fix argparse help generation exception in edge case (GH-30111)
https://github.com/python/cpython/commit/e5edc8d737a45d9d8b9b93b8be52f85d79d0f417


--

___
Python tracker 

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



[issue41857] Document timeout arguments to poll() in select module

2022-01-20 Thread Tal Einat


Tal Einat  added the comment:


New changeset 27df7566bc19699b967e0e30d7808637b90141f6 by Zane Bitter in branch 
'main':
bpo-41857: mention timeout argument units in select.poll() and select.depoll() 
doc-strings (GH-22406)
https://github.com/python/cpython/commit/27df7566bc19699b967e0e30d7808637b90141f6


--
nosy: +taleinat

___
Python tracker 

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



Re: Puzzling behaviour of Py_IncRef

2022-01-20 Thread Greg Ewing

On 20/01/22 12:09 am, Chris Angelico wrote:

At this point, the refcount has indeed been increased.


  return self;
 }


And then you say "my return value is this object".

So you're incrementing the refcount, then returning it without
incrementing the refcount. Your code is actually equivalent to "return
self".


Chris, you're not making any sense. This is C code, so there's no
way that "return x" can change the reference count of x.

> The normal thing to do is to add a reference to whatever you're
> returning. For instance, Py_RETURN_NONE will incref None and then
> return it.
>

The OP understands that this is not a normal thing to do. He's
trying to deliberately leak a reference for the purpose of diagnosing
a problem.

It would be interesting to see what the actual refcount is after
calling this function.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


[issue7275] CoverageResult fails to merge input file with non-empty callers in trace.py

2022-01-20 Thread Irit Katriel


Irit Katriel  added the comment:

The patch needs to be converted to a GitHub PR.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue7275] CoverageResult fails to merge input file with non-empty callers in trace.py

2022-01-20 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy -patch
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.5, Python 3.6

___
Python tracker 

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



Re: empty stdout (subprocess.run)

2022-01-20 Thread James Smith
On Wednesday, January 19, 2022 at 11:14:28 PM UTC-5, cameron...@gmail.com wrote:

> But I recommend you use shell=False and make: 
> 
> cmd = ["/usr/bin/transmission-remote", "--torrent", str(torrentno), "--info"] 

I like that. :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: empty stdout (subprocess.run)

2022-01-20 Thread James Smith
On Wednesday, January 19, 2022 at 11:08:58 PM UTC-5, Dennis Lee Bieber wrote:

> Don't you need to provide for that %s? Perhaps 
> 
> cmd="/usr/bin/transmission-remote --torrent %s --info" % torrentno 

That works, thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-20 Thread NArshad


- I will try to follow all that you people are saying, but it will take time or 
next time. The chance of concurrency is very less. Kindly don't write big 
descriptions.

- The weblink Avi Gross has given is very useful.






-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24527] The MimeTypes class cannot ignore global files per instance

2022-01-20 Thread Irit Katriel


Change by Irit Katriel :


--
type: behavior -> 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



[issue23162] collections.abc sequences don't check identity before equality

2022-01-20 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Test identity first in membership operation of ItemsView, 
ValuesView and Sequence in collections.abc

___
Python tracker 

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



[issue46080] argparse.BooleanOptionalAction with default=argparse.SUPPRESS and help specified raises exception

2022-01-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28918
pull_request: https://github.com/python/cpython/pull/30731

___
Python tracker 

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



[issue46080] argparse.BooleanOptionalAction with default=argparse.SUPPRESS and help specified raises exception

2022-01-20 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +28917
pull_request: https://github.com/python/cpython/pull/30730

___
Python tracker 

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



[issue46080] argparse.BooleanOptionalAction with default=argparse.SUPPRESS and help specified raises exception

2022-01-20 Thread Tal Einat


Tal Einat  added the comment:


New changeset 9e87c0e03fa501fb90008547983ce4c1dcaaf90c by Felix Fontein in 
branch 'main':
bpo-46080: fix argparse help generation exception in edge case (GH-30111)
https://github.com/python/cpython/commit/9e87c0e03fa501fb90008547983ce4c1dcaaf90c


--
nosy: +taleinat

___
Python tracker 

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



[issue40529] Auto Completions with case insensitive

2022-01-20 Thread Tal Einat


Tal Einat  added the comment:

This should probably be brought up in the python-ideas mailing list, which is 
much more active than the group 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



[issue40529] Auto Completions with case insensitive

2022-01-20 Thread Tal Einat


Change by Tal Einat :


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

___
Python tracker 

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



[issue40529] Auto Completions with case insensitive

2022-01-20 Thread Tal Einat


Change by Tal Einat :


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

___
Python tracker 

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



[issue41857] Document timeout arguments to poll() in select module

2022-01-20 Thread Tal Einat


Change by Tal Einat :


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



[issue46070] [subinterpreters] crash when importing _sre in subinterpreters in parallel (Python 3.9 regression)

2022-01-20 Thread STINNER Victor


STINNER Victor  added the comment:

Another measure using the command:

PYTHONHASHSEED=0 ./python -X showrefcount -c pass

I had to run the command 20 times to get a stable value, I don't know why.

main branch: [21981 refs, 5716 blocks]
PR: [21887 refs, 5667 blocks]

=> the PR removes 94 references and 49 memory blocks.

--

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:

I checked with Valgrind the affect of PR 30645.

main branch:

==330902== LEAK SUMMARY:
==330902==  possibly lost: 29,128 bytes in 494 blocks
==330902==still reachable: 353,615 bytes in 3,577 blocks

With the PR:

==332161== LEAK SUMMARY:
==332161==  possibly lost: 24,456 bytes in 417 blocks
==332161==still reachable: 337,223 bytes in 3,423 blocks

It frees 21,064 bytes (20 kB) in Py_Finalize().

--

___
Python tracker 

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



[issue46086] Add ratio_min() function to the difflib library

2022-01-20 Thread Tal Einat


Tal Einat  added the comment:

I'm closing this for now since nobody has followed up and to the best of my 
understanding this wouldn't be an appropriate addition to the stdlib. 

This can be re-opened in the future if needed, of course.

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



Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Dan Stromberg
There's also Python Weekly:
https://www.pythonweekly.com/

On Sat, Jan 8, 2022 at 10:29 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Well yes XD though LWN covers Py topics well when it wants
>
>
> 1. Yes sure, did not expect RSS interest
> 2. Excuse my blunder, will do!
>
>

> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread Tim Peters


Tim Peters  added the comment:

For the purpose of topological sorting, yes, it's by far most natural to give, 
for each node, the collection of that node's predecessors. And that's the way 
topsort applications typically collect their data to begin with, like, "here, 
for each recipe, is a list of ingredients needed first" or "before we can begin 
this job, here are the other jobs that need to complete first". or, as in 
makefiles, "here's a list of the targets that need to be built before we can 
start building the current target".

I definitely don't want to change the wording, because it's bog standard as is. 
For example, Wikipedia's "topological sorting" entry is typical:

"""
In computer science, a topological sort or topological ordering of a directed 
graph is a linear ordering of its vertices such that for every directed edge uv 
from vertex u to vertex v, u comes before v in the ordering. 
"""

It's what topsort _means_. We did not intend to implement a "reverse topsort" 
algorithm, and I see no attraction to doing so, neither in pretending we did so.

If the way the user collects their data stores only successor links (which, as 
above, seems odd in applications that actually use topsorts), then they need 
something like this instead:

ts = TopologicalSorter()
for u, successors in my_forward_graph.items():
for v in successors:
ts.add(v, u)

But that's something I never needed.

--

___
Python tracker 

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



[issue26792] docstrings of runpy.run_{module,path} are rather sparse

2022-01-20 Thread Humbdrag


Change by Humbdrag :


--
nosy: +humbdrag
nosy_count: 3.0 -> 4.0
pull_requests: +28916
pull_request: https://github.com/python/cpython/pull/30729

___
Python tracker 

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



[issue46447] datetime.isoformat() documentation does not point to the risk of using it with naive datetime objects

2022-01-20 Thread Jean Carlo Machado


New submission from Jean Carlo Machado :

datetime.utcnow() already present a warning box describing the risk of using it 
without specifying timezone information. However, one might still have the same 
problem and never encounter this warning information by doing 
datetime.now().isoformat(). Or just by not reading the docs of datetime.utcnow, 
just the datetime.isoformat docs.

By adding a similar warning to the datetime.isoformat() we could make the risk 
clearer and reduce the likelihood of errors. Is when calling isoformat() where 
people get confident to be producing ISO's.

I just recently had an incident in my company where we produced naive datetimes 
using datetime.now() and serialized them using isoformat() while expecting them 
to be a transferrable ISO format. Nevertheless, the other system read the dates 
without Z in the end and interpreted it as local time.

If you agree that this suggestion could be a good improvement to the docs, I 
can send a patch in the next 2 weeks.

--
assignee: docs@python
components: Documentation
messages: 411046
nosy: docs@python, jeanCarloMachado
priority: normal
severity: normal
status: open
title: datetime.isoformat() documentation does not point to the risk of using 
it with naive datetime objects
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



[issue45413] Add install scheme for virtual environments

2022-01-20 Thread Stefano Rivera


Change by Stefano Rivera :


--
nosy: +stefanor

___
Python tracker 

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



[issue46070] [subinterpreters] crash when importing _sre in subinterpreters in parallel (Python 3.9 regression)

2022-01-20 Thread jokot3


Change by jokot3 :


--
nosy: +jokot3

___
Python tracker 

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



[issue23325] Turn SIG_DFL and SIG_IGN into functions

2022-01-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It may take a time, because the module initialization code has been completely 
rewritten.

--

___
Python tracker 

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



[issue46441] Caret points to wrong line on 'return yield 42' in REPL

2022-01-20 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:


New changeset 30fb6d073d9ca00dff8e4155c523cdfa63abab6b by Batuhan Taskaya in 
branch 'main':
bpo-46441: Add a boilerplate to test syntax errors in interactive mode 
(GH-30720)
https://github.com/python/cpython/commit/30fb6d073d9ca00dff8e4155c523cdfa63abab6b


--

___
Python tracker 

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



[issue43654] IDLE: Fix tab completion after settings and some keys

2022-01-20 Thread Tal Einat


Tal Einat  added the comment:

Terry, for all intents and purposes you're the one in charge of IDLE now. I 
suggest deciding whether to change all three bindings as in the current PR or 
only the one for completions. Just le me know and if needed I'll make a new PR.

--

___
Python tracker 

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



[issue46316] Optimize pathlib.Path.iterdir()

2022-01-20 Thread Zachary Ware


Change by Zachary Ware :


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



[issue46316] Optimize pathlib.Path.iterdir()

2022-01-20 Thread Zachary Ware


Zachary Ware  added the comment:


New changeset a1c88414926610a3527398a478c3e63c531dc742 by Barney Gale in branch 
'main':
bpo-46316: optimize `pathlib.Path.iterdir()` (GH-30501)
https://github.com/python/cpython/commit/a1c88414926610a3527398a478c3e63c531dc742


--
nosy: +zach.ware

___
Python tracker 

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



[issue31603] Please add argument to override stdin/out/err in the input builtin

2022-01-20 Thread Wren Turkal


Wren Turkal  added the comment:

I'm not sure that I ever got a definitive issue, but I didn't have time to
push it forward. I still think the idea has merit. I'd love to see it
implemented, but I don't have the time to pursue it right now.

Thanks,
wt

On Mon, Jan 17, 2022 at 10:23 AM Irit Katriel 
wrote:

>
> Irit Katriel  added the comment:
>
> See also Issue1927.
>
> --
> nosy: +iritkatriel
>
> ___
> Python tracker 
> 
> ___
>

--

___
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-20 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
pull_requests: +28915
pull_request: https://github.com/python/cpython/pull/30725

___
Python tracker 

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



[issue46442] testExceptionCleanupNames doesn't test anything?

2022-01-20 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Perhaps it's testing that the implicit `del` doesn't blow up if the variable is 
already deleted.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue40280] Consider supporting emscripten/webassembly as a build target

2022-01-20 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset c02e860ee79f29905be6fca997c96bb1a404bb32 by Christian Heimes in 
branch 'main':
bpo-40280: Misc fixes for wasm32-emscripten (GH-30722)
https://github.com/python/cpython/commit/c02e860ee79f29905be6fca997c96bb1a404bb32


--

___
Python tracker 

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



[issue46442] testExceptionCleanupNames doesn't test anything?

2022-01-20 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
nosy: +sobolevn

___
Python tracker 

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



[issue1284670] Allow to restrict ModuleFinder to get "direct" dependencies

2022-01-20 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Mike's fix unfortunately didn't work out.

What are the rules about closing old enhancement requests? modulefinder is an 
old and rarely used package, and I feel like the use case is better served by a 
PyPI package.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue43683] Handle generator (and coroutine) state in the bytecode.

2022-01-20 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +28914
pull_request: https://github.com/python/cpython/pull/30723

___
Python tracker 

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



[issue40280] Consider supporting emscripten/webassembly as a build target

2022-01-20 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +28913
pull_request: https://github.com/python/cpython/pull/30722

___
Python tracker 

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



[issue23325] Turn SIG_DFL and SIG_IGN into functions

2022-01-20 Thread Christian Heimes


Christian Heimes  added the comment:

Serhiy, could you please rebase your PR to tip of main branch? I'd like to try 
it out.

--
nosy: +christian.heimes
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



[issue45767] Fix types for dev_t processing in posix module

2022-01-20 Thread Dmitry Marakasov


Dmitry Marakasov  added the comment:

> Is device number -1 used in any context (for example as "unknown device 
> number")?

Yes, there's NODEV macro in both Linux and FreeBSD which expands to ((dev_t)-1).

--

___
Python tracker 

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



[issue46429] Merge all deepfrozen files into one

2022-01-20 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset ef3ef6fa43d5cca072eed2a66064e818de583be7 by Kumar Aditya in 
branch 'main':
bpo-46429: Merge all deepfrozen files into one (GH-30572)
https://github.com/python/cpython/commit/ef3ef6fa43d5cca072eed2a66064e818de583be7


--

___
Python tracker 

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



[issue46441] Caret points to wrong line on 'return yield 42' in REPL

2022-01-20 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks for the quick fix!

--

___
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-20 Thread STINNER Victor


STINNER Victor  added the comment:

If tomorrow static types are shared between sub-interpreters, it doesn't solve 
this problem: we still need to release memory allocated by Py_Initialize() in 
Py_Finalize() when Python is embedded. This issue is a sub-set of the big 
bpo-1635741 which explains the rationale. Again, this issue is not about 
sub-interpreters.

> Anyway, for this issue: is there a way to test if the types are correctly 
> reinitialized if there are multiple finalize/init cycles? I worry about 
> introducing more unexpected issues here.

I wasn't sure how to test it. But well, Dong-hee and you asked for tests, so I 
added tests for my PR ;-)

--

___
Python tracker 

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



  1   2   >