[issue46511] dataclasses: Allow typing.Annotated to wrap dataclasses-specific annotations

2022-01-25 Thread Gregory Beauregard


Gregory Beauregard  added the comment:

Or rather,

^\s*(?:(?:\w+\s*\.)?\s*Annotated\s*\[)?(?:\s*(\w+)\s*\.)?\s*(\w+)

--

___
Python tracker 

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



[issue46511] dataclasses: Allow typing.Annotated to wrap dataclasses-specific annotations

2022-01-25 Thread Gregory Beauregard


Gregory Beauregard  added the comment:

Thanks for getting back so quickly.

Annotated is set up to be 'transparent' by default to `typing.get_type_hints` 
so in the case of using `typing.py` it can be made straightforward by chaining 
with `typing.get_origin`, I think.

I don't see any reasonable way to do the regex that allows `Annotated` to be 
renamed, so I agree your suggested restriction. I think the regex would be 
something like this:

^\s*(?:(?:\w+\s*\.)?\s*Annotated\[)?(?:\s*(\w+)\s*\.)?\s*(\w+)

I'm a bit worried people who are into Annotated annotations might be concerned 
about line length and more likely to rename `Annotated`, but I don't know if 
this is a realistic concern. And a part of me wants to say always importing 
typing.py should be okay since dataclasses was designed to work with type hints 
after all.

On the other hand, I'm also a bit worried that if we made dataclasses always 
import typing.py it would rub people the wrong way even if we profiled it and 
decided it was okay.

I'm going to spend some more time digesting the code tomorrow and try to decide 
if there's any major speed bumps to a full `typing` approach. I'll also look at 
import time and such.

--

___
Python tracker 

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



[issue46517] Review exception handling in urllib

2022-01-25 Thread Irit Katriel

Irit Katriel  added the comment:

> The author probably also wants the TypeError initially raised from the 
> "len(query)" and "query[0]" operations to get the same "not a valid . . ." 
> message.

I see.


I didn’t realise it’s deprecated, I guess we’ll leave it alone then. Thanks.

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



[issue41846] IDLE subsection of What's New 3.10

2022-01-25 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Dong-hee Na


Change by Dong-hee Na :


--
priority: normal -> release blocker

___
Python tracker 

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



[issue46517] Review exception handling in urllib

2022-01-25 Thread Martin Panter


Martin Panter  added the comment:

The linked code is for urllib.parse.urlencode, looking something like

try:
if len(query) and not isinstance(query[0], tuple):
raise TypeError
except TypeError:
ty, va, tb = sys.exc_info()
raise TypeError("not a valid non-string sequence "
"or mapping object").with_traceback(tb)

I guess it raises twice so that the error message is not duplicated in the 
code. The author probably also wants the TypeError initially raised from the 
"len(query)" and "query[0]" operations to get the same "not a valid . . ." 
message.

Regarding the OSError, originally it was catching socket.error and raising 
IOError. I guess someone only wanted the caller to have catch IOError and not 
need to import the socket module. Later these exception types became aliases of 
each other.

Anyway, the URLopener class is documented as deprecated, so is it really worth 
changing anything in that?

--
nosy: +martin.panter

___
Python tracker 

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



[issue33205] GROWTH_RATE prevents dict shrinking

2022-01-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
status: closed -> open

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread miss-islington


miss-islington  added the comment:


New changeset f8a805bde1ff4679c2824ced4a28437da61b1506 by Miss Islington (bot) 
in branch '3.9':
bpo-41844: Update IDLE part of What's New 3.9 to 20228 (GH-30905)
https://github.com/python/cpython/commit/f8a805bde1ff4679c2824ced4a28437da61b1506


--

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread miss-islington


miss-islington  added the comment:


New changeset 8356f6aac2fc41cab44159574f5d8fd5fdf95a63 by Miss Islington (bot) 
in branch '3.10':
bpo-41844: Update IDLE part of What's New 3.9 to 20228 (GH-30905)
https://github.com/python/cpython/commit/8356f6aac2fc41cab44159574f5d8fd5fdf95a63


--

___
Python tracker 

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



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

2022-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

> sys.getwindowsversion() which exposes GetVersionEx() looks fine to me.

In Windows 8+, sys.getwindowsversion() returns a version that can vary from 
6.2.9200 (Windows 8) up to the actual OS version. It depends on the OS versions 
supported by the application manifest -- with 6.2.9200 used when there's no 
application manifest. The platform module uses the shell's VER command because 
it returns the real OS version.

The version number for Windows 11 is 10.0.22000+. The platform module 
misreports this as Windows 10. In msg403452, I suggested a modification to use 
build numbers. In msg404451 Steve said we may as well use the WMI result to 
identify Windows 11 based on the OS caption. If we use WMI, we can choose to 
rely on wmic.exe (deprecated), PowerShell, or implement our own code in C/C++.

> I don't understand why we have to handle XML or JSON and encoding... 

Using JSON or XML (ElementTree) isn't required, if you'd rather parse 
human-readable output. AFAIK, the Win32_OperatingSystem caption is always 
ASCII. 

In general, wmic.exe writes output text to a pipe that's encoded with the 
system OEM code page. pwsh.exe, powershell.exe, and cmd.exe write output text 
to a pipe (from their internal commands/cmdlets) that's encoded using the 
console's output code page. cmd.exe also supports a /U option to use UTF-16.

--

___
Python tracker 

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



[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29086
pull_request: https://github.com/python/cpython/pull/30908

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29087
pull_request: https://github.com/python/cpython/pull/30909

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 7cf285d82ec722d4225297366013e924805171f2 by Terry Jan Reedy in 
branch 'main':
bpo-41844: Update IDLE part of What's New 3.9 to 20228 (GH-30905)
https://github.com/python/cpython/commit/7cf285d82ec722d4225297366013e924805171f2


--

___
Python tracker 

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



[issue41846] IDLE subsection of What's New 3.10

2022-01-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


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

___
Python tracker 

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



[issue41844] IDLE subsection of What's New 3.9

2022-01-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +29084
pull_request: https://github.com/python/cpython/pull/30905

___
Python tracker 

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



[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


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

___
Python tracker 

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



[issue43706] enumerate() instantiation time reducing by using PEP 590 vectorcall

2022-01-25 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra
nosy_count: 4.0 -> 5.0
pull_requests: +29083
pull_request: https://github.com/python/cpython/pull/30904

___
Python tracker 

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



[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

I can confirm that the behavior changed between 3.10 and current main: 
enumerate(iterable=[]) works on 3.10 but not on main. It's likely a consequence 
of bpo-43706.

I'll submit a patch to restore the previous behavior.

--
nosy: +Jelle Zijlstra, corona10

___
Python tracker 

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



[issue46498] Add new triplets for loongarch64

2022-01-25 Thread WANG Xuerui


New submission from WANG Xuerui :

First of all I think the changes should probably go in main branch first, then 
backported to the older branches if possible; although IMO you'd be much better 
off just backporting and carrying the patch yourselves.

Secondly the suggested patch is not consistent with the LoongArch toolchain 
spec, in that it didn't use the multiarch identifiers in the spec document 
(https://github.com/loongson/LoongArch-Documentation/blob/a8a004148734445480659a5e25ef985817881341/docs/LoongArch-toolchain-conventions-EN.adoc,
 Table 12), but rather the old-world one; see the discussion at 
https://github.com/loongarch64/cpython/pull/1 (in Chinese) too.

--
nosy: +xen0n

___
Python tracker 

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



[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher


Brandt Bucher  added the comment:

In practice, pretty much the only thing that will do more work now is augmented 
subscription:

>>> a[b] += c

main:

  1   2 LOAD_NAME0 (a)
  4 LOAD_NAME1 (b)
  6 DUP_TOP_TWO
  8 BINARY_SUBSCR
 10 LOAD_NAME2 (c)
 12 BINARY_OP   13 (+=)
 14 ROT_THREE
 16 STORE_SUBSCR

patched:

  1   2 LOAD_NAME0 (a)
  4 LOAD_NAME1 (b)
  6 COPY 2
  8 COPY 2
 10 BINARY_SUBSCR
 12 LOAD_NAME2 (c)
 14 BINARY_OP   13 (+=)
 16 SWAP 3
 18 SWAP 2
 20 STORE_SUBSCR

Pattern matching is the only place where we use ROT_N, and frankly it's 
*misused* there... often, it makes the cost of storing names quadratic at 
runtime. Even though we emit *more* instructions now, the peephole optimizer 
actually cuts them down significantly, and the result is more efficient than 
before. For example:

>>> match x:
... case (a, b, c, None):
... pass

main:

  1   2 LOAD_NAME0 (x)

  2   4 MATCH_SEQUENCE
  6 POP_JUMP_IF_FALSE   20 (to 40)
  8 GET_LEN
 10 LOAD_CONST   0 (4)
 12 COMPARE_OP   2 (==)
 14 POP_JUMP_IF_FALSE   20 (to 40)
 16 UNPACK_SEQUENCE  4
 18 ROT_FOUR
 20 ROT_FOUR
 22 ROT_FOUR
 24 POP_JUMP_IF_NOT_NONE18 (to 36)
 26 STORE_NAME   1 (a)
 28 STORE_NAME   2 (b)
 30 STORE_NAME   3 (c)

  3  32 LOAD_CONST   1 (None)
 34 RETURN_VALUE

  2 >>   36 POP_TOP
 38 POP_TOP
>>   40 POP_TOP
 42 LOAD_CONST   1 (None)
 44 RETURN_VALUE

patched:

  1   2 LOAD_NAME0 (x)

  2   4 MATCH_SEQUENCE
  6 POP_JUMP_IF_FALSE   20 (to 40)
  8 GET_LEN
 10 LOAD_CONST   0 (4)
 12 COMPARE_OP   2 (==)
 14 POP_JUMP_IF_FALSE   20 (to 40)
 16 UNPACK_SEQUENCE  4
 18 SWAP 2
 20 SWAP 3
 22 SWAP 4
 24 POP_JUMP_IF_NOT_NONE18 (to 36)
 26 STORE_NAME   1 (a)
 28 STORE_NAME   2 (b)
 30 STORE_NAME   3 (c)

  3  32 LOAD_CONST   1 (None)
 34 RETURN_VALUE

  2 >>   36 POP_TOP
 38 POP_TOP
>>   40 POP_TOP
 42 LOAD_CONST   1 (None)
 44 RETURN_VALUE

Replacing the ROT_FOURs with SWAPs may seem minor, but it ends up being a *lot* 
less work at runtime.

--

___
Python tracker 

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



[issue12067] Doc: remove errors about mixed-type comparisons.

2022-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Martin: [tests need review].  Yep.  Improved constant folding and elimination 
of duplication now causes many 'is not' tests to fail.  Language tests should 
not test current implementation limitations.

--

___
Python tracker 

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



[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher


Change by Brandt Bucher :


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

___
Python tracker 

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



[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

What are the (unoptimized) performance implications of replacing one 
instruction with multiple instructions?

--
nosy: +barry

___
Python tracker 

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



[issue46528] Simplify the VM's stack manipulations

2022-01-25 Thread Brandt Bucher


New submission from Brandt Bucher :

...as discussed in https://github.com/faster-cpython/ideas/discussions/228.

We can dramatically simplify our stack manipulations by getting rid of the 
`DUP_TOP*` and `ROT_*` families of instructions:

- Replace `DUP_TOP` with `COPY(1)`.
- Replace `DUP_TOP_TWO` with `COPY(2), COPY(2)`.
- Introduce a new `SWAP` instruction.
  - Replace `ROT_TWO` with `SWAP(2)`.
  - Replace `ROT_THREE` with `SWAP(3), SWAP(2)`.
  - Remove `ROT_FOUR`.
  - Replace `ROT_N(n)` with `SWAP(n), SWAP(n - 1), ..., SWAP(2)`.

It then becomes much simpler for the peephole optimizer to reason about code 
sequences involving these instructions (for example, it's pretty 
straightforward to truly *optimize* an arbitrary sequence of swaps).

--
assignee: brandtbucher
components: Interpreter Core
messages: 411697
nosy: Mark.Shannon, brandtbucher
priority: normal
severity: normal
status: open
title: Simplify the VM's stack manipulations
type: performance
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



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

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

I don't understand why we have to handle XML or JSON and encoding... just to 
get a version number. Why did Microsoft make it so complicated?

sys.getwindowsversion() which exposes GetVersionEx() looks fine to me.

--

___
Python tracker 

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



[issue46527] enumerate no longer accepts iterable keyword argument

2022-01-25 Thread Trey Hunner


New submission from Trey Hunner :

While playing around with the main CPython branch against I noticed that 
enumerate now gives a strange error message when `iterable` is provided as a 
keyword argument:

>>> enumerate(iterable=[])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: enumerate() missing required argument 'iterable'

When passing an invalid keyword argument (and no positional arguments) an 
interesting error message is also given:

>>> enumerate(hello="world")
Traceback (most recent call last):
  File "", line 1, in 
TypeError: enumerate() missing required argument 'iterable'


The help output still shows that iterable is accepted as either a keyword 
argument or a positional argument.

--
components: Library (Lib)
messages: 411695
nosy: trey
priority: normal
severity: normal
status: open
title: enumerate no longer accepts iterable keyword argument
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



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

2022-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

> Bit wmic seems nice solution.
> Is still working for windows lower than 11?

wmic.exe is still included in Windows 10 and 11, but it's officially deprecated 
[1], which means it's no longer being actively developed, and it might be 
removed in a future update. PowerShell is the preferred way to use WMI.

---
[1] 
https://docs.microsoft.com/en-us/windows/deployment/planning/windows-10-deprecated-features

--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yeah, there are no perfect solutions. Please let it go.

--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Anthony Sottile


Anthony Sottile  added the comment:

3.7.2 has another example where OrderedDict was added to typing

I don't have any personal investment in this particular change but I've had 
quite a few unhappy consumers of libraries due to instability in typing apis 
between patch versions in the past (heh and they're especially frustrated 
because they don't care about type checking and just want functional software)

it's also difficult and/or not cost effective to add every patch version to a 
CI matrix to catch these sorts of problems

--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Well that's *always* a problem right? If you take that to the extreme we 
wouldn't need bugfix releases. :-)

Apart from some examples in the 3.5-3.6 timeframe, what makes you think that 
*this* fix *specifically* is going to make more people unhappy than it makes 
happy?

When people complain that they wrote Annotated[ClassVar[int], ...] and are 
disappointed that it doesn't work in a certain old version, you can just tell 
them to use ClassVar[Annotated[int, ...]] which is in no way invalid or 
inferior and works in all versions that support Annotated.

--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Anthony Sottile


Anthony Sottile  added the comment:

to me this is the same as the Union[Pattern] / Union[Match] "fixes" that landed 
in 3.5.3 -- and the pain caused by using that and having CI pass (because of 
modern 3.5.x) but having spurious bug reports from users stuck on 3.5.2

or in 3.6.1 when NamedTuple was "fixed" to allow methods, again having CI pass 
with modern pythons but having frustrated users running 3.6.0

I forsee the same class of problems here with Annotated where it works great in 
3.10.3 and 3.9.11 but anyone stuck on 3.10.2 or 3.9.10 or older will be broken

--

___
Python tracker 

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



[issue46431] Trouble subclassing ExceptionGroup

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset 072f4a473e861c6c987650f08990c0ed1f76715f by Irit Katriel in 
branch 'main':
bpo-46431: use raw string for regex in test (GH-30901)
https://github.com/python/cpython/commit/072f4a473e861c6c987650f08990c0ed1f76715f


--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

But it *is* a bugfix.

--

___
Python tracker 

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



[issue19073] Inability to specific __qualname__ as a property on a class instance.

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

See also Issue41294.

--

___
Python tracker 

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



[issue46491] typing: allow Annotated in outermost scope

2022-01-25 Thread Anthony Sottile


Anthony Sottile  added the comment:

should this behaviour change be backported?  it potentially creates an annoying 
edgecase where code seemingly works unless you use an older patch version

since this isn't a bugfix I wouldn't expect this to land in 3.9 and 3.10

--
nosy: +Anthony Sottile

___
Python tracker 

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



[issue46431] Trouble subclassing ExceptionGroup

2022-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +29080
pull_request: https://github.com/python/cpython/pull/30901

___
Python tracker 

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



[issue46524] test_peg_generator takes 8 minutes on Windows

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> In which case it would be generally helpful to start the longest-running 
> tests first.

Currently, most CI run "make buildbottest" which uses -r option of libregrtest: 
randomize tests order.

--

___
Python tracker 

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



[issue41294] Allow '__qualname__' to be an instance of 'DynamicClassAttribute'

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

I think this is a duplicate of Issue19073.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue46526] iglob exclude patterns

2022-01-25 Thread Henning Leth


Henning Leth  added the comment:

Fix typo in 1st post

Code as i espected it would be writen:
... iglob(f'**/*[!{ignore}]', recursive=True)

--

___
Python tracker 

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



[issue46526] iglob exclude patterns

2022-01-25 Thread Henning Leth

New submission from Henning Leth :

Got a project where I am looking for all files in a project dir, except the 
some files/dir/extentions that should be ignored.

Found a possible bug:
- the set has to be defined even though it was a set when defined
- f-string doesn´t work as I would expect

working code from my project:
ignore = {'*.tmp', 'test.txt', './tmp/*'}
for file in iglob('**/*[!f"{set(ignore)}"]', recursive=True):

code as i espected it would be writen:
... iglob(f'**/*[!{"ignore"}]', recursive=True)

--
components: Library (Lib)
messages: 411682
nosy: leth.henning
priority: normal
severity: normal
status: open
title: iglob exclude patterns
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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

I've started a pull request here: https://github.com/python/cpython/pull/30900

--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Change by Niklas Rosenstein :


--
pull_requests: +29079
pull_request: https://github.com/python/cpython/pull/30900

___
Python tracker 

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



[issue46091] IndendationError from multi-line indented statements

2022-01-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue46091] IndendationError from multi-line indented statements

2022-01-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +29078
pull_request: https://github.com/python/cpython/pull/30899

___
Python tracker 

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



[issue46091] IndendationError from multi-line indented statements

2022-01-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 3fc8b74ace033a17346a992f661928ba619e61e8 by Pablo Galindo Salgado 
in branch '3.10':
[3.10] bpo-46091: Correctly calculate indentation levels for whitespace lines 
with continuation characters (GH-30130). (GH-30898)
https://github.com/python/cpython/commit/3fc8b74ace033a17346a992f661928ba619e61e8


--

___
Python tracker 

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



[issue23556] [doc] Scope for raise without argument is different in Python 2 and 3

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

@kinshukdua - can you explain why you closed the PR and whether you are 
interested in reopening it and finishing this?

--

___
Python tracker 

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



[issue46091] IndendationError from multi-line indented statements

2022-01-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +29077
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30898

___
Python tracker 

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



[issue46091] IndendationError from multi-line indented statements

2022-01-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset a0efc0c1960e2c49e0092694d9839270914c by Pablo Galindo Salgado 
in branch 'main':
bpo-46091: Correctly calculate indentation levels for whitespace lines with 
continuation characters (GH-30130)
https://github.com/python/cpython/commit/a0efc0c1960e2c49e0092694d9839270914c


--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

Interesting! Representing the entire type hint as a string is something I 
haven't thought about, but it makes sense that it works.

It is my understanding that `get_type_hint()` already walks through the entire 
type hint recursively. If it weren't, it would not resolve `List['N']` to 
`List[__main__.N]` in the example below.


>>> from typing import get_type_hints, Mapping, List
>>>
>>> class N:
...   a: Mapping['str', list[List['N']]]
...
>>> get_type_hints(N)
{'a': typing.Mapping[str, list[typing.List[__main__.N]]]}


Upon closer inspection of the `typing` code, I can see that `_eval_type()` is 
doing that recursion. Applying the change your proposed in your previous 
message to that function seems to work at least in a trivial test case.


diff --git a/Lib/typing.py b/Lib/typing.py
index e3e098b1fc..ac56b545b4 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -331,6 +331,12 @@ def _eval_type(t, globalns, localns, 
recursive_guard=frozenset()):
 if isinstance(t, ForwardRef):
 return t._evaluate(globalns, localns, recursive_guard)
 if isinstance(t, (_GenericAlias, GenericAlias, types.UnionType)):
+if isinstance(t, GenericAlias):
+args = tuple(
+ForwardRef(arg) if isinstance(arg, str) else arg
+for arg in t.__args__
+)
+t = t.__origin__[(*args,)]
 ev_args = tuple(_eval_type(a, globalns, localns, recursive_guard) for 
a in t.__args__)
 if ev_args == t.__args__:
 return t


Testcase:


>>> from typing import get_type_hints, Mapping, List
>>> class N:
...  a: Mapping['str', List[list['N']]]
...
>>> get_type_hints(N)
{'a': typing.Mapping[str, typing.List[list[__main__.N]]]}


I believe that this would be enough, but then again I haven't yet had enough 
time to crack at other implications this might have.


> How will it interact with from __future__ import annotations?

I've never used this future, but from my current, possibly limited, 
understanding it should have no side effects on how `get_type_hints()` will 
evaluate fully stringified annotations (as you have already shown, a fully 
stringified type hint actually works fine with PEP 585 generics).


> And can we sell this as a bugfix for 3.10, or will this be a new feature in 
> 3.11?

I will throw in my personal opinion that this could be a bugfix, but I'm 
obviously biased as being on the "experiencing end" of this behaviour we're 
trying to change.

--

___
Python tracker 

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



[issue46525] datetime.timestamp() lose precision when the time is too large

2022-01-25 Thread Yilei Yang


New submission from Yilei Yang :

Examples:

>>> datetime.datetime(, 1, 1, microsecond=99).timestamp()
7952371200.99
>>> datetime.datetime(, 1, 1, microsecond=99).timestamp()
43012195201.0
>>> datetime.datetime(2567, 1, 1, microsecond=98).timestamp()
18839548800.96

I believe this is an issue caused by using `double` in the C implementation.

--
components: Library (Lib)
messages: 411676
nosy: yilei
priority: normal
severity: normal
status: open
title: datetime.timestamp() lose precision when the time is too large
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue46524] test_peg_generator takes 8 minutes on Windows

2022-01-25 Thread Tim Peters


Tim Peters  added the comment:

As a general thing, I expect people on Windows always run the tests with 
multiple processes. In which case it would be generally helpful to start the 
longest-running tests first. As is, because of its late-in-the-alphabet name, 
"test_peg_generator" gets started late in the process and so typically keeps 
running for minutes and minutes after all other tests have completed. So just 
renaming it to  "test_0peg_generator" would cut minutes off the Windows wall 
clock time ;-)

--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Here's a patch that doesn't do it right but illustrates the point:

diff --git a/Lib/typing.py b/Lib/typing.py
index 972b8ba24b..4616db60c3 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1807,6 +1807,12 @@ def get_type_hints(obj, globalns=None, localns=None, 
include_extras=False):
 value = type(None)
 if isinstance(value, str):
 value = ForwardRef(value, is_argument=False, is_class=True)
+elif isinstance(value, types.GenericAlias):
+args = tuple(
+ForwardRef(arg) if isinstance(arg, str) else args
+for arg in value.__args__
+)
+value = value.__origin__[(*args,)]
 value = _eval_type(value, base_globals, base_locals)
 hints[name] = value

--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Ah, I see the issue. I stepped through get_type_hints() using pdb, and it does 
have a special case for when it encounters a string: it wraps it in a 
ForwardRef and proceeds from there:

https://github.com/python/cpython/blob/cef0a5458f254c2f8536b928dee25862ca90ffa6/Lib/typing.py#L1806-L1807

But list['N'] isn't a string, so it doesn't trigger this case. If you were to 
use "list[N]" instead, it works:

>>> from typing import get_type_hints
>>> class N:
...   c: "list[N]"
... 
>>> get_type_hints(N)
{'c': list[__main__.N]}
>>>

But I suppose you have a reason you (or your users) don't want to do that.

We could probably add a special case where it checks for types.GenericAlias and 
goes through __args__, replacing strings by ForwardRefs.

But would that be enough? The algorithm would have to recursively dive into 
__args__ to see if there's a string hidden deep inside, e.g. list[tuple[int, 
list["N"]]].

And what if the user writes something hybrid, like List[list["N"]]? What other 
cases would we need to cover?

And can we sell this as a bugfix for 3.10, or will this be a new feature in 
3.11?

How will it interact with from __future__ import annotations?

--

___
Python tracker 

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



[issue46523] Test suite skips failing tests when setUp[Class] fails

2022-01-25 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue46524] test_peg_generator takes 8 minutes on Windows

2022-01-25 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

The test needs to build a lot of C extensions with different parsers, and that 
compilation is what takes most of the time.

I don't think we should skip these tests by default on Windows, as it gives us 
valuable information (that the parser features work compiled on windows).

If you have an idea on how to speed the tests, I'm all ears :)

--

___
Python tracker 

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



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

2022-01-25 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 8.0 -> 9.0
pull_requests: +29075
pull_request: https://github.com/python/cpython/pull/30894

___
Python tracker 

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



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

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4a57fa296b92125e41220ecd201eb2e432b79fb0 by Victor Stinner in 
branch '3.10':
[3.10] bpo-45382: test.pythoninfo logs more Windows versions (GH-30891)
https://github.com/python/cpython/commit/4a57fa296b92125e41220ecd201eb2e432b79fb0


--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

It was not my intention to sound passive agressive. Thanks for providing the 
context around the time PEP 585 was discussed.

Frankly, I believe I have explained the problem quite well. But I would like to 
propose a solution.

I can't judge in what circumstance a `str` would end up in 
`typing._GenericAlias.__args__` since `typing._GenericAlias.__getitem__()` 
converts strings to `typing.ForwardRef` using `_type_check()` immediately.

Assuming this is indeed a case to be taken into account, I would propose that 
`typing.get_type_hint()` implements special treatment for `types.GenericAlias` 
such that strings in `__args__` are treated as forward references, and keep the 
old behaviour for `typing._GenericAlias`. Do you see any problems with that?

Of course this would break cases that have come to strictly expect strings in 
PEP 585 generic `__args__` since the release of Python 3.10 to stay strings, 
although I cannot come up with an example or think of a usecase myself.

--

___
Python tracker 

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



[issue46520] `ast.unparse` produces syntactically illegal code for identifiers that look like reserved words

2022-01-25 Thread Nikita Sobolev

Nikita Sobolev  added the comment:

I can confirm that it happens on all versions from 3.9 to 3.11 (main).

```
Python 3.9.9 (main, Dec 21 2021, 11:35:28) 
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.unparse(ast.parse("핕핖핗 = 1"))
'def = 1'
>>> exec(ast.unparse(ast.parse("핕핖핗 = 1")))  # SyntaxError
```

```
Python 3.11.0a4+ (heads/main-dirty:ef3ef6fa43, Jan 20 2022, 20:48:25) [Clang 
11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.unparse(ast.parse("핕핖핗 = 1"))
'def = 1'
>>> exec(ast.unparse(ast.parse("핕핖핗 = 1")))  # SyntaxError
```

--
nosy: +sobolevn
versions: +Python 3.11, Python 3.9

___
Python tracker 

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



[issue46282] return value of builtins is not clearly indicated

2022-01-25 Thread James Gerity


James Gerity  added the comment:

My thought was to add something like this to the top of functions.rst:

```
Note that some of the functions listed here have the :ref:`default return value 
 of ``None``.
```

For reference, the builtins this applies to are:

* breakpoint()
* delattr()
* exec()
* help()
* print()
* setattr()

Which makes me wonder if the hint is even worth having, since it's so few of 
them.

Note that of these, exec() does what this ticket originally proposed for 
print() - i.e. it explicitly says that the function returns None.

--

___
Python tracker 

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



[issue46524] test_peg_generator takes 8 minutes on Windows

2022-01-25 Thread Tim Peters


Change by Tim Peters :


--
nosy: +tim.peters

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +sobolevn

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46420] Use NOTRACE_DISPATCH in specialized opcodes

2022-01-25 Thread Dennis Sweeney


Change by Dennis Sweeney :


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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

When PEP 585 was discussed and implemented we did not expect people to care as 
much about runtime types as they did.

I already explained that making list['Node'] incorporate a ForwardRef instance 
is unrealistic (we'd have to reimplement ForwardRef in C first).

It might be possible to change get_type_hints() to recognize strings, and 
deprecate ForwardRef altogether. But I suspect that that would break something 
else, since ForwardRef is documented (I had intended it to remain an internal 
detail but somehow it got exposed, I don't recall why).

Please stop asking why the decision was made (it sounds rather 
passive-aggressive to me) and start explaining the problem you are having in a 
way that we can actually start thinking about a solution.

I have boiled down the original example to a slightly simpler one (dataclasses 
are a red herring):

>>> from typing import get_type_hints, List
>>> class N:
...   c1: list["N"]
...   c2: List["N"]
...
>>> N.__annotations__
{'c1': list['N'], 'c2': typing.List[ForwardRef('N')]}
>>> get_type_hints(N)
{'c1': list['N'], 'c2': typing.List[__main__.N]}

The key problem here is that the annotation list['N'] is not expanded to 
list[N]. What can we do to make get_type_hint() produce list[N] instead here?

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

My audioop.c change which looks to be wrong (useless):

diff --git a/Modules/audioop.c b/Modules/audioop.c
index 3aeb6f04f13..4c04b17ce7f 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1948,6 +1941,13 @@ audioop_exec(PyObject* module)
 {
 audioop_state *state = get_audioop_state(module);
 
+if (!_Py_CTYPE_IS_SIGNED(char)) {
+PyErr_SetString(PyExc_RuntimeError,
+"the audioop module does not support systems "
+"where the char type is unsigned");
+return -1;
+}
+
 state->AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
 if (state->AudioopError == NULL) {
 return -1;

--

___
Python tracker 

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



[issue46214] Remove unused opcode ROT_FOUR

2022-01-25 Thread Irit Katriel


Change by Irit Katriel :


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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

To test if a C type is signed or not, I wrote this macro:

// Test if a C type is signed.
//
// Usage: assert(_Py_CTYPE_IS_SIGNED(char)); // fail if 'char' type is unsigned
#define _Py_CTYPE_IS_SIGNED(T) (((T)-1) < 0)

I planned to use it to raise an error on "import audioop" if the C "char" type 
is unsigned, but it seems like it's not needed, since the C extensions seems to 
work if char is signed or unsigned (I only read the C code, I didn't run 
test_audioop to actually test it).

--

___
Python tracker 

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



[issue46282] return value of builtins is not clearly indicated

2022-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Please post your proposed change here to be discussed by participants here.

--

___
Python tracker 

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



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

2022-01-25 Thread Alex Zaslavskis


Alex Zaslavskis  added the comment:

Thanks guys. Microsoft is always pain for us.
Bit wmic seems nice solution.
Is still working for windows lower than 11?

--

___
Python tracker 

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



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

2022-01-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29074
pull_request: https://github.com/python/cpython/pull/30891

___
Python tracker 

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



[issue46524] test_peg_generator takes 8 minutes on Windows

2022-01-25 Thread STINNER Victor


New submission from STINNER Victor :

test_peg_generator takes between 5 and 16 minutes on the Windows CI run on 
Python pull requests.

Example of timings on my PR https://github.com/python/cpython/pull/30890

* GitHub Action win32: 8 min 16 sec
* GitHub Action win64: 16 min 38 sec
* Azure Pipelines win32: 5 min 30 sec
* Azure Pipelines win64: 8 min 3 sec

Would it be possible to make these tests faster?

Or at least, would it be possible to skip these slow tests on Windows where 
spawing a process or running a C compiler is slower?

On my Fedora 35 (Linux) laptop, test_peg_generator takes 49.5 seconds. 
test_peg_generator only takes 736 ms if I disable TestCParser.

--
components: Tests
messages: 411662
nosy: lys.nikolaou, pablogsal, vstinner
priority: normal
severity: normal
status: open
title: test_peg_generator takes 8 minutes on Windows
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



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

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset cef0a5458f254c2f8536b928dee25862ca90ffa6 by Victor Stinner in 
branch 'main':
bpo-45382: test.pythoninfo: set wmic.exe encoding to OEM (GH-30890)
https://github.com/python/cpython/commit/cef0a5458f254c2f8536b928dee25862ca90ffa6


--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

You're right, let me trim it down:

In production we use `get_type_hints()` a lot, expecting it to resolve strings 
as forward references as per it's original API contract. However, PEP 585 
generics parametrized with strings in Python 3.10 doesn't work like that (as 
the documentation already points out). `get_type_hints()` itself does not fail, 
subsequently broke our code because it was not built to expect strings in 
`GenericAlias.__args__`.


What I ask myself is what motivated the decision to change the behaviour for 
PEP 585 generics in `get_type_hints()` and not go the extra mile.

--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



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

2022-01-25 Thread STINNER Victor

STINNER Victor  added the comment:

> When writing to a pipe, wmic.exe hard codes using the process OEM code page 
> (i.e. CP_OEMCP). If it matters, running wmic.exe with subprocess should use 
> encoding='oem' instead of text=True.

Oh ok, I wrote PR 30890 to fix the wmic.exe encoding.

I would prefer to avoid a named temporary file if possible, until it's really 
needed.

I'm only aware of the Fedora operating system which made fun of non-ASCII users 
once with "Fedora release 19 (Schrödinger's Cat)": 
https://lwn.net/Articles/545741/

--

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

I asked for a brief example that explains your issue to me. Instead you sent me 
links to production code and patches to it. Sorry, but that doesn't help me 
understand your problem. Is there really no way that you can write a little 
story that goes along the lines of

 In our production code, we use the pattern

   foo blah blah:
   spam spam Ham eggs anchovies
   buzz buzz blah get_type_hints buzz buzz

  a lot. As you can see, the get_type_hints call fails
  when we switch from "Ham eggs" to "ham eggs".

--

___
Python tracker 

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



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

2022-01-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +29073
pull_request: https://github.com/python/cpython/pull/30890

___
Python tracker 

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



[issue43976] Allow Python distributors to add custom site install schemes

2022-01-25 Thread Frederik Rietdijk


Frederik Rietdijk  added the comment:

In Nixpkgs we install every Python package under a unique prefix, a so-called 
Nix store path. If we were to use sysconfig for installing packages, then we'd 
need to be able to dynamically set the paths. This was also discussed as part 
of the Installer project. https://github.com/pradyunsg/installer/issues/98

We could use a custom scheme, however, we do need to be able to dynamically set 
a certain variable, e.g. `base`.

```
variables = {"installed_base": "$out", "base": "$out", "platbase": "$out", 
"installed_platbase": "$out"}
# Note there is no `sysconfig.get_default_scheme()`
sysconfig._expand_vars("posix_prefix", variables)
```

I could imagine we do something like

```
# check whether we're in a nix build and want to install in a prefix
if "IN_NIX_BUILD" in os.environ:
base = os.environ["out"]

scheme = {...}
```
We'd then need to update the base variable in sysconfig or partially expand our 
own scheme using this variable.

--
nosy: +Frederik Rietdijk

___
Python tracker 

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



[issue41370] PEP 585 and ForwardRef

2022-01-25 Thread Niklas Rosenstein


Niklas Rosenstein  added the comment:

Guido, sorry for the late response on this. I have a work around, but it 
involves passing along my own "context" from which to resolve strings on the go 
as they are encountered while decomposing the type hint.

https://github.com/NiklasRosenstein/databind/commit/960da61149b7139ec81b0e49d407fae321581914

I'm using `typing.get_type_hints()` expecting it to fully resolve all forward 
references, but that no longer happens with PEP 585 generics. 

https://github.com/NiklasRosenstein/databind/blob/960da61149b7139ec81b0e49d407fae321581914/databind.core/src/databind/core/types/utils.py#L129-L138

I understand the documentation has been updated to reflect this behaviour, but 
it was an issue for me because it broke it's original API contract.

> In addition, forward references encoded as string literals are handled by 
> evaluating them in globals and locals namespaces.

Arguably the same has happened when `include_extras` was added (Annotated was 
now stripped from the returned resolved type hints by default), but that had an 
easy fix by simply wrapping it with `include_extra=True` depending on the 
Python version. The fix for the forward references in PEP 585 was not so 
trivial because we can't hook into what `get_type_hints()` does when it 
encounters a string.

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Modules/audioop.c uses __CHAR_UNSIGNED__, but the absence or presence of the 
> symbol does not affect behavior

This comment is really weird since audioop explicitly uses "signed char" and 
"unsigned char". Maybe to avoid any risk of confusion, the C code should use 
int8_t and uint8_t.

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

Fedora downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2043555

We should make sure that Python can be built with -fsigned-char *and* with 
-funsigned-char: build Python, but also run its test suite.

--

___
Python tracker 

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



[issue46282] return value of builtins is not clearly indicated

2022-01-25 Thread James Gerity

James Gerity  added the comment:

> advertising that all functions default to returning None

This is already communicated in § 4.7 ("Defining Functions") of the official 
tutorial. 

I think it would be a good idea to revise that section so that this property of 
functions is a little more clear, but that isn't the scope of this ticket.

The title change reflects my intent to submit a PR that adds a hint to the 
builtins doc.

--

___
Python tracker 

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



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

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Regarding C extensions, I think clear documentation that extension authors 
> need to check for signals in any code that might run for a few hundred 
> microseconds or longer is the best approach.

Python 3.10 doesn't require it. If you want to change Python 3.11 behavior, 
please announce the change on python-dev and capi-sig mailing lists, and 
document it carefully in What's New in Python 3.11.

I'm not talking about checking frequently interruptions while a function is 
running, I'm only talking about the "end" of a C function (exit). In Python 
3.10, ceval.c does it automatically.

case TARGET(CALL_FUNCTION): {
PREDICTED(CALL_FUNCTION);
PyObject **sp, *res;
sp = stack_pointer;
res = call_function(tstate, _info, , oparg, NULL);
stack_pointer = sp;
PUSH(res);
if (res == NULL) {
goto error;
}
CHECK_EVAL_BREAKER();  // < HERE
DISPATCH();
}

--

___
Python tracker 

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



[issue33205] GROWTH_RATE prevents dict shrinking

2022-01-25 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue41682] [Windows] : Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> I'm sorry, Victor.

As a maintainer of the Python CIs, The Night's Watch (*), it's my fault that I 
didn't skip these tests earlier. Honestly, it's ok to skip a bunch of tests or 
even remove them if there is no active maintainer.

It's also ok that there is no active maintainer if existing tests continue to 
pass. asyncio is far from being an exception. Just look at test_nntplib: not 
maintained for 9 years, https://bugs.python.org/issue40735

This test failure got more attention since it started to fail even more 
frequently (always?) on Windows 2022.

(*) 
https://pythondev.readthedocs.io/ci.html#the-night-s-watch-is-fixing-the-cis-in-the-darkness-for-you

--

___
Python tracker 

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



[issue46510] Update Python2-style exception handling

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



[issue46510] Update Python2-style exception handling

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset ec7c17ea236f71c8376abcc2930a7c857d417966 by Irit Katriel in 
branch 'main':
bpo-46510: Add missing test for types.TracebackType/FrameType. Calculate them 
directly from the caught exception. (GH-30880)
https://github.com/python/cpython/commit/ec7c17ea236f71c8376abcc2930a7c857d417966


--

___
Python tracker 

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



[issue40735] test_nntplib depends on unreliable external servers

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

IMO for now it's better to *always* skip test_nnptlib tests which rely on 
external servers and close related issues.

* https://bugs.python.org/issue19613 (test_article_head_body)
* https://bugs.python.org/issue19756 (test_capabilities)

These issues are open for 9 years. NNTP protocol is getting less and less 
popular, I don't expect that anyone will come in 2022 and suddenly propose a 
fix.

--

___
Python tracker 

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



[issue46510] Update Python2-style exception handling

2022-01-25 Thread Irit Katriel


Irit Katriel  added the comment:


New changeset d69d3d8b2fec501e51309221fb1fa4622c8a3db3 by Irit Katriel in 
branch 'main':
bpo-46510: simplify exception handling code in xmlrpc (GH-30878)
https://github.com/python/cpython/commit/d69d3d8b2fec501e51309221fb1fa4622c8a3db3


--

___
Python tracker 

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



[issue5322] object.__new__ argument calling autodetection faulty

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

Python has the same behavior since Python 2.6. While it annoys a few persons, 
the majority doesn't care. I suggest to close the issue.

It's easy to workaround limitation that object.__new__() which doesn't accept 
arguments.

--

___
Python tracker 

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



[issue41682] [Windows] : Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

I'm sorry, Victor.

--

___
Python tracker 

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



[issue38195] A bug in the multiprocessing module

2022-01-25 Thread eshkrig


eshkrig  added the comment:

$ cat /etc/os-release
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo/Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/;
SUPPORT_URL="https://www.gentoo.org/support/;
BUG_REPORT_URL="https://bugs.gentoo.org/;

$ uname -a
Linux lynx 5.16.2-gentoo-1 #1 SMP PREEMPT Fri Jan 21 10:38:04 MSK 2022 x86_64 
AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux

$ python --version
Python 3.9.9

$ ./testqueue.py
queue.get() from pid 11371
queue.get() from pid 11372
^CTraceback (most recent call last):
  File "/home/john/main/123/./testqueue.py", line 45, in 
result = ps_queues[cpu].get(timeout=2)
  File "/usr/lib/python3.9/multiprocessing/queues.py", line 117, in get
res = self._recv_bytes()
  File "/usr/lib/python3.9/multiprocessing/connection.py", line 221, in 
recv_bytes
buf = self._recv_bytes(maxlength)
  File "/usr/lib/python3.9/multiprocessing/connection.py", line 426, in 
_recv_bytes
return self._recv(size)
  File "/usr/lib/python3.9/multiprocessing/connection.py", line 384, in _recv
chunk = read(handle, remaining)
KeyboardInterrupt

--
resolution: out of date -> 
status: closed -> open
versions: +Python 3.9 -Python 3.6

___
Python tracker 

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



[issue42982] Update suggested number of iterations for pbkdf2_hmac()

2022-01-25 Thread Alex Gaynor


Alex Gaynor  added the comment:

Sticking with 100k is not scientific though ;-) Empiricism is science!

I'm probably the person responsible for Django's process, which is to increase 
by some % (10% or 20% IIRC) every release.

As you point out, the exact value one should use is a function of context, 
which we don't have as documentation authors. However, what we can do is try to 
select a value that's most likely to be practical for many users and will 
in-turn protect their users data most. 100k isn't that value, and taking 
inspiration from places that have had their values tested by many users is 
intuitive to me.

--
nosy: +alex

___
Python tracker 

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



[issue41682] [Windows] : Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

This failing test was one of my most hated test because it failed randomly for 
almost 2 years. I'm happy that it has been fixed :-)

Regularly, I'm asking for help to fix test_asyncio:

* October 2020: 
https://mail.python.org/archives/list/python-...@python.org/message/Y7I5ADXAQEGK6DOFAPVDTKMBT6NUFNQ4/
* October 2019: 
https://mail.python.org/archives/list/python-...@python.org/message/R7X6NKGEOKWD3PBWIL2LPZWZ6MMRANN5/

Last years I gave up, since almost no one replied to my requests.

--
title: [Windows] test_asyncio: Proactor 
test_sendfile_close_peer_in_the_middle_of_receiving failure -> [Windows] : 
Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

___
Python tracker 

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



[issue42238] Deprecate suspicious.py?

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> It currently looks like this: https://github.com/JulienPalard/sphinxlint but 
> should obviously be moved to github.com/python/ if we adopt this direction.

If you want to move the project under the https://github.com/psf/ organization, 
the PSF has some rules to move a project in the Python organization. For 
example, contributors must respect the PSF Code of Conduct and the GitHub 
project must have at least 3 administrators. I forgot when I read these rule 
exactly. See for example https://github.com/psf/pyperf/

* https://github.com/psf/pyperf/blob/main/CODE_OF_CONDUCT.md
* README says "The pyperf project is covered by the PSF Code of Conduct."

--

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks Kumar for the fix!

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 75d88b91e6b1320ae0511eaf72e860bea913a3eb by Miss Islington (bot) 
in branch '3.10':
bpo-41682: fixed flaky test test_sendfile_close_peer_in_the_middle_of_receiving 
(GH-30845) (#30860)
https://github.com/python/cpython/commit/75d88b91e6b1320ae0511eaf72e860bea913a3eb


--

___
Python tracker 

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



[issue41682] [Windows] test_asyncio: Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f9ff0bf515e0fa162889aca508e755cc65d85079 by Miss Islington (bot) 
in branch '3.9':
bpo-41682: fixed flaky test test_sendfile_close_peer_in_the_middle_of_receiving 
(GH-30845) (#30861)
https://github.com/python/cpython/commit/f9ff0bf515e0fa162889aca508e755cc65d85079


--

___
Python tracker 

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



  1   2   3   >