[issue46223] asyncio cause infinite loop during debug

2022-01-08 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303

___
Python tracker 

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



[issue46309] Task created by StreamReaderProtocol gets garbage collected.

2022-01-08 Thread Kumar Aditya


Change by Kumar Aditya :


--
nosy: +kumaraditya303

___
Python tracker 

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



[issue23819] test_asyncio fails when run under -O

2022-01-08 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Is anything left to do?

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



Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Paul Bryan
+1 to RSS.

On Sun, 2022-01-09 at 10:28 +0400, Abdur-Rahmaan Janhangeer 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!
> 
> On Sun, 9 Jan 2022, 01:15 Peter J. Holzer,  wrote:
> 
> > On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote:
> > > I have started a newspaper (not newsletter) focused
> > > on interesting reads on Python mailing lists. Don't tag
> > > on the fact that holiday seasons are the worst times for
> > > launch according to marketing folks, I started this to note
> > > down interesting mails. This might also be a great way to
> > > bring mailing list gems to a wider readership. So, here's
> > > the url https://pyherald.com/
> > 
> > Something like [LWN](https://lwn.net/) for Python? Neat.
> > 
> > Two suggestions:
> > 
> > 1. Could you add an RSS or Atom feed?
> > 
> > 2. CSS «word-break: break-all» seems like a really weird choice for
> >    English language text. If you really want to break words across
> >    lines, use «hyphens: auto».
> > 
> >     hp
> > 
> > --
> >    _  | Peter J. Holzer    | Story must make more sense than
> > reality.
> > > _|_) |    |
> > > >   | h...@hjp.at |    -- Charles Stross, "Creative
> > > > writing
> > __/   | http://www.hjp.at/ |   challenge!"
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


[issue46309] Task created by StreamReaderProtocol gets garbage collected.

2022-01-08 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Thanks for the bug report.

Seems like your analysis is correct.

Could you make a pull request which adds a task reference?

--

___
Python tracker 

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



[issue46223] asyncio cause infinite loop during debug

2022-01-08 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

I guess applying '@reprlib.recursive_repr' decorator to 
'events.Handle.__repr__()' function can help.

Could you check, please?

--
versions: +Python 3.10, Python 3.11

___
Python tracker 

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



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

2022-01-08 Thread Ethan Smith


Change by Ethan Smith :


--
pull_requests: +28700
pull_request: https://github.com/python/cpython/pull/30494

___
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-08 Thread Abdur-Rahmaan Janhangeer
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!

On Sun, 9 Jan 2022, 01:15 Peter J. Holzer,  wrote:

> On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote:
> > I have started a newspaper (not newsletter) focused
> > on interesting reads on Python mailing lists. Don't tag
> > on the fact that holiday seasons are the worst times for
> > launch according to marketing folks, I started this to note
> > down interesting mails. This might also be a great way to
> > bring mailing list gems to a wider readership. So, here's
> > the url https://pyherald.com/
>
> Something like [LWN](https://lwn.net/) for Python? Neat.
>
> Two suggestions:
>
> 1. Could you add an RSS or Atom feed?
>
> 2. CSS «word-break: break-all» seems like a really weird choice for
>English language text. If you really want to break words across
>lines, use «hyphens: auto».
>
> hp
>
> --
>_  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46205] test.libregrtest: Race condition in runtest_mp leads to hangs (never exits)

2022-01-08 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



[issue46110] compile("-"*3000000 + "4", '', mode) causes hard crash

2022-01-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yup. All better: 
https://speed.python.org/timeline/#/?exe=12=python_startup=1=50=off=on=on

--

___
Python tracker 

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



[issue46148] Optimize pathlib

2022-01-08 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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Ben Kehoe


Ben Kehoe  added the comment:

I opened a PR. By default, it raises an exception if there's an invalid 
identifier; there's a keyword argument raise_on_invalid to control that.

The implementation I have adds them to a set first, which means the order is 
not guaranteed. I'm of two minds about this: if there's a big template, you 
want to gather the identifiers in a set so uniqueness is checked immediately 
and O(1) and without duplication. On the other hand, if templates are never 
very big, you could build a list (in order) and check it, O(N) style, or build 
a duplicate list and set in parallel. Or build a big list and check it at the 
end.

I kind of think ordering doesn't matter? What would someone do with that 
information?

--

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Ben Kehoe


Change by Ben Kehoe :


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

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

I think you’re right that the iterator API isn’t very helpful.  I also agree 
that you probably really want to answer the “why identifiers are in this 
template?” question.  As for repeats, there’s two ways to think about it.  You 
could return all the identifiers in the order in which they’re found in the 
template (and you can unique-ify them if you want by passing that list to 
set()).  But maybe you don’t really need that either.

get_identifiers() works for me!

On Jan 8, 2022, at 18:51, Ben Kehoe  wrote:
> 
> Ben Kehoe  added the comment:
> 
> Happy to make a PR! In my mind I had been thinking it would be the 
> get_identifiers() method with the implementation above, returning a list.
> 
> As for __iter__, I'm less clear on what that would look like:
> 
> t = string.Template(...)
> for identifier in t:
>  # what would I do here?
>  # would it include repeats if they appear more than once in the template?
> 
> I guess there are two ways to think about it: one is "what identifiers are in 
> this template?" which I think should return a list with no repeats, which I 
> can then iterate over or check if a value is in it. The other is, "what are 
> the contents of the template?" in the style of string.Formatter.parse().
> 
> Given that string.Template is supposed to be the "simple, no-frills" thing in 
> comparison to string.Formatter, I see less use for the latter option.

--

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Ben Kehoe


Ben Kehoe  added the comment:

Happy to make a PR! In my mind I had been thinking it would be the 
get_identifiers() method with the implementation above, returning a list.

As for __iter__, I'm less clear on what that would look like:

t = string.Template(...)
for identifier in t:
  # what would I do here?
  # would it include repeats if they appear more than once in the template?

