[issue44524] __name__ attribute in typing module

2021-08-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26325
pull_request: https://github.com/python/cpython/pull/27871

___
Python tracker 

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



[issue44524] __name__ attribute in typing module

2021-08-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 4ceec495598e78f0776dd46d511dcc612a434dc3 by Serhiy Storchaka in 
branch 'main':
bpo-44524: Do not set _name of _SpecialForm without need (GH-27861)
https://github.com/python/cpython/commit/4ceec495598e78f0776dd46d511dcc612a434dc3


--

___
Python tracker 

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



[issue44968] Fix/remove test_subprocess_wait_no_same_group from test_asyncio tests

2021-08-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
components: +asyncio
type:  -> behavior
versions:  -Python 3.8

___
Python tracker 

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



[issue44968] Fix/remove test_subprocess_wait_no_same_group from test_asyncio tests

2021-08-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
nosy: +serhiy.storchaka
nosy_count: 7.0 -> 8.0
pull_requests: +26324
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27870

___
Python tracker 

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



[issue44968] Fix/remove test_subprocess_wait_no_same_group from test_asyncio tests

2021-08-20 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
nosy: +andrei.avk

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Ryan Mast (nightlark)


Ryan Mast (nightlark)  added the comment:

The new issue for the failing test is bpo-44968

--

___
Python tracker 

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



[issue44968] Fix/remove test_subprocess_wait_no_same_group from test_asyncio tests

2021-08-20 Thread Ryan Mast (nightlark)


New submission from Ryan Mast (nightlark) :

A deprecation made in bpo-41322 uncovered issues with 
test_subprocess_wait_no_same_group in test_asyncio that seems to have been 
broken for some time.

Reverting to a similar structure prior to the refactoring in 
https://github.com/python/cpython/commit/658103f84ea860888f8dab9615281ea64fee31b9
 using async/await avoids the deprecation error, though it still might not be 
running correctly.

With the change I tried in 
https://github.com/python/cpython/commit/658103f84ea860888f8dab9615281ea64fee31b9
 there is a message about an `unknown child process`, which makes me think 
there could be some issues with the subprocess exiting prior to the refactoring 
~8 years ago.

--
components: Tests
messages: 400018
nosy: asvetlov, ezio.melotti, michael.foord, rbcollins, rmast, yselivanov
priority: normal
severity: normal
status: open
title: Fix/remove test_subprocess_wait_no_same_group from test_asyncio tests
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Ryan Mast (nightlark)


Ryan Mast (nightlark)  added the comment:

Sure, I'll open a new issue.

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

The test was refactored in this commit: 
https://github.com/python/cpython/commit/658103f84ea860888f8dab9615281ea64fee31b9

the refactoring moved yield statement from inner func into the test.

That was 8 years ago so it hasn't worked since then, and since asyncio changed 
a lot, I wonder if the test is still valid?

Ryan, do you want to open a new issue for fixing / removing the test?

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Yes, it seems like this deprecation detected a broken test that wasn't running.

If I add a `raise` statement to it and rerun the test, it still passes on my 
local system:
./python.exe -m unittest -v 
test.test_asyncio.test_events.PollEventLoopTests.test_subprocess_wait_no_same_group
  warnings.warn(f'It is deprecated to return a value!=None from a '
Ran 1 test in 0.022s

OK

(with last line of test being just `raise`).

It seems to me it should be fixed in some way although I don't know if Ryan's 
suggestion will do or not as I haven't looked at asyncio tests before..

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Ryan Mast (nightlark)


Ryan Mast (nightlark)  added the comment:

Would rewriting the test so that it doesn't yield be the right fix?

```
def test_subprocess_wait_no_same_group(self):
# start the new process in a new session
connect = self.loop.subprocess_shell(
functools.partial(MySubprocessProtocol, self.loop),
'exit 7', stdin=None, stdout=None, stderr=None,
start_new_session=True)
_, proto = yield self.loop.run_until_complete(connect)
self.assertIsInstance(proto, MySubprocessProtocol)
self.loop.run_until_complete(proto.completed)
self.assertEqual(7, proto.returncode)
```

to

```
def test_subprocess_wait_no_same_group(self):
# start the new process in a new session
connect = self.loop.subprocess_shell(
functools.partial(MySubprocessProtocol, self.loop),
'exit 7', stdin=None, stdout=None, stderr=None,
start_new_session=True)
transp, proto = self.loop.run_until_complete(connect)
self.assertIsInstance(proto, MySubprocessProtocol)
self.loop.run_until_complete(proto.completed)
self.assertEqual(7, proto.returncode)
transp.close()
```

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

That test does have a yield statement in it, and does cause the deprecation 
warning to fire off. I'm looking into it..

--

___
Python tracker 

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



[issue44967] pydoc should return non-zero exit code when a query is not found

2021-08-20 Thread Gregory Anders


Change by Gregory Anders :


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

___
Python tracker 

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



[issue44967] pydoc should return non-zero exit code when a query is not found

2021-08-20 Thread Gregory Anders


New submission from Gregory Anders :

Currently pydoc returns an exit code of zero no matter what, even with e.g.

pydoc lsjdfkdfj

However, the ability to know whether or not pydoc successfully found a result 
is useful in tools that embed pydoc in some way.

Here's one use case: Vim and Neovim have a feature that allows a user to run an 
external command for the keyword under the cursor (keywordprg). In Python 
files, this defaults to pydoc. In Neovim, we would like to automatically close 
the PTY buffers that we create for these processes when they finish without any 
errors, but if it returns a non-zero exit code we want to keep the PTY buffer 
open so the user can see what went wrong. Because pydoc returns immediately 
when it fails to find a match and does not indicate that it failed via a return 
code, the PTY buffer is closed immediately with no indication to the user that 
anything went wrong.

I have a patch prepared for this that I will link to the issue.

--
components: Demos and Tools
messages: 400012
nosy: gpanders
priority: normal
severity: normal
status: open
title: pydoc should return non-zero exit code when a query is not found
type: enhancement

___
Python tracker 

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



[issue44943] Integrate PyHyphen into the textwrap module?

2021-08-20 Thread Eric V. Smith

Eric V. Smith  added the comment:

I agree this doesn’t belong in the stdlib. For future reference, my principal 
objections are 1) the need to manage and distribute per-language dictionaries 
and 2) difficulty in determining the best algorithm for the stdlib. There are a 
lot of ways to tweak this. The community is well served with the multiple 
libraries on PyPI.