I guess there are two ways to think about it: one is "what identifiers are in 
this template?" which I think should return a list with no repeats, which I can 
then iterate over or check if a value is in it. The other is, "what are the 
contents of the template?" in the style of string.Formatter.parse().

Given that string.Template is supposed to be the "simple, no-frills" thing in 
comparison to string.Formatter, I see less use for the latter option.

--

___
Python tracker 

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



[issue46148] Optimize pathlib

2022-01-08 Thread Barney Gale


Change by Barney Gale :


--
nosy: +barneygale
nosy_count: 8.0 -> 9.0
pull_requests: +28697
pull_request: https://github.com/python/cpython/pull/30492

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

I've never personally needed this, but I could see where it could come in handy.

I wonder if __iter__() would be the right API for that?  I wonder then if we 
should also implement __contains__()?

Would you be interested in creating a PR for the feature?

--

___
Python tracker 

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



[issue34602] python3 resource.setrlimit strange behaviour under macOS

2022-01-08 Thread Ned Deily


Ned Deily  added the comment:


New changeset b962544594c6a7c695330dd20fedffb3a1916ba6 by Miss Islington (bot) 
in branch '3.10':
bpo-34602: Fix unportable test(1) operator in configure script (GH-30490) 
(GH-30491)
https://github.com/python/cpython/commit/b962544594c6a7c695330dd20fedffb3a1916ba6


--

___
Python tracker 

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



[issue34602] python3 resource.setrlimit strange behaviour under macOS

2022-01-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28696
pull_request: https://github.com/python/cpython/pull/30491

___
Python tracker 

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



[issue46308] Unportable test(1) operator in configure script

2022-01-08 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +28695
pull_request: https://github.com/python/cpython/pull/30491

___
Python tracker 

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



[issue46308] Unportable test(1) operator in configure script

2022-01-08 Thread Ned Deily


Ned Deily  added the comment:


New changeset 3d11c1b8b49800c5c4c295953cc3abf577f6065a by Thomas Klausner in 
branch 'main':
bpo-46308: Fix unportable test(1) operator in configure script (GH-30490)
https://github.com/python/cpython/commit/3d11c1b8b49800c5c4c295953cc3abf577f6065a


--
nosy: +ned.deily

___
Python tracker 

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



[issue34602] python3 resource.setrlimit strange behaviour under macOS

2022-01-08 Thread Thomas Klausner


Change by Thomas Klausner :


--
nosy: +wiz
nosy_count: 8.0 -> 9.0
pull_requests: +28694
pull_request: https://github.com/python/cpython/pull/30490

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +barry

___
Python tracker 

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



[issue46309] Task created by StreamReaderProtocol gets garbage collected.

2022-01-08 Thread Simon Wrede


Change by Simon Wrede :


--
type:  -> behavior

___
Python tracker 

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



[issue46309] Task created by StreamReaderProtocol gets garbage collected.

2022-01-08 Thread Simon Wrede


New submission from Simon Wrede :

Documentation states that a reference must be kept when creating a task, 
https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task.

This is not done in StreamReaderProtocol, 
https://github.com/python/cpython/blob/main/Lib/asyncio/streams.py#L244.

I've provided a simple example to force garbage collection of this task which 
results in `Task was destroyed but it is pending!`. Uncommenting the commented 
code of the example shows that the task is not destroyed when a reference is 
kept.

Am I missing something or using the library incorrectly? I've followed the 
examples at 
https://docs.python.org/3/library/asyncio-stream.html#tcp-echo-server-using-streams.

--
components: asyncio
files: example.py
messages: 410124
nosy: asvetlov, simwr872, yselivanov
priority: normal
severity: normal
status: open
title: Task created by StreamReaderProtocol gets garbage collected.
versions: Python 3.10
Added file: https://bugs.python.org/file50552/example.py

___
Python tracker 

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



[issue46291] [doc] First argument to raise can also be BaseException

2022-01-08 Thread Vedran Čačić

Vedran Čačić  added the comment:

Let me just say that I use `raise SystemExit` all the time. Beats `from sys 
import exit`, weird error messages about having to type parentheses, and surely 
beats "oh, am I on Windows so Ctrl+Z, or on Linux so Ctrl+D". :-]

I also use `raise KeyboardInterrupt` sometimes in games, to test whether Ctrl+C 
handling works as expected at precise moments in the game (beats having to 
guess the millisecond in which to press Ctrl+C:).

--
nosy: +veky

___
Python tracker 

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



[issue46304] Unable to iterate over lines in a file without a block of code

2022-01-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

I can't believe I missed that, Jason. I even read it twice!

I think this could go in pathlib, along with read_text. Maybe read_lines, or 
iter_lines, or something. Of course PEP 533 is needed, too.

--

___
Python tracker 

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



Re: Extracting dataframe column with multiple conditions on row values

2022-01-08 Thread Avi Gross via Python-list

I have to wonder if when something looks like HOMEWORK, if it should be 
answered in detail, let alone using methods beyond what is expected in class.
The goal of this particular project seems to be to find one (or perhaps more) 
columns in some data structure like a dataframe that match two conditions 
(containing a copy of two numbers in one or more places) and then KNOW what 
column it was in. The reason I say that is because the next fairly nonsensical 
request is to then explicitly return what that column has in the row called 2, 
meaning the third row.
Perhaps stated another way: "what it the item in row/address 2 of the column 
that somewhere contains two additional specified contents called key1 and key2" 
My guess is that if the instructor wanted this to be solved using methods being 
taught, then loops may well be a way to go. Python and numpy/pandas make it 
often easier to do things with columns rather than in rows across them, albeit 
many things allow you to specify an axis. So, yes, transposing is a way to go 
that transforms the problem in a way easier to solve without thinking deeply. 
Some other languages allow relatively easy access in both directions of 
horizontally versus vertically. And this may be an example where solving it as 
a list of lists may also be easier. 
Is the solution at the bottom a solution? Before I check, I want to see if I 
understand the required functionality and ask if it is completely and 
unambiguously specified. 
For completeness, the question being asked may need to deal with a uniqueness 
issue. Is it possible multiple columns match the request and thus more than one 
answer is required to be returned? Is the row called 2 allowed to participate 
in the match or must it be excluded and the question becomes to find one (or 
more) columns that contain key1 somewhere else than row 2 and key2 (which may 
have to be different than key1 or not) somewhere else and THEN provide the 
corresponding entry from row 2 and that (or those) column(s)?
So in looking at the solution offered, what exactly was this supposed to do 
when dft is the transpose?
idt = (dft[0] == 1) & (dft[1] == 5)
Was the code (way below in this message) tried out or just written for us to 
ponder? I tried it. I got an answer of:     0 1 2
    V2  1  5  6
That is not my understanding of what was requested. Row 2 (shown transposed as 
a column) is being shown as a whole. The request was for item "2" which would 
be just 6. Something more like this:
print(dft[idt][2])

But the code makes no sense to me.  seems to explicitly test the first column 
(0) to see if it contains a 1 and then the second column (1) to see if it 
contains a 5. Not sure who cares about this hard-wired query as this is not my 
understanding of the question. You want any of the original three rows (now 
transposed)  tested to see if it contains BOTH. 
I may have read the requirements wrong or it may not be explained well. Until I 
am sure what is being asked and whether there is a good reason someone wants a 
different solution, I see no reason to provide yet another solution.But just 
for fund, assuming dft contains the transpose of the original data, will this 
work?
first = dft[dft.values == key1 ]second = first[first.values == key2 
]print(second[2])
I get a 6 as an answer and suppose it could be done in one more complex 
expression if needed! LOL!
-Original Message-
From: Edmondo Giovannozzi 
To: python-list@python.org
Sent: Sat, Jan 8, 2022 8:00 am
Subject: Re: Extracting dataframe column with multiple conditions on row values

Il giorno sabato 8 gennaio 2022 alle 02:21:40 UTC+1 dn ha scritto:
> Salaam Mahmood,
> On 08/01/2022 12.07, Mahmood Naderan via Python-list wrote: 
> > I have a csv file like this 
> > V0,V1,V2,V3 
> > 4,1,1,1 
> > 6,4,5,2 
> > 2,3,6,7 
> > 
> > And I want to search two rows for a match and find the column. For 
> > example, I want to search row[0] for 1 and row[1] for 5. The corresponding 
> > column is V2 (which is the third column). Then I want to return the value 
> > at row[2] and the found column. The result should be 6 then.
> Not quite: isn't the "found column" also required?
> > I can manually extract the specified rows (with index 0 and 1 which are 
> > fixed) and manually iterate over them like arrays to find a match. Then I
> Perhaps this idea has been influenced by a similar solution in another 
> programming language. May I suggest that the better-answer you seek lies 
> in using Python idioms (as well as Python's tools)...
> > key1 = 1 
> > key2 = 5
> Fine, so far - excepting that this 'problem' is likely to be a small 
> part of some larger system. Accordingly, consider writing it as a 
> function. In which case, these two "keys" will become 
> function-parameters (and the two 'results' become return-values).
> > row1 = df.iloc[0] # row=[4,1,1,1] 
> > row2 = df.iloc[1] # row=[6,4,5,2]
> This is likely not native-Python. Let's create lists for 'everything', 
> just-because: 
> 

[issue46308] Unportable test(1) operator in configure script

2022-01-08 Thread Thomas Klausner


Change by Thomas Klausner :


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

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread Jackson Brummell


Jackson Brummell  added the comment:

Have updated the PR to be in line with the issues leading ideas, specifically 
Tal's suggestion.

Thanks

--

___
Python tracker 

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



[issue46308] Unportable test(1) operator in configure script

2022-01-08 Thread Thomas Klausner


New submission from Thomas Klausner :

The configure script uses the test(1) '==' operator, which is only supported by 
bash. The standard comparison operator is '='.

--
components: Installation
messages: 410120
nosy: wiz
priority: normal
severity: normal
status: open
title: Unportable test(1) operator in configure script
type: compile error
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



[issue46110] compile("-"*3000000 + "4", '', mode) causes hard crash

2022-01-08 Thread Guido van Rossum


Guido van Rossum  added the comment:

To close the loop, setuptools 60.4.0 should fix this, see 
https://github.com/pypa/setuptools/pull/3009.

--

___
Python tracker 

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



[issue46249] [sqlite3] lastrowid improvements

2022-01-08 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
title: [sqlite3] move set lastrowid out of the query loop and enable it for 
executemany() -> [sqlite3] lastrowid improvements

___
Python tracker 

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



[issue46304] Unable to iterate over lines in a file without a block of code

2022-01-08 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Nice reference. Indeed, the 
[rationale](https://www.python.org/dev/peps/pep-0533/#id15) of that pep gives a 
similar example and the 
[background](https://www.python.org/dev/peps/pep-0533/#id3) describes the 
problem with the solution I've drafted above (it still depends on garbage 
collection to close the file).

I guess that means that in general, it's not possible to accomplish what I'd 
like.

As author of the PEP, I'm looping in njs.

--
nosy: +njs

___
Python tracker 

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



[issue46249] [sqlite3] move set lastrowid out of the query loop and enable it for executemany()

2022-01-08 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +28692
pull_request: https://github.com/python/cpython/pull/30489

___
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-08 Thread Peter J. Holzer
On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote:
> I have started a newspaper (not newsletter) focused
> on interesting reads on Python mailing lists. Don't tag
> on the fact that holiday seasons are the worst times for
> launch according to marketing folks, I started this to note
> down interesting mails. This might also be a great way to
> bring mailing list gems to a wider readership. So, here's
> the url https://pyherald.com/

Something like [LWN](https://lwn.net/) for Python? Neat.

Two suggestions: 

1. Could you add an RSS or Atom feed?

2. CSS «word-break: break-all» seems like a really weird choice for
   English language text. If you really want to break words across
   lines, use «hyphens: auto».

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46249] [sqlite3] move set lastrowid out of the query loop and enable it for executemany()

2022-01-08 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

I see now that GH-30380 has grown a little bit out of scope, as it changes too 
many things at once:

1. Simplify the `execute()`/`executemany()` query loop
2. Create the lastrowid PyObject on demand, simplifying cursor GC
3. `lastrowid` is now available for all `execute*()` methods
4. The default value of `lastrowid` is now `0`

It will be easier to reason about and review each change separately.

--

___
Python tracker 

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



[issue46249] [sqlite3] move set lastrowid out of the query loop and enable it for executemany()

2022-01-08 Thread Erlend E. Aasland

Erlend E. Aasland  added the comment:

Marc-André: since Python 3.6, the sqlite3.Cursor.lastrowid attribute does no 
longer comply with the recommendations of PEP 249:

Previously, lastrowid was set to None for operations other than INSERT or 
REPLACE. This changed with ab994ed8b97e1b0dac151ec827c857f5e7277565 (in Python 
3.6), so that lastrowid is _unchanged_ for operations other than INSERT or 
REPLACE, and it is set to 0 after the first valid SQL (that is not 
INSERT/REPLACE) is executed on the cursor.

Now, PEP 249 only _recommends_ that lastrowid is set to None for operations 
that do not modify a row, so it's probably not a big deal. No-one has ever 
mentioned this change in behaviour; there have been no bug reports.

FTR, here is the relevant quote from PEP 249:

If the operation does not set a rowid or if the database does not support
rowids, this attribute should be set to None.

(I interpret "should" as understood by RFC 2119.)

So, my follow-up question becomes:
I see no point in reverting to pre Python 3.6 behaviour. I would rather change 
the default value to be 0 (to get rid of the dirty flag in GH-30380), and to 
make the behaviour more consistent with how the actual SQLite API behaves.


Do you have an opinion about such a change (in behaviour)?

--

___
Python tracker 

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



[issue46304] Unable to iterate over lines in a file without a block of code

2022-01-08 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I think this might require something like PEP 533 in order to be safe.

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46304] Unable to iterate over lines in a file without a block of code

2022-01-08 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Hi Eric. I did mention that option in my report, but that option requires 
loading the whole file into memory. I'd like something equivalent to the 
iterator that `open()` provides, which yields lines lazily.

Serihy, thanks for the feedback. I do indeed not want to rely on the implicit 
closing of the file handle. I'd instead like a helper function/method that will 
close the file after the iterator is consumed.

Something like:

def read_lines(path):
with path.open() as strm:
yield from strm

What I'm seeking is for that block to be placed somewhere in the stdlib so that 
I don't have to copy it into every project that needs/wants this behavior.

--
type:  -> enhancement

___
Python tracker 

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



[issue46306] Suspicious operation in `doctest.py`: `None - 1`

2022-01-08 Thread Eric V. Smith


Change by Eric V. Smith :


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



[issue46306] Suspicious operation in `doctest.py`: `None - 1`

2022-01-08 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset 0fc58c1e051026baff4919d8519ce2aabe3b2ba1 by Nikita Sobolev in 
branch 'main':
bpo-46306: simplify `CodeType` attribute access in `doctest.py` (GH-30481)
https://github.com/python/cpython/commit/0fc58c1e051026baff4919d8519ce2aabe3b2ba1


--
nosy: +eric.smith

___
Python tracker 

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



[issue46307] string.Template should allow inspection of identifiers

2022-01-08 Thread Ben Kehoe


New submission from Ben Kehoe :

Currently, the only thing that can be done with a string.Template instance and 
a mapping is either attempt to substitute with substitute() and catch a 
KeyError if some identifier has not been provided in the mapping, or substitute 
with safe_substitute() and not know whether all identifiers were provided.

I propose adding a method that returns the identifiers in the template. Because 
the template string and pattern are exposed, this is already possible as a 
separate function:

def get_identifiers(template):
return list(
set(
filter(
lambda v: v is not None,
(mo.group('named') or mo.group('braced') 
 for mo in template.pattern.finditer(template.template))
)
)
)

However, this function is not easy for a user of string.Template to construct 
without learning how the template pattern works (which is documented but 
intended to be learned only when subclassing or modifying id patterns).

As a method on string.Template, this would enable use cases like more 
comprehensive error handling (e.g., finding all missing mapping keys at once) 
or interactive prompting.

--
components: Library (Lib)
messages: 410112
nosy: ben11kehoe
priority: normal
severity: normal
status: open
title: string.Template should allow inspection of identifiers
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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Tal Einat


Change by Tal Einat :


--
stage: patch review -> resolved

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:

Thanks for this, Erlend!

--
stage: resolved -> patch review

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:


New changeset b29aa71090e4dd34900660ecca8bb62667440f41 by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-46261: Update `sqlite3.Cursor.lastrowid` docs (GH-30407)
https://github.com/python/cpython/commit/b29aa71090e4dd34900660ecca8bb62667440f41


--

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:


New changeset 987fba102e909229dd2aa1a6115aa28d514c1818 by Miss Islington (bot) 
in branch '3.10':
bpo-46261: Update `sqlite3.Cursor.lastrowid` docs (GH-30407)
https://github.com/python/cpython/commit/987fba102e909229dd2aa1a6115aa28d514c1818


--

___
Python tracker 

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



[issue46141] Fix ipaddress.ip_network TypeErrors

2022-01-08 Thread Tal Einat


Change by Tal Einat :


--
nosy: +pmoody, taleinat
stage:  -> patch review
status: pending -> open
versions:  -Python 3.8

___
Python tracker 

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



[issue46301] Enum tests: One branch is not covered in `Enum._convert_`

2022-01-08 Thread Ethan Furman


Change by Ethan Furman :


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



[issue46301] Enum tests: One branch is not covered in `Enum._convert_`

2022-01-08 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 8d59d2563b914b7208779834895c080c70cd94dd by Nikita Sobolev in 
branch 'main':
bpo-46301: [Enum] test uncomparable values in `_convert_` (GH-30472)
https://github.com/python/cpython/commit/8d59d2563b914b7208779834895c080c70cd94dd


--

___
Python tracker 

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



[issue46285] http/server.py wont respect its protocol_version

2022-01-08 Thread Hugo Almeida


Hugo Almeida  added the comment:

The short story is, everything is okay,
its my bad to taken the test function out of context,
sorry about that of issue report.

# just for details review (related file attached):
#
# check line 1277 to line 1278 (main branch of Python currently):
# https://github.com/python/cpython/blob/17b16e1/Lib/http/server.py#L1277-L1278
#
# thus, `functools.partial` (closure/wrapper) will
# make the parameter `protocol` of the function `test` useless.
# So, specify a handler class directly.

--
resolution: remind -> not a bug
stage:  -> resolved
status: open -> closed
Added file: https://bugs.python.org/file50551/my_http.py

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:


New changeset b6aa38f1ca79600f2ab46ac114ff36461a19c4a3 by Erlend Egeberg 
Aasland in branch 'main':
bpo-46261: Update `sqlite3.Cursor.lastrowid` docs (GH-30407)
https://github.com/python/cpython/commit/b6aa38f1ca79600f2ab46ac114ff36461a19c4a3


--
nosy: +taleinat

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28691
pull_request: https://github.com/python/cpython/pull/30488

___
Python tracker 

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



[issue46261] [doc] fix inaccuracies in sqlite3.Cursor.lastrowid docs

2022-01-08 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue46305] SyntaxError when using dict key in fstring