--

___
Python tracker 

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



[issue41322] unittest: deprecate test methods returning non-None values

2021-08-20 Thread Ryan Mast (nightlark)


Ryan Mast (nightlark)  added the comment:

It looks like since GH-27748 got merged, `test_subprocess_wait_no_same_group` 
in `test_asyncio` has been failing for the Ubuntu SSL tests.

--
nosy: +rmast

___
Python tracker 

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



[issue21184] statistics.pvariance with known mean does not work as expected

2021-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

See commit d71ab4f73887a6e2b380ddbbfe35b600d236fd4a for bpo-40855.

--
nosy: +rhettinger
resolution:  -> fixed
stage: needs patch -> 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



[issue44941] Add check_methods function to standard library

2021-08-20 Thread Finn Mason


Finn Mason  added the comment:

Thank you for the suggestions.

>From what I could tell, the cited python-ideas discussion was more about 
>checking the signature of a method. However, an issue cited by the ex-BDFL 
>(issue9731) was helpful. It's a similar idea that verifies that a class 
>implements an ABC. However, I'm looking at a function that simplifies writing 
>the ABC itself.

I will post the idea to python-ideas and see what people think.

--

___
Python tracker 

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



[issue44966] example code does not macth the very version(3.9)

2021-08-20 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
nosy: +rhettinger
nosy_count: 2.0 -> 3.0
pull_requests: +26322
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27867

___
Python tracker 

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



[issue44966] example code does not macth the very version(3.9)

2021-08-20 Thread 杨青

New submission from 杨青 :

【url】https://docs.python.org/3/tutorial/errors.html

【chapter】8.2. Exceptions

【origina example code】
>>> '2' + 2
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Can't convert 'int' object to str implicitly

【what i got in practice】
>>> '2' + 2
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can only concatenate str (not "int") to str

--
assignee: docs@python
components: Documentation
messages: 47
nosy: docs@python, yangqing
priority: normal
severity: normal
status: open
title: example code does not macth the very version(3.9)
type: enhancement
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



[issue39218] Assertion failure when calling statistics.variance() on a float32 Numpy array

2021-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Removing the assertion and implementing Steven's idea seems like the best way 
to go:

sum((y:=(x-c)) * y for x in data)

--

___
Python tracker 

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



[issue39827] setting a locale that uses comma as decimal separator breaks tkinter.DoubleVar

2021-08-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I wrote a longer explanation but BPO and Chrome ate it.

The issue is that DoubleVar is not locale aware. I don't know what should be 
the actual fix but the following may be a useful workaround (It works on my 
system):

import tkinter
import locale
import sys

locale.setlocale(locale.LC_NUMERIC, 'de_DE')
class Var(tkinter.DoubleVar):
def get(self):
return locale.atof(self._tk.globalgetvar(self._name))

class TestDoubleVar():
def __init__(self):
root = tkinter.Tk()
self.var = Var()
self.var.set(0.8)
number = tkinter.Spinbox(
root,
from_=0, to=1, increment=0.1,
textvariable=self.var,
command=self.update,
width=4
)
number.pack(side=tkinter.LEFT)
root.mainloop()
def update(self, *args):
print(self.var.get())
if __name__ == '__main__':
TestDoubleVar()

--
nosy: +andrei.avk

___
Python tracker 

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



[issue44963] anext_awaitable is not a collections.abc.Generator

2021-08-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +asvetlov, yselivanov

___
Python tracker 

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



[issue44943] Integrate PyHyphen into the textwrap module?

2021-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I concur with Terry.  The suggestion is nice but it belongs outside the 
standard library.

--
nosy: +rhettinger
resolution:  -> rejected
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



[issue4442] document immutable type subclassing via __new__

2021-08-20 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
nosy: +rhettinger
nosy_count: 8.0 -> 9.0
pull_requests: +26321
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/27866

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue44934] Windows installer: Append Python to PATH instead of prepending it

2021-08-20 Thread Steve Dower


Steve Dower  added the comment:

That branch looks like you're on the right track. The build scripts in 
Tools/msi should Just Work, so I'd be interested to see the error you get.

You can also submit it as a PR and the MSI will be built automatically.

One thing I noticed is updating the name of the "Add Python to PATH" 
option, which I'd rather keep as "Add" since we won't have both options 
in the UI. The word "Prepend" is quite obscure jargon, and for the range 
of users we have it isn't fair to expect them to know it (or to break 
all of the guidance out there explaining that checkbox already).

--

___
Python tracker 

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



[issue44943] Integrate PyHyphen into the textwrap module?

2021-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This strikes me as an example of the sort of thing that should not be in the 
stdlib.  'Correct' behavior is a matter of opinion and the language being 
hyphenated.  I recommend rejecting.

--
nosy: +terry.reedy
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