2022-01-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

Yes, the behavior is intentional. It might be relaxed in the future.

--
nosy: +eric.smith

___
Python tracker 

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



Re: Extracting dataframe column with multiple conditions on row values

2022-01-08 Thread Edmondo Giovannozzi
Il giorno sabato 8 gennaio 2022 alle 02:21:40 UTC+1 dn ha scritto:
> Salaam Mahmood,
> On 08/01/2022 12.07, Mahmood Naderan via Python-list wrote: 
> > I have a csv file like this 
> > V0,V1,V2,V3 
> > 4,1,1,1 
> > 6,4,5,2 
> > 2,3,6,7 
> > 
> > And I want to search two rows for a match and find the column. For 
> > example, I want to search row[0] for 1 and row[1] for 5. The corresponding 
> > column is V2 (which is the third column). Then I want to return the value 
> > at row[2] and the found column. The result should be 6 then.
> Not quite: isn't the "found column" also required?
> > I can manually extract the specified rows (with index 0 and 1 which are 
> > fixed) and manually iterate over them like arrays to find a match. Then I
> Perhaps this idea has been influenced by a similar solution in another 
> programming language. May I suggest that the better-answer you seek lies 
> in using Python idioms (as well as Python's tools)...
> > key1 = 1 
> > key2 = 5
> Fine, so far - excepting that this 'problem' is likely to be a small 
> part of some larger system. Accordingly, consider writing it as a 
> function. In which case, these two "keys" will become 
> function-parameters (and the two 'results' become return-values).
> > row1 = df.iloc[0] # row=[4,1,1,1] 
> > row2 = df.iloc[1] # row=[6,4,5,2]
> This is likely not native-Python. Let's create lists for 'everything', 
> just-because: 
> 
> >>> headings = [ "V0","V1","V2","V3" ] 
> >>> row1 = [4,1,1,1] 
> >>> row2 = [6,4,5,2] 
> >>> results = [ 2,3,6,7 ] 
> 
> 
> Note how I'm using the Python REPL (in a "terminal", type "python" (as 
> appropriate to your OpSys) at the command-line). IMHO the REPL is a 
> grossly under-rated tool, and is a very good means towards 
> trial-and-error, and learning by example. Highly recommended! 
> 
> 
> > for i in range(len(row1)): 
> 
> This construction is very much a "code smell" for thinking that it is 
> not "pythonic". (and perhaps the motivation for this post) 
> 
> In Python (compared with many other languages) the "for" loop should 
> actually be pronounced "for-each". In other words when we pair the 
> code-construct with a list (for example): 
> 
> for each item in the list the computer should perform some suite of 
> commands. 
> 
> (the "suite" is everything 'inside' the for-each-loop - NB my 
> 'Python-betters' will quickly point-out that this feature is not limited 
> to Python-lists, but will work with any :iterable" - ref: 
> https://docs.python.org/3/tutorial/controlflow.html#for-statements) 
> 
> 
> Thus: 
> 
> > for item in headings: print( item ) 
> ... 
> V0 
> V1 
> V2 
> V3 
> 
> 
> The problem is that when working with matrices/matrixes, a math 
> background equips one with the idea of indices/indexes, eg the 
> ubiquitous subscript-i. Accordingly, when reading 'math' where a formula 
> uses the upper-case Greek "sigma" character, remember that it means "for 
> all" or "for each"! 
> 
> So, if Python doesn't use indexing or "pointers", how do we deal with 
> the problem? 
> 
> Unfortunately, at first glance, the pythonic approach may seem 
> more-complicated or even somewhat convoluted, but once the concepts 
> (and/or the Python idioms) are learned, it is quite manageable (and 
> applicable to many more applications than matrices/matrixes!)...
> > if row1[i] == key1: 
> > for j in range(len(row2)): 
> > if row2[j] == key2: 
> > res = df.iloc[:,j] 
> > print(res) # 6 
> > 
> > Is there any way to use built-in function for a more efficient code?
> This is where your idea bears fruit! 
> 
> There is a Python "built-in function": zip(), which will 'join' lists. 
> NB do not become confused between zip() and zip archive/compressed files! 
> 
> Most of the time reference book and web-page examples show zip() being 
> used to zip-together two lists into a single data-construct (which is an 
> iterable(!)). However, zip() will actually zip-together multiple (more 
> than two) "iterables". As the manual says: 
> 
> «zip() returns an iterator of tuples, where the i-th tuple contains the 
> i-th element from each of the argument iterables.» 
> 
> Ah, so that's where the math-idea of subscript-i went! It has become 
> 'hidden' in Python's workings - or putting that another way: Python 
> looks after the subscripting for us (and given that 'out by one' errors 
> in pointers is a major source of coding-error in other languages, 
> thank-you very much Python!) 
> 
> First re-state the source-data as Python lists, (per above) - except 
> that I recommend the names be better-chosen to be more meaningful (to 
> your application)! 
> 
> 
> Now, (in the REPL) try using zip(): 
> 
> >>> zip( headings, row1, row2, results ) 
>  
> 
> Does that seem a very good illustration? Not really, but re-read the 
> quotation from the manual (above) where it says that zip returns an 
> iterator. If we want to see the values an iterator will produce, then 
> turn it into an iterable data-structure, eg: 
> 
> >>> list( zip( 

RE: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-08 Thread Kirill Ratkin

Hi.
You probably can solve issue on Gunicorn side. But afaik better solution is to 
use http proxy before Gunicorn. This proxy accepts https connection and proxy 
requests to Gunicorn instances as plain http.

This approach gives you:
a) Monitoring on network layer (tcpdump/wireshark shows you req/res on Gunicorn 
instance)
b) Scalability (proxy can spread traffic on several Gunicorn instances)
c) Maintenance (you can gracefully shutdown/restart Gunicorn instances one by 
one) 
d) Security (For example SSL certificate is configured in proxy only. There are 
another useful features which such proxy can do: simple authentication, 
ddos/fail2ban and so on)

Quite often NGINX is better choice for such proxy. But apache is good as well.

Best regards.
Kirill

От: Skip Montanaro
Отправлено: 7 января 2022 г. в 21:54
Кому: Python
Тема: Gunicorn - HTTP and HTTPS in the same instance?

Hopefully some Pythonistas are also Gunicornistas. I've had little success
finding help with a small dilemma in the docs or in other more specific
sources.

I'm testing out a new, small website. It is just Gunicorn+Flask. I'd like
to both listen for HTTP and HTTPS connections. Accordingly, in my config, I
have the Gunicorn process bind to both ports 80 and 443 if running as root:

if IAM_ROOT:
bind = [
'0.0.0.0:443',
'0.0.0.0:80',
]
else:
bind = [
'0.0.0.0:8080',
]

Gunicorn listens on both ports, but insists on SSL/TLS chit chat over port
80, not just port 443 (which seems to work okay). Is there some magic
incantation to get it to just talk HTTP on port 80, or will I need to spin
up two instances? (The non-root config works fine - plain old HTTP over
port 8080.)

Thx,

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

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


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

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the suggestion and the PR, Giacomo!

However, in my opinion, this is better suited to be something like a cookbook 
recipe.  The number of use cases for this will be low, and there would be 
little advantage to having this in the stdlib rather than elsewhere.