[issue44934] Windows installer: Append Python to PATH instead of prepending it

2021-08-20 Thread Bastian Neuburger


Bastian Neuburger  added the comment:

Previous URL got "fixed" by roundup, hopefully this one works:

https://github.com/python/cpython/compare/16b9be4861e007ad483611ba0479feb2b90ea783...bneuburg:issue44934

--

___
Python tracker 

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



[issue44934] Windows installer: Append Python to PATH instead of prepending it

2021-08-20 Thread Bastian Neuburger


Bastian Neuburger  added the comment:

Maybe this view better shows what I've actually done:

https://github.com/python/cpython/compare/16b9be4861e007ad483611ba0479feb2b90ea783...bneuburg:issue44934?expand=1

--

___
Python tracker 

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



[issue44934] Windows installer: Append Python to PATH instead of prepending it

2021-08-20 Thread Bastian Neuburger


Bastian Neuburger  added the comment:

Thanks for the rundown, after digging a little bit into the abyss that is the 
WIX toolset if you've never dealt with it before I already started going down 
that route. 

I pushed it to my fork of cpython:
https://github.com/bneuburg/cpython/commits/issue44934

Since I'm pretty sure that my commits are not correct yet (following the 
instructions in Tools/msi/README.txt regarding fetching dependencies building 
the MSI resulted in a failed build before I even touched a single line of code) 
I abstained from handing in a pull request.

Feedback would be very much appreciated. Of course if you'd want to use that 
stuff and refine it I would be totally fine with it ;)

In case I messed up any formal requirements (i.e. wording of commit messages 
etc.): I will get myself up to speed and fix that, but since I'll be offline 
for a week starting Monday I wanted to get my initial draft out there, so in 
case you have any feedback until Monday I can incorporate it before my brain 
pushes that stuff out...

--

___
Python tracker 

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



[issue44915] Python keywords as string keys in TypedDict

2021-08-20 Thread Guido van Rossum

Guido van Rossum  added the comment:

Unfortunately you can’t use Python keywords in such positions and we have no 
plans to fix this. Serhiy’s workaround is the best you can do.

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



[issue30999] statistics module: add a general selection function

2021-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

No one has shown any interest in this in a long time.  Marking is as closed  
for now.  

This issue can be reopened if there is an interest and a reasonable use case 
that can't be reasonably handled with sorted, min, or max.

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



[issue44918] Unhandled Exception (Not Implemented) in HTMLParser().feed

2021-08-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Not Implemented Error in stdLib HTMLParser

___
Python tracker 

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



[issue44915] Python keywords as string keys in TypedDict

2021-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The current behavior is not a bug, so this is an enhancement proposal.

--
nosy: +gvanrossum, terry.reedy
type: behavior -> enhancement
versions: +Python 3.11 -Python 3.8, Python 3.9

___
Python tracker 

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



[issue33084] statistics module: NaN handling in median, median_high an median_low

2021-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

[Steven]
> Thoughts?

1) Document that results are undefined if a NaN is present in the data.

2) Add function to strip NaNs from the data:

def remove_nans(iterable):
"Remove float('NaN') and other objects not equal to themselves"
return [x for x in iterable if x == x]

--
nosy: +rhettinger

___
Python tracker 

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



[issue44934] Windows installer: Append Python to PATH instead of prepending it

2021-08-20 Thread Steve Dower


Steve Dower  added the comment:

The logic is probably simplest if you clone the Tools/msi/path project entirely 
as pathappend. That will technically allow people to both prepend and append if 
they set both flags, but I think it's okay to say "don't do that", especially 
if AppendPath is only a command line option.

Per-component or optional features are complicated and best avoided if we can. 
For a simple on-off like this, a whole MSI is actually the simplest way to 
manage it.

--

___
Python tracker 

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



[issue44963] anext_awaitable is not a collections.abc.Generator

2021-08-20 Thread Thomas Grainger


Thomas Grainger  added the comment:

it also fails with asyncio.create_task

```
import asyncio

async def agen():
yield

async def main():
p = agen()
await asyncio.create_task(anext(p, 'finished'))

asyncio.run(main())
```

```
Traceback (most recent call last):
  File "/home/graingert/projects/datapraxis/analysis/foo.py", line 10, in 

asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in 
run_until_complete
return future.result()
  File "/home/graingert/projects/asyncio-demo/foo.py", line 8, in main
await asyncio.create_task(anext(p, 'finished'))
  File "/usr/lib/python3.10/asyncio/tasks.py", line 337, in create_task
task = loop.create_task(coro)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 433, in create_task
task = tasks.Task(coro, loop=self, name=name)
TypeError: a coroutine was expected, got 
```


there's also a problem with cancelling and aclosing an async gen this way:

```
import asyncio
import contextlib

async def agen():
await asyncio.sleep(1)
yield

async def main():
async with contextlib.aclosing(agen()) as p:
asyncio.current_task().cancel()
try:
await anext(p, 'finished')
except asyncio.CancelledError:
pass

asyncio.run(main())
```

```
an error occurred during closing of asynchronous generator 
asyncgen: 
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in 
run_until_complete
return future.result()
  File "/home/graingert/projects/asyncio-demo/foo.py", line 9, in main
async with contextlib.aclosing(agen()) as p:
  File "/usr/lib/python3.10/contextlib.py", line 366, in __aexit__
await self.thing.aclose()
RuntimeError: aclose(): asynchronous generator is already running

During handling of the above exception, another exception occurred:

RuntimeError: aclose(): asynchronous generator is already running
Traceback (most recent call last):
  File "/home/graingert/projects/datapraxis/analysis/foo.py", line 16, in 

asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in 
run_until_complete
return future.result()
  File "/home/graingert/projects/asyncio-demo/foo.py", line 9, in main
async with contextlib.aclosing(agen()) as p:
  File "/usr/lib/python3.10/contextlib.py", line 366, in __aexit__
await self.thing.aclose()
RuntimeError: aclose(): asynchronous generator is already running
```