--
nosy: +taleinat

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:

Good to know Eric, will do!

--

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks for committing this, @taleinat. But next time, if it's assigned to me, 
I'd like to review it first. Thanks!

--

___
Python tracker 

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



Re: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-08 Thread Skip Montanaro
Thanks all. I was hoping to get away without something more
sophisticated like NGINX. This is just a piddly little archive of an
old mailing list running on a single-core Ubuntu VM somewhere on the
East Coast. Speed is not a real requirement. Load balancing seemed
like overkill to me. Still, I guess if it has to be, then it has to
be.

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


[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the report and the PR, Zsolt!

--
nosy:  -miss-islington
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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread miss-islington


miss-islington  added the comment:


New changeset cd95033d9c27d6c541dfd774b4c5eab4a70a23ab by Miss Islington (bot) 
in branch '3.9':
bpo-46290: Fix parameter names in dataclasses docs (GH-30450)
https://github.com/python/cpython/commit/cd95033d9c27d6c541dfd774b4c5eab4a70a23ab


--

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread miss-islington


miss-islington  added the comment:


New changeset 8bef658668bac923166ae160c79720aed5f3b712 by Miss Islington (bot) 
in branch '3.10':
bpo-46290: Fix parameter names in dataclasses docs (GH-30450)
https://github.com/python/cpython/commit/8bef658668bac923166ae160c79720aed5f3b712


--

___
Python tracker 

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



Re: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-08 Thread Albert-Jan Roskam
   I always use NGINX for this. Run Flask/Gunicorn on localhost:5000 and have
   NGINX rewrite https requests to localhost requests. In nginx.conf I
   automatically redirect every http request to https. Static files are
   served by NGINX, not by Gunicorn, which is faster. NGINX also allows you
   to easily set the transfer encoding to gzip
   Albert-Jan
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46227] add pathlib.Path.walk method

2022-01-08 Thread Stanislav Zmiev


Stanislav Zmiev  added the comment:

Thanks for the tip! Hopefully, I created it correctly:
https://discuss.python.org/t/add-pathlib-path-walk-method/

It is currently on review.

--

___
Python tracker 

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



[issue45925] Upgrade macOS and Windows installers to use SQLite 3.37.2

2022-01-08 Thread Kumar Aditya


Change by Kumar Aditya :


--
keywords: +patch
nosy: +kumaraditya303
nosy_count: 7.0 -> 8.0
pull_requests: +28689
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30485

___
Python tracker 

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



[issue40479] Port _hashlib to OpenSSL 3.0.0

2022-01-08 Thread Christian Heimes


Christian Heimes  added the comment:

Simple benchmark with openssl-3.0.0-5.el9.x86_64

With custom EVP_MD cache:
$ ./python -m timeit -s "from hashlib import md5" "md5(b'12345678', 
usedforsecurity=False).digest()"50 loops, best of 5: 520 nsec per loop
$ ./python -m timeit -s "from hashlib import sha512" "sha512(b'12345678', 
usedforsecurity=False).digest()"
50 loops, best of 5: 730 nsec per loop

Without EVP_MD cache:
$ ./python -m timeit -s "from hashlib import md5" "md5(b'', 
usedforsecurity=False).digest()"
50 loops, best of 5: 807 nsec per loop
$ ./python -m timeit -s "from hashlib import sha512" "sha512(b'12345678', 
usedforsecurity=False).digest()"
20 loops, best of 5: 1.03 usec per loop

--

___
Python tracker 

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



[issue46302] IndexError inside list comprehension + workaround

2022-01-08 Thread Pierre Fortin


Pierre Fortin  added the comment:

[Thanks for the replies! I was trying to post this before seeing them.]

Major egg on face...
The more complex the code becomes, the more likely you will be burned by a 
rookie mistake...
var = ''
var[0]  WILL give IndexError  -- Duh!
It was buried in the each.split('=') returning an empty string -- that's what 
you get for making things easier for the user. 
The easier code is to use, the more complex it must be...

Sorry for the noise.

--

___
Python tracker 

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



[issue46006] [subinterpreter] _PyUnicode_EqualToASCIIId() issue with subinterpreters

2022-01-08 Thread STINNER Victor


Change by STINNER Victor :


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



[issue46303] _Py_stat and _Py_wstat using incorrect type for status argument

2022-01-08 Thread STINNER Victor


STINNER Victor  added the comment:

It's not the first time that private functions included by the public Python.h 
are causing build errors event if these functions are not used. The previous 
issue were functions for atomic operations. I solved this build error by moving 
the whole private C API into the internal C API: 
Include/internal/pycore_atomic.h. Since that time, we no longer got build error 
related to this header file.

I propose a similar fix: move all private fileutils.h functions from 
Include/cpython/fileutils.h to the internal Include/internal/pycore_fileutils.h.

I wrote PR 30484 to implement this change.

To keep the implementation simple, I kept _Py_fopen_obj() in 
Include/cpython/fileutils.h, for _testcapi which must not use the internal C 
API.

If this PR is merged, for Python 3.9 and 3.10, I will write a simpler change: 
modify Include/cpython/fileutils.h to only define functions using "struct stat" 
in the internal C API (if Py_BUILD_CORE is defined).

--

___
Python tracker 

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



[issue46303] _Py_stat and _Py_wstat using incorrect type for status argument

2022-01-08 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +28688
pull_request: https://github.com/python/cpython/pull/30484

___
Python tracker 

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



[issue46306] Suspicious operation in `doctest.py`: `None - 1`

2022-01-08 Thread Alex Waygood


Change by Alex Waygood :


--
title: Suspicios operation in `doctest.py`: `None - 1` -> Suspicious operation 
in `doctest.py`: `None - 1`

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +28686
pull_request: https://github.com/python/cpython/pull/30482

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +28687
pull_request: https://github.com/python/cpython/pull/30483

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:


New changeset ef5376e69e72fa922d7f1b3df47b99d3576f9df1 by Zsolt Dollenstein in 
branch 'main':
bpo-46290: Fix parameter names in dataclasses docs (GH-30450)
https://github.com/python/cpython/commit/ef5376e69e72fa922d7f1b3df47b99d3576f9df1


--

___
Python tracker 

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



[issue46306] Suspicios operation in `doctest.py`: `None - 1`

2022-01-08 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread FeRD (Frank Dana)

FeRD (Frank Dana)  added the comment:

Maybe,

"""
This won’t work for __main__.py files in the root directory of a .zip file 
though. Thus, for consistency, it is usually preferred to place code in other 
modules. That code can then be invoked from a minimal ``__main__.py``.
"""

(And then the see-also opens, "See venv for an example of a package with a 
minimal __main__.py in the standard library." which is a natural extension of 
the discussion.)

@taleinat's suggestion works as well (crossed streams).

--
nosy:  -taleinat

___
Python tracker 

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



[issue46306] Suspicios operation in `doctest.py`: `None - 1`

2022-01-08 Thread Nikita Sobolev

New submission from Nikita Sobolev :

This line `lineno = getattr(obj, 'co_firstlineno', None)-1` does not look good. 
Link: 
https://github.com/python/cpython/blame/45d44b950f1dab0ef90d0a8f4fa75ffaae71500b/Lib/doctest.py#L1116

Why? 
1. `CodeType` is guaranteed to have `co_firstlineno`. Docs: 
https://github.com/python/cpython/blob/45d44b950f1dab0ef90d0a8f4fa75ffaae71500b/Lib/inspect.py#L487
2. Even if it does not have it for some reason, this `getattr` does not help. 
It raises unhandled `TypeError`. We can simulate it by replacing `lineno = 
getattr(obj, 'co_firstlineno', None)-1` with `lineno = None-1`

Here's what happens in this case:

```
» ./python.exe -m test -v test_doctest
== CPython 3.11.0a3+ (heads/issue-26767:45d44b950f, Jan 8 2022, 12:23:45) 
[Clang 11.0.0 (clang-1100.0.33.16)]
== Darwin-18.7.0-x86_64-i386-64bit little-endian
== cwd: /Users/sobolev/Desktop/cpython/build/test_python_78065æ
== CPU count: 4
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 3.51 Run tests sequentially
0:00:00 load avg: 3.51 [1/1] test_doctest
Failed to call load_tests:
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/unittest/loader.py", line 108, in 
loadTestsFromModule
return load_tests(self, tests, pattern)
   
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_doctest.py", line 3134, in 
load_tests
tests.addTest(doctest.DocTestSuite(doctest))
  ^
  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 2391, in 
DocTestSuite
tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)

  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 940, in find
self._find(tests, obj, name, module, source_lines, globs, {})
^
  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1013, in _find
self._find(tests, val, valname, module, source_lines,
^
  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1001, in _find
test = self._get_test(obj, name, module, globs, source_lines)
   ^^
  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1069, in _get_test
lineno = self._find_lineno(obj, source_lines)
 
  File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1117, in 
_find_lineno
None - 1
~^~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

test test_doctest crashed -- Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/runtest.py", line 
352, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
  ^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/runtest.py", line 
309, in _runtest_inner2
test_runner()
^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/runtest.py", line 
272, in _test_module
raise Exception("errors while loading tests")
^
Exception: errors while loading tests

test_doctest failed (uncaught exception)

== Tests result: FAILURE ==

1 test failed:
test_doctest

Total duration: 1.0 sec
Tests result: FAILURE
```

So, we have two options:
1. Think of a case when `CodeType` does not have `co_firstlineno` and handle it 
properly, like using `0` or `None` as `lineno`
2. Simplify this line to remove potential `TypeError`

I think that this line should be rewritten as `lineno = obj.co_firstlineno - 1`

I will send a PR for others to judge.

--
components: Library (Lib)
messages: 410092
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Suspicios operation in `doctest.py`: `None - 1`
type: behavior
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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread Tal Einat

Tal Einat  added the comment:

I agree that it seems better to avoid menntioning venv in that sentence. 
Specifically I suggest:

This won’t work for __main__.py files in the root directory of a .zip file 
though. Hence, for consistency, minimal __main__.py without a __name__ check 
are preferred.

--
nosy: +taleinat

___
Python tracker 

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



[issue46242] Improve error message when attempting to extend an enum with `__call__`

2022-01-08 Thread Alex Waygood


Change by Alex Waygood :


--
assignee:  -> ethan.furman

___
Python tracker 

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



[issue46303] _Py_stat and _Py_wstat using incorrect type for status argument

2022-01-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner

___
Python tracker 

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



[issue46304] Unable to iterate over lines in a file without a block of code

2022-01-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

A warning is an indication of possible bugs in your code. If you do not close 
file explicitly, and it is closed by the garbage collector, the time of closing 
is undeterminated. This can lead to exhausting of file descriptors if you have 
a lot of opened files waiting for closing in reference loops.

If you want to get rid of warnings, use a corresponding warning filter for 
ignoring specific warnings. Or better rewrite your code in a way that file 
closing is deterministic.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46290] Parameter names are inaccurate in dataclasses docs

2022-01-08 Thread Tal Einat


Tal Einat  added the comment:

Indeed, the argument name in the code is "obj", and in 3 of those 4 functions 
it is a normal (positional or keyword) argument, so the name is important.

--
assignee: eric.smith -> taleinat
nosy: +taleinat

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread FeRD (Frank Dana)

FeRD (Frank Dana)  added the comment:

TBH, personally I don't think I'd just reword it with "below". That seems like 
the path of least resistance, but then the sentence becomes this:

"""
This won’t work for __main__.py files in the root directory of a .zip file 
though. Hence, for consistency, minimal __main__.py like the venv one mentioned 
below are preferred.
"""

Doesn't really track. How can you draw conclusions ("Hence...") from something 
that hasn't even been discussed yet?

It might actually be better to just drop the mention of venv from that 
particular sentence. The see-also text introduces *itself* as an example of 
what was just discussed. There's no real reason to bring it up ahead of time, 
because the see-also already flows naturally from the previous discussion 
without any setup.

--

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread Jackson Brummell


Jackson Brummell  added the comment:

Updating issue, Have submitted fix

--

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread Jackson Brummell


Change by Jackson Brummell :


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

___
Python tracker 

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



[issue46279] [docs] Minor information-ordering issue in __main__ doc

2022-01-08 Thread Jackson Brummell


Jackson Brummell  added the comment:

It seems this is a simple miswording, where the word 'above' is used when the 
see below example clarifies BELOW the text.

I will create a pull request within the hour

--
nosy: +jacksonbrummell1

___
Python tracker 

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



[issue46305] SyntaxError when using dict key in fstring

2022-01-08 Thread Samisafool


Samisafool  added the comment:

Huh, it does seem to be intentional.

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



[issue46223] asyncio cause infinite loop during debug

2022-01-08 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Just to clarify.

What do you mean by "When running code in debug mode"?
Do you use some debugger like `pdb` or pycharm?

--
nosy: +sobolevn

___
Python tracker 

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



[issue46305] SyntaxError when using dict key in fstring

2022-01-08 Thread Samisafool


Samisafool  added the comment:

Is that intended behaviour? It works though.

--

___
Python tracker 

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



[issue46305] SyntaxError when using dict key in fstring

2022-01-08 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Can you please try this:

```
dict1 = {
"key1": "test"
}

print(dict1["key1"])

print(f"key1 is {dict1['key1']}!")
```

The problem with your code is that `dict1["key1"]` used the same quotes as 
`f""`.

--
nosy: +sobolevn

___
Python tracker 

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



[issue46299] Improve several exception handling practices in `test_descr.py`

2022-01-08 Thread Dong-hee Na


Change by Dong-hee Na :


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



[issue46299] Improve several exception handling practices in `test_descr.py`

2022-01-08 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset 45d44b950f1dab0ef90d0a8f4fa75ffaae71500b by Dong-hee Na in branch 
'main':
bpo-46299: Improve test_descr (GH-30475)
https://github.com/python/cpython/commit/45d44b950f1dab0ef90d0a8f4fa75ffaae71500b


--

___
Python tracker 

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