--
nosy: +graingert

___
Python tracker 

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



[issue44963] anext_awaitable is not a collections.abc.Generator

2021-08-20 Thread Joshua Bronson


Change by Joshua Bronson :


--
nosy: +jab

___
Python tracker 

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



[issue44965] [sqlite3] early exit for non-DML statements in executemany()

2021-08-20 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


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

___
Python tracker 

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



[issue44965] [sqlite3] early exit for non-DML statements in executemany()

2021-08-20 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

Currently, if a non-DML statement is executed with executemany(), we only bail 
as late as possible: just before the call to _pysqlite_fetch_one_row(). This 
means that we've already stepped through the statement once (!), and possibly 
bound values, built the row cast map, and created the description tuple, all 
before raising the "executemany() can only execute DML statements."

So, the error message currently is not quite true, because we already executed 
the statement once.

Checking for this earlier will prevent a (possibly time-consuming) 
sqlite3_step(), and it will leave the main loop in _pysqlite_query_execute() 
slightly easier to read, IMO.

--
components: Extension Modules
messages: 32
nosy: berker.peksag, erlendaasland, serhiy.storchaka
priority: low
severity: normal
status: open
title: [sqlite3] early exit for non-DML statements in executemany()
type: enhancement

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Pedro Gimeno


Pedro Gimeno  added the comment:

> @Pedro Thanks again for the report! Just out of curiosity, how did you manage 
> to find this?

I'm writing a C strtod implementation and I was adding corner cases to the unit 
testing (now published here: 
https://codeberg.org/pgimeno/ACSL/src/branch/master/tests/test-strtod.c). 
Sometimes I get confused by whether to add one or subtract one to the exponent 
as digits are moved, and since I have an interactive Python shell always open 
as a calculator, I used it to make sure that the test I was writing had the 
correct exponent. But the result I got was not the one I expected, and upon 
verification, I soon became convinced that it was a bug, so I dug a bit more 
(at first I didn't notice it only happened if the leading zero was left out) 
and finally submitted the bug.

Thanks for the quick fix, by the way.

--
resolution: fixed -> 
status: closed -> open
type: behavior -> 
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



[issue44941] Add check_methods function to standard library

2021-08-20 Thread Éric Araujo

Éric Araujo  added the comment:

FYI there was a ticket and a discussion before: 
https://mail.python.org/archives/list/python-id...@python.org/thread/FCGDSVWHIJHBYKS2O4RHZVLXCGSGBLQH/#FCGDSVWHIJHBYKS2O4RHZVLXCGSGBLQH

Should be reviewed to see the arguments made and determine if things have 
changed to reopen the question!

--
nosy: +eric.araujo

___
Python tracker 

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



[issue39039] zlib.error with tarfile.open

2021-08-20 Thread jvoisin


jvoisin  added the comment:

The file was created with a fuzzer, like the one described in 
https://dustri.org/b/fuzzing-python-in-python-and-doing-it-fast.html

--

___
Python tracker 

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



[issue30999] statistics module: add a general selection function

2021-08-20 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy:  -mark.dickinson

___
Python tracker 

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



[issue11479] Add discussion of trailing backslash in raw string to tutorial

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

The patch needs to be converted into a github PR, and modified according to the 
feedback on this issue.

--
keywords: +easy
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

All fixed! Closing.

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

___
Python tracker 

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



[issue44964] Semantics of PyCode_Addr2Line() changed

2021-08-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Sorry, bad copy paste. Correction:

Technically, the function was called with:

PyCode_Addr2Line(frame->f_code, frame->f_last_i)

but now it needs to be called with

PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)

--

___
Python tracker 

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



[issue44964] Semantics of PyCode_Addr2Line() changed

2021-08-20 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

I have noticed that the semantics of PyCode_Addr2Line() have changed from 3.9 
to 3.10. Technically, the function was called with:

PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)

but now it needs to be called with

PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)

This is likely going to break all users of this function. This is also not 
advertised in the 3.10 "how to port to Python 3.10" section.

We should discuss what's the best approach here because technically this is a 
backwards incompatible change, although in the other hand PyCode_Addr2Line() 
was not documented previously so we may have some room.

We need to decide on this ASAP, because there is only one extra release 
candidate before the actual release of 3.10/

--
keywords: 3.10regression
messages: 399985
nosy: Mark.Shannon, pablogsal
priority: release blocker
severity: normal
status: open
title: Semantics of PyCode_Addr2Line() changed
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



[issue44958] [sqlite3] only reset statements when needed

2021-08-20 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

I did a quick count of sqlite3_reset()s in the sqlite3 test suite:
- main: 2976 calls
- PR 27844: 1730 calls

Since we never call sqlite3_reset() with a NULL pointer, all sqlite3_reset() 
calls we execute hold the SQLite db mutex; reducing the number of 
sqlite3_reset() calls reduces the number of times we need to hold the mutex.

--

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread miss-islington


miss-islington  added the comment:


New changeset 838b0e975fc2c106508eb27d19a9548533ac1e55 by Miss Islington (bot) 
in branch '3.10':
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)
https://github.com/python/cpython/commit/838b0e975fc2c106508eb27d19a9548533ac1e55


--

___
Python tracker 

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



[issue44963] anext_awaitable is not a collections.abc.Generator

2021-08-20 Thread Daniel Pope


New submission from Daniel Pope :

The anext_awaitable object returned by anext(..., default) does not support 
.send()/.throw(). It only supports __next__().

So we can pass messages from the suspending coroutine to the event loop but not 
from the event loop to the suspending coroutine.

trio and curio rely on both directions working. (I don't know about asyncio.)

For example, this trio code fails:

import trio

async def produce():
   for v in range(3):
   await trio.sleep(1)
   yield v

async def consume():
   p = produce()
   while True:
print(await anext(p, 'finished'))

trio.run(consume)

raising AttributeError: 'anext_awaitable' object has no attribute 'send'.

I realise that any awaitable that wants to await another awaitable must return 
not an iterator from __await__() but something that implements the full PEP-342 
generator protocol. Should PEP-492 section on __await__()[1] say something 
about that?

[1] https://www.python.org/dev/peps/pep-0492/#await-expression

--
components: Library (Lib)
messages: 399982
nosy: lordmauve
priority: normal
severity: normal
status: open
title: anext_awaitable is not a collections.abc.Generator
type: behavior
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



[issue44524] __name__ attribute in typing module

2021-08-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26319
pull_request: https://github.com/python/cpython/pull/27861

___
Python tracker 

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



[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

2021-08-20 Thread Vedran Čačić

Vedran Čačić  added the comment:

Also, maybe you should read the following sentence (also in the docs):

> If one wants more information about all matches of a pattern than the matched 
> text, finditer() is useful as it provides match objects instead of strings.

It seems that's what you wanted in the first place.

--

___
Python tracker 

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



[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

2021-08-20 Thread Vedran Čačić

Vedran Čačić  added the comment:

Have you seen the patch? In the patched docs, non-capturing grouping is 
explicitly mentioned. (Though I myself wouldn't include even that, as it's 
superfluous with what's said before, obviously it's needed.:)

--

___
Python tracker 

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



[issue4442] document immutable type subclassing via __new__

2021-08-20 Thread Gautam Chaudhuri


Change by Gautam Chaudhuri :


--
nosy: +quantum

___
Python tracker 

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



[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

2021-08-20 Thread Rondevous


Rondevous  added the comment:

To produce the same results that you'd get by using the global flag in 
javascript regex, and make re.findall to not capture the groups exclusively, 
all the groups in the pattern need to be of the non-capturing (?:) type. 

If the distinction about capturing and non-capturing groups is mentioned in the 
docs of re.findall, it would help those who have learnt regex from another 
language (like javascript), where the global flag in regex is allowed.

I want the docs of re.findall and re.finditer to somehow suggest the use 
(?:group) to return the original matches and not the captured groups.

--

___
Python tracker 

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



[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

2021-08-20 Thread Rondevous


Rondevous  added the comment:

Maybe the functionality of re.findall and re.finditer is limited because, e.g. 
I can't do something like this:
https://stackoverflow.com/questions/3512471/what-is-a-non-capturing-group-in-regular-expressions#3513858

The workaround for doing that might need me to eventually write a parser O_O

--

___
Python tracker 

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



[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

2021-08-20 Thread Rondevous


Rondevous  added the comment:

>From my understanding, "|" should match either the RegEx on the left or the 
>RegEx on the right of the pipe
>>> help(re):
"|"  A|B, creates an RE that will match either A or B.

With re.search(), the pattern below matches 'cool' as well as 'foo'
>>> re.search('(foo)|cool?', 'foo bar cool foobar coolbar')

>>> re.search('(foo)|cool?', 'cool')


But, the same pattern and strings won't match 'cool' if used with re.findall() 
or re.finditer() because of how they work when capture-groups are present in 
the pattern.

--
title: Hint the use of non-capturing group in re.findall() documentation -> 
Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

___
Python tracker 

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



[issue44940] Hint the use of non-capturing group in re.findall() documentation

2021-08-20 Thread Rondevous


Rondevous  added the comment:

To clarify in short: the pattern I mentioned doesn't give the result I expected 
in re.findall() unlike re.search()

Given pattern:  (foo)?bar|cool

Maybe my approach in testing the regex first using re.search() and then using 
re.findall() to return all matches was wrong.

Initially, after going through help(re) I had associated re.findall with the 
'global' flag used in javascript regex which would return all the matches. 
Without the global flag (in javascript) only the first match is returned, like 
re.search() in python.

--

___
Python tracker 

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



[issue39355] The Python library will not compile with a C++2020 compiler because the code uses the reserved “module” keyword

2021-08-20 Thread Hasan


Hasan  added the comment:

We have tested with cxx-modules that issue.
module is just a specifier for export (only export is a compiler-based keyword 
in >= C++20)
That's why we can use module as argument name and there's no need to rename or 
delete *module arguments from header files.

What do you recommend to do?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1103r3.pdf

--

___
Python tracker 

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



[issue44926] typing.get_type_hints() raises for type aliases with forward references

2021-08-20 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 16b9be4861e007ad483611ba0479feb2b90ea783 by Maximilian Hils in 
branch 'main':
bpo-44926: `get_type_hints`: Add note about type aliases with forward refs 
(#27859)
https://github.com/python/cpython/commit/16b9be4861e007ad483611ba0479feb2b90ea783


--

___
Python tracker 

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



[issue44926] typing.get_type_hints() raises for type aliases with forward references

2021-08-20 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Ben


Ben  added the comment:

I can reproduce on 3.9.6

A little digging and it seems asyncio imports Task from _asyncio
and _asyncio's implementation (in asynciomodule.c) of Task has an __init__ 
which adds the task to the `all_tasks` weakref.WeakSet
which appears to be implemented in Python (in Lib/_weakrefset.py)

weakref.WeakSet is not thread-safe,  which means concurrent create_task's in 
different threads (even on separate event loops) is not safe.

--
nosy: +bjs

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger


Thomas Grainger  added the comment:

interestingly 3.10 didn't show:

sys:1: RuntimeWarning: coroutine 'BaseEventLoop.shutdown_asyncgens' was never 
awaited

--

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger


Thomas Grainger  added the comment:

still happens on 3.10 even though there's an `with _IterationGuard`

```
worked 0
Traceback (most recent call last):
  File "/home/graingert/projects/asyncio-demo/demo.py", line 36, in 
sys.exit(main())
  File "/home/graingert/projects/asyncio-demo/demo.py", line 30, in main
test_all_tasks_threading()
  File "/home/graingert/projects/asyncio-demo/demo.py", line 24, in 
test_all_tasks_threading
results.append(f.result())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 438, in result
return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 390, in 
__get_result
raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.10/asyncio/runners.py", line 47, in run
_cancel_all_tasks(loop)
  File "/usr/lib/python3.10/asyncio/runners.py", line 56, in _cancel_all_tasks
to_cancel = tasks.all_tasks(loop)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 53, in all_tasks
tasks = list(_all_tasks)
  File "/usr/lib/python3.10/_weakrefset.py", line 60, in __iter__
with _IterationGuard(self):
  File "/usr/lib/python3.10/_weakrefset.py", line 33, in __exit__
w._commit_removals()
  File "/usr/lib/python3.10/_weakrefset.py", line 57, in _commit_removals
discard(l.pop())
IndexError: pop from empty list
```

--

___
Python tracker 

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



[issue30999] statistics module: add a general selection function

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

Updating the subject according to the discussion.

--
nosy: +iritkatriel
title: statistics module: add "key" keyword argument to median, mode, ... -> 
statistics module: add a general selection function
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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger


Change by Thomas Grainger :


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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger


Change by Thomas Grainger :


--
versions: +Python 3.7

___
Python tracker 

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



[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger


New submission from Thomas Grainger :

with the following demo script I can get a IndexError: pop from empty list

```
import itertools
import asyncio
import concurrent.futures
import sys
import threading

threads = 200

def test_all_tasks_threading() -> None:
async def foo() -> None:
await asyncio.sleep(0)

async def create_tasks() -> None:
for i in range(1000):
asyncio.create_task(foo())

await asyncio.sleep(0)

results = []
with concurrent.futures.ThreadPoolExecutor(threads) as tpe:
for f in concurrent.futures.as_completed(
tpe.submit(asyncio.run, create_tasks()) for i in range(threads)
):
results.append(f.result())
assert results == [None] * threads


def main():
for i in itertools.count():
test_all_tasks_threading()
print(f"worked {i}")
return 0


if __name__ == "__main__":
sys.exit(main())
```



```
worked 0
worked 1
worked 2
worked 3
worked 4
worked 5
worked 6
worked 7
worked 8
worked 9
worked 10
worked 11
worked 12
worked 13
worked 14
worked 15
worked 16
worked 17
worked 18
Traceback (most recent call last):
  File "/home/graingert/projects/asyncio-demo/demo.py", line 36, in 
sys.exit(main())
  File "/home/graingert/projects/asyncio-demo/demo.py", line 30, in main
test_all_tasks_threading()
  File "/home/graingert/projects/asyncio-demo/demo.py", line 24, in 
test_all_tasks_threading
results.append(f.result())
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 438, in result
return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 390, in 
__get_result
raise self._exception
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.9/asyncio/runners.py", line 48, in run
loop.run_until_complete(loop.shutdown_asyncgens())
  File "/usr/lib/python3.9/asyncio/base_events.py", line 621, in 
run_until_complete
future = tasks.ensure_future(future, loop=self)
  File "/usr/lib/python3.9/asyncio/tasks.py", line 667, in ensure_future
task = loop.create_task(coro_or_future)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 433, in create_task
task = tasks.Task(coro, loop=self, name=name)
  File "/usr/lib/python3.9/_weakrefset.py", line 84, in add
self._commit_removals()
  File "/usr/lib/python3.9/_weakrefset.py", line 57, in _commit_removals
discard(l.pop())
IndexError: pop from empty list
sys:1: RuntimeWarning: coroutine 'BaseEventLoop.shutdown_asyncgens' was never 
awaited
Task was destroyed but it is pending!
task: >
```

here's a live demo on github actions: 
https://github.com/graingert/asyncio-backport/runs/3380502247#step:5:90

--
components: asyncio
messages: 399969
nosy: asvetlov, graingert, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.create_task weakrefset race condition
versions: Python 3.8, Python 3.9

___
Python tracker 

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



[issue33084] statistics module: NaN handling in median, median_high an median_low

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced in 3.11:

>>> import numpy as np
>>> import statistics as stats
>>> data = [75, 90,85, 92, 95, 80, np.nan]
>>> stats.median(data)
90
>>> stats.median_low(data)
90
>>> stats.median_high(data)
90

--
nosy: +iritkatriel
title: Computing median, median_high an median_low in statistics library -> 
statistics module: NaN handling in median, median_high an median_low
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

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



[issue21184] statistics.pvariance with known mean does not work as expected

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

I can't reproduce this on 3.11, was it fixed?

>>> import statistics
>>> data = [1, 2, 2, 2, 3, 4]
>>> statistics.pvariance(data)
0.
>>> statistics.pvariance(data, 2.5)
0.9166
>>>

--
nosy: +iritkatriel

___
Python tracker 

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



[issue44960] Add regression test for geometric_mean

2021-08-20 Thread Irit Katriel


Change by Irit Katriel :


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



[issue44960] Add regression test for geometric_mean

2021-08-20 Thread Irit Katriel

Irit Katriel  added the comment:


New changeset f5d7a8d29c49ad47254fa098abb7a510e5e7b45e by Irit Katriel in 
branch 'main':
bpo-44960: add regression test for geometric_mean with mixed int/floa… (#27856)
https://github.com/python/cpython/commit/f5d7a8d29c49ad47254fa098abb7a510e5e7b45e


--

___
Python tracker 

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



[issue44926] typing.get_type_hints() raises for type aliases with forward references

2021-08-20 Thread Maximilian Hils


Change by Maximilian Hils :


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

___
Python tracker 

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



[issue44961] @classmethod doesn't set __wrapped__ the same way as functool's update_wrapper

2021-08-20 Thread Thomas


New submission from Thomas :

@classmethod defines a __wrapped__ attribute that always points to the inner 
most function in a decorator chain while functool's update_wrapper has been 
fixed to set the wrapper.__wrapped__ attribute after updating the 
wrapper.__dict__ (see https://bugs.python.org/issue17482) so .__wrapped__ 
points to the next decorator in the chain.
This results in inconsistency of the value of the.__wrapped__ attribute.

Consider this code:

from functools import update_wrapper


class foo_deco:
def __init__(self, func):
self._func = func
update_wrapper(self, func)

def __call__(self, *args, **kwargs):
return self._func(*args, **kwargs)


class bar_deco:
def __init__(self, func):
self._func = func
update_wrapper(self, func)

def __call__(self, *args, **kwargs):
return self._func(*args, **kwargs)


class Foo:
@classmethod
@foo_deco
def bar_cm(self):
pass

@bar_deco
@foo_deco
def bar_bar(self):
pass


print(Foo.bar_cm.__wrapped__)
# 
print(Foo.bar_bar.__wrapped__)
# <__main__.foo_deco object at 0x7fb025445fd0>

# The foo_deco object is available on bar_cm this way though
print(Foo.__dict__['bar_cm'].__func__)
# <__main__.foo_deco object at 0x7fb025445fa0>

It would be more consistent if the fix that was applied to update_wrapper was 
ported to classmethod's construction (or classmethod could invoke 
update_wrapper directly, maybe). It's also worth noting that @staticmethod 
behaves the same and @property doesn't define a .__wrapped__ attribute. For 
@property, I don't know if this is by design or if it was just never ported, 
but I believe it would be a great addition just to be able to go down a 
decorator chain without having to special-case the code.

--
components: Extension Modules
messages: 399965
nosy: Thomas701
priority: normal
severity: normal
status: open
title: @classmethod doesn't set __wrapped__ the same way as functool's 
update_wrapper
type: behavior
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



[issue39218] Assertion failure when calling statistics.variance() on a float32 Numpy array

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

I've reproduced this on 3.9 and 3.10. This part of the code in main is still 
the same, so the issue is probably there even though we don't have numpy with 
which to test.

--
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

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



[issue43093] Make modules picklable

2021-08-20 Thread Cornelius Krupp


Cornelius Krupp  added the comment:

I would also like to see this added, and I can also provided a usecase where I 
naturally came across this.

I am helping on a parsing library which uses regular expressions internally. We 
allow the user to select the stdlib re module or the third party regex module 
and store the selected module as an attribute in multiple different objects, 
since those modules (by design) have pretty much compatible interfaces. This 
however makes it unpicklable, unless one adds a custom __reduce__ function for 
each of those classes.

Most notably, this issue also extends to deepcopy and the multiprocessing 
module.

--
nosy: +MegaIng

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

Fixed in the main branch and in 3.9; 3.10 is very close to release, so the 
backport PR for 3.10 may have to wait for 3.10.1 (which wouldn't really be a 
problem, given that this bug has apparently lain unnoticed since Python 2.7). 
That's Pablo's call, of course.

@Pedro Thanks again for the report! Just out of curiosity, how did you manage 
to find this?

--

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 7ef0673de48958bc3a75af5f152564bd2dffa8dd by Miss Islington (bot) 
in branch '3.9':
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834) (GH-27855)
https://github.com/python/cpython/commit/7ef0673de48958bc3a75af5f152564bd2dffa8dd


--

___
Python tracker 

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



[issue44960] Add regression test for geometric_mean

2021-08-20 Thread Irit Katriel


Change by Irit Katriel :


--
title: Add regression test for geometric test -> Add regression test for 
geometric_mean

___
Python tracker 

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



[issue44959] EXT_SUFFIX is missing '.sl' on HP-UX

2021-08-20 Thread Roundup Robot


Change by Roundup Robot :


--
nosy: +python-dev
nosy_count: 5.0 -> 6.0
pull_requests: +26316
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27857

___
Python tracker 

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



[issue44960] Add regression test for geometric test

2021-08-20 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26314
pull_request: https://github.com/python/cpython/pull/27855

___
Python tracker 

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



[issue44954] Bug in float.fromhex

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 60b93d9e4922eeae25052bc15909d1f4152babde by Mark Dickinson in 
branch 'main':
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)
https://github.com/python/cpython/commit/60b93d9e4922eeae25052bc15909d1f4152babde


--

___
Python tracker 

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



[issue44959] EXT_SUFFIX is missing '.sl' on HP-UX

2021-08-20 Thread Florin Spătar

Florin Spătar  added the comment:

@mattip
Yes, the patch fixed the issue and the extension module import works.

With the patch applied:

[fspatar@hpux1131:/cust/fspatar/buildtest/hp-ux/11.31/build]> 
/opt/OPSWbuildtools/2.0.5/python/3.8.11.01/bin/python3
Python 3.8.11 (default, Aug  4 2021, 03:13:01) 
[GCC 4.2.4] on hp-ux-pa
Type "help", "copyright", "credits" or "license" for more information.
>>> import _imp
>>> _imp.extension_suffixes()
['.cpython-38.sl', '.sl']
>>> 

Sorry for the confusion; I meant python should search for the following file 
names when extension module _m2crypto is imported (in this order):

_m2crypto.cpython-38.sl
_m2crypto.sl

@vstinner
I'm working on the pull request.

--

___
Python tracker 

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



[issue44547] fraction.Fraction does not implement __int__.

2021-08-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Fraction.__int__ = Fraction.__trunc__ may not work because __trunc__() can 
return any object with __index__, while __int__ should return an exact int (not 
even an int subclass).

--

___
Python tracker 

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



[issue44960] Add regression test for geometric test

2021-08-20 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue27353] Add nroot function to math

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Irit]

> Is this still needed?

It's not needed for geometric_mean. It's still a reasonable feature request, 
but it would be non-trivial effort to put a good quality implementation 
together - C doesn't have this function, so we can't simply wrap it like we did 
for cbrt. But at least IEEE 754 does specify a "rootn" function, so we know 
what the behaviour should be in all the various special cases.

cbrt probably covers a good proportion of use-cases for rootn (those that 
weren't already satisfied by sqrt).

NumPy seems to have survived without needing a rootn function so far, which 
seems like an indication that it's not a really pressing need.

Let's close, and re-open or open a new issue if someone discovers another good 
use-case.

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



[issue44960] Add regression test for geometric test

2021-08-20 Thread Steven D'Aprano


New submission from Steven D'Aprano :

Hi Irit, thanks for looking at #28327.

Sorry to be That Guy who can't do it himself, but I'm still stuck with old tech 
and ignorance about the git way of doing things, which limits my ability to do 
PRs :-(

Would you be willing to add a regression test for that bug to the 
test_statistics.py file please?

If you can add a test case for this in

class TestGeometricMean

and make a PR that would be great. If you're not willing or able, please just 
reassign back to me and I'll go old school and make a patch file.

Should be fairly straight-forward, just add a method like

def test_regression_28327(self):
# Regression test for b.p.o. #28327
gmean = statistics.geometric_mean
expected = 3.80675409583932
self.assertTrue(math.isclose(gmean([2, 3, 5, 7]), expected))
self.assertTrue(math.isclose(gmean([2.0, 3.0, 5.0, 7.0]), expected))


Thanks.

--
assignee: iritkatriel
messages: 399956
nosy: iritkatriel, steven.daprano
priority: normal
severity: normal
status: open
title: Add regression test for geometric test
type: behavior

___
Python tracker 

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



[issue44344] Documentation for pow() should include the possibility of complex numbers as a return type

2021-08-20 Thread Mark Dickinson


Change by Mark Dickinson :


--
assignee: docs@python -> mark.dickinson

___
Python tracker 

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



[issue44959] EXT_SUFFIX is missing '.sl' on HP-UX

2021-08-20 Thread mattip


mattip  added the comment:

I assume you tried and succeeded with your patch. Could you post what 
`_imp.extension_suffixes()` reports after the patch? 

I am a bit confused because you said the following, should the last line be 
`_m2crypto.sl` and not `_m2crypto.sl` ?

my understanding is that python should search for the following file names when 
extension module _m2crypto is imported (in this order):

_m2crypto.cpython-38.sl
_m2crypto.so

--

___
Python tracker 

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



[issue44344] Documentation for pow() should include the possibility of complex numbers as a return type

2021-08-20 Thread Mark Dickinson


Change by Mark Dickinson :


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

___
Python tracker 

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



[issue27353] Add nroot function to math

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

Is this still needed? It was requested for issue27181, which has been resolved 
by now.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue36099] Clarify the difference between mu and xbar in the statistics documentation

2021-08-20 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> clarify meaning of xbar and mu in pvariance/variance of 
statistics module

___
Python tracker 

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



[issue20389] clarify meaning of xbar and mu in pvariance/variance of statistics module

2021-08-20 Thread Irit Katriel


Irit Katriel  added the comment:

I've closed issue36099 as a duplicate of this.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue16801] Preserve original representation for integers / floats in docstrings

2021-08-20 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy:  -mark.dickinson

___
Python tracker 

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



[issue44728] Testsuite fails on x86_64

2021-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

One more thought on the libm issues - from the logs, it looks as though the 
libm implementation is coming from a fairly recent version of glibc (glibc 
2.33, which was released in February 2021). There were updates to the 'exp' 
implementation in glibc in 2018[1], but I'm not seeing anything more recent 
than that. Is it possible that glibc was miscompiled somehow on this platform - 
e.g., that it's using code designed to work with the x87 FPU with its extended 
precision, but was compiled with flags that force use of SSE2 instead?

If not, and if there's a genuine accuracy problem in glibc itself, we should 
expect to see more Python test_math and test_cmath failures in the future.

If anyone is able to run test_math or test_cmath on a machine using glibc 2.33 
or glibc 2.34 and report results, that would be useful.




[1] 
https://sourceware.org/git/?p=glibc.git;a=commit;h=e70c17682518fab2fad164fecf73341443bc2ed3

--

___
Python tracker 

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



[issue20389] clarify meaning of xbar and mu in pvariance/variance of statistics module

2021-08-20 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4

___
Python tracker 

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



  1   2   >