[issue44721] Problem in tkinter button widget

2021-07-23 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> not a bug

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



[issue38291] Deprecate the typing.io and typing.re pseudo-modules

2021-07-23 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Currently deprecation warnings are emitted in test_typing:

$ ./python -m test test_typing
0:00:00 load avg: 3.38 Run tests sequentially
0:00:00 load avg: 3.38 [1/1] test_typing
/home/serhiy/py/cpython/Lib/test/test_typing.py:4657: DeprecationWarning: 
typing.io is deprecated, import directly from typing instead. typing.io will be 
removed in Python 3.12.
  k not in typing.io.__all__ and
/home/serhiy/py/cpython/Lib/test/test_typing.py:4658: DeprecationWarning: 
typing.re is deprecated, import directly from typing instead. typing.re will be 
removed in Python 3.12.
  k not in typing.re.__all__ and

== Tests result: SUCCESS ==

1 test OK.

Total duration: 564 ms
Tests result: SUCCESS

--
assignee: docs@python -> 
nosy: +serhiy.storchaka
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open

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



[issue44353] PEP 604 NewType

2021-07-23 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 27311 copies tests from PR 9951, adds support of nested NewTypes (with 
__qualname__ containing multiple components) an makes them pickleable by name 
as functions and classes.

--

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



[issue44353] PEP 604 NewType

2021-07-23 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25856
pull_request: https://github.com/python/cpython/pull/27311

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



[issue44353] PEP 604 NewType

2021-07-23 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

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



[issue43838] There is a way to access an underlying mapping in MappingProxyType

2021-07-23 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For __or__ we need to copy the content of both mapping to the resulting mapping 
in any case. We can implement it as {**self, **other}. We should not use the 
copy() method because it is not a part of the Mapping interface.

For __eq__, no copying is needed if we just re-implement Mapping.__eq__ (with 
special cases for few known types for performance).

--

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue44712.

--

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



[issue44712] Replace `type(literal)` with corresponding builtin types

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

All cases was manually checked several times (with months passes between 
checks). Several cases were preserved: when the name of built-in type 
conflicted with the name of function parameter (in weakref.py), when the code 
was used for testing type() and when the test code looks clearer with 
type(literal).

--

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



[issue44712] Replace `type(literal)` with corresponding builtin types

2021-07-22 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44712] Replace `type(literal)` with corresponding builtin types

2021-07-22 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are several occurrences of type(literal) in the code of the stdlib where 
literal is a literal of built-in type: '', 1, [], {}, etc. I suppose it is a 
remnants of very old code written when str, int, list, dict, etc were functions 
and not classes.

The proposed PR replaces `type(literal)` with corresponding builtin types. It 
makes the code cleaner.

I consider also idea of replacing identity or equality checks ("is" or "==") 
with isinstance(). I suppose that that code was written when built-in  types 
were not subclassable. But now there is a reason to use isinstance().

See also issue44711.

--
components: Library (Lib)
messages: 398002
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Replace `type(literal)` with corresponding builtin types
versions: Python 3.11

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



[issue44711] Optimize type check in pipes.py

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I suppose it is a very old code written when str was a function, not a type 
(thus using type('')) and builtin types were not subclassable (thus not using 
isinstance()).

I once analyzed other similar cases in the stdlib. Seems it is time to revive 
my old patch.

--
nosy: +serhiy.storchaka

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



[issue44707] runtime error: applying zero offset to null pointer in Objects/listobject.c

2021-07-22 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44707] runtime error: applying zero offset to null pointer in Objects/listobject.c

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

AFAIK pointer arithmetic with NULL has undefined behavior. There is similar 
case in list_slice().

--
components: +Interpreter Core
nosy: +mark.dickinson, serhiy.storchaka
type:  -> compile error
versions: +Python 3.10, Python 3.11, Python 3.9

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



[issue44710] Unexpected behavior in empty class with pass (Python 3.7.3)

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Because super().__init__(name, bases, nmspc) does not have any effect. Type is 
created by the metaclass' __new__ method, and the __init__ method is virtually 
no-op.

--
nosy: +serhiy.storchaka

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



[issue44706] UUID constructor should accept another UUID instance

2021-07-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a duplicate of issue32112.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Should uuid.UUID() accept another UUID() instance?

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is also problem with other typing types:

>>> (int | T)[typing.List]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Each union argument must be a type, got typing.List
>>> (int | T)[typing.List[int]]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Each union argument must be a type, got typing.List[int]
>>> (int | T)[typing.Hashable]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Each union argument must be a type, got typing.Hashable
>>> (int | T)[typing.Callable[[int], str]]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Each union argument must be a type, got typing.Callable[[int], str]
>>> (int | T)[typing.ParamSpec('P')]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Each union argument must be a type, got ~P

Despite the fact that they support the | operator.

We can add one by one special support of different types supporting the | 
operator (ParamSpec, _GenericAlias, _CallableGenericAlias, _UnionGenericAlias, 
_LiteralGenericAlias, _ConcatenateGenericAlias, _AnnotatedAlias, 
_SpecialGenericAlias, _CallableType, _TupleType), but it is cumbersome and 
errorprone. We will need to synchronize code of unionobject.c with typing every 
time we add new kind of types.

PR 27247 uses more general approach. It calls the | operator for arguments 
after substitution. So all types which support the | operator are now 
automatically supported. But the result of parameter substitution can now be 
typing.Union instead of types.Union.

>>> import typing
>>> import collections.abc
>>> T = typing.TypeVar('T')
>>> (int | T)[list]
int | list
>>> (int | T)[typing.List]
typing.Union[int, typing.List]
>>> (int | T)[list[int]]
int | list[int]
>>> (int | T)[typing.List[int]]
typing.Union[int, typing.List[int]]
>>> (int | T)[collections.abc.Hashable]
int | collections.abc.Hashable
>>> (int | T)[typing.Hashable]
typing.Union[int, typing.Hashable]
>>> (int | T)[collections.abc.Sequence[int]]
int | collections.abc.Sequence[int]
>>> (int | T)[typing.Sequence[int]]
typing.Union[int, typing.Sequence[int]]
>>> (int | T)[collections.abc.Callable[[int], str]]
int | collections.abc.Callable[[int], str]
>>> (int | T)[typing.Callable[[int], str]]
typing.Union[int, typing.Callable[[int], str]]
>>> (int | T)[typing.TypeVar('S')]
int | ~S
>>> (int | T)[typing.ParamSpec('P')]
typing.Union[int, ~P]
>>> (int | T)[str | list]
int | str | list
>>> (int | T)[typing.Union[str, list]]
typing.Union[int, str, list]

--

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25795
pull_request: https://github.com/python/cpython/pull/27247

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



[issue44668] More differences in instance and subclass checks between typing.Union and types.Union

2021-07-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is easy to fix once we define the correct behavior in corner cases.

--

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



[issue44668] More differences in instance and subclass checks between typing.Union and types.Union

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
components: +Library (Lib)
type:  -> behavior
versions: +Python 3.10, Python 3.11

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



[issue44668] More differences in instance and subclass checks between typing.Union and types.Union

2021-07-18 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

1. Checks for types.Union ignore any non-type args. Checks for typing.Union 
require fail on first checked non-type (but it can short circuit).

>>> import typing
>>> T = typing.TypeVar('T')
>>> issubclass(int, int | T | str)
True
>>> issubclass(int, str | T | int)
True
>>> issubclass(int, typing.Union[int, T, str])
True
>>> issubclass(int, typing.Union[str, T, int])
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/typing.py", line 1208, in __subclasscheck__
if issubclass(cls, arg):
   
TypeError: issubclass() arg 2 must be a class, a tuple of classes, or a union.
>>> isinstance(1, int | T | str)
True
>>> isinstance(1, str | T | int)
True
>>> isinstance(1, typing.Union[int, T, str])
True
>>> isinstance(1, typing.Union[str, T, int])
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/typing.py", line 1204, in __instancecheck__
return self.__subclasscheck__(type(obj))
   ^
  File "/home/serhiy/py/cpython/Lib/typing.py", line 1208, in __subclasscheck__
if issubclass(cls, arg):
   
TypeError: issubclass() arg 2 must be a class, a tuple of classes, or a union.

2. __instancecheck__ of typing.Union uses __subclasscheck__ of args instead of 
__instancecheck__. In normal cases the result should be the same, but there 
should be a reason of having two different special methods.

--
messages: 397757
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: More differences in instance and subclass checks between typing.Union 
and types.Union

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25780
pull_request: https://github.com/python/cpython/pull/27232

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests:  -25757

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



[issue44654] Refactor and clean up the union type implementation

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44654] Refactor and clean up the union type implementation

2021-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a6670cdf77aab2b1ee7be0b9df060dcac2a2dc48 by Serhiy Storchaka in 
branch '3.10':
[3.10] bpo-44654: Do not export the union type related symbols (GH-27223). 
(GH-27225)
https://github.com/python/cpython/commit/a6670cdf77aab2b1ee7be0b9df060dcac2a2dc48


--

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44654] Refactor and clean up the union type implementation

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25766
pull_request: https://github.com/python/cpython/pull/27225

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



[issue44654] Refactor and clean up the union type implementation

2021-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 8f50f44592190b5a8cb115f0d58d577036e68308 by Serhiy Storchaka in 
branch 'main':
bpo-44654: Do not export the union type related symbols (GH-27223)
https://github.com/python/cpython/commit/8f50f44592190b5a8cb115f0d58d577036e68308


--

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 85b58292cf94de74d028053ac33a65f269f305cb by Miss Islington (bot) 
in branch '3.10':
bpo-44633: Fix parameter substitution of the union type with wrong types. 
(GH-27218) (GH-27224)
https://github.com/python/cpython/commit/85b58292cf94de74d028053ac33a65f269f305cb


--

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



[issue44664] builtins.chr and the 'c' format flag raise different errors

2021-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Is there any example where it causes troubles?

--
nosy: +serhiy.storchaka

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 3ea5332a4365bdd771286b3e9692495116e9ceef by Serhiy Storchaka in 
branch 'main':
bpo-44633: Fix parameter substitution of the union type with wrong types. 
(GH-27218)
https://github.com/python/cpython/commit/3ea5332a4365bdd771286b3e9692495116e9ceef


--

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



[issue44654] Refactor and clean up the union type implementation

2021-07-18 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25764
pull_request: https://github.com/python/cpython/pull/27223

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



[issue44654] Refactor and clean up the union type implementation

2021-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 03aad3049d1591c76a219dfe089e5367f88f167e by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-44654: Refactor and clean up the union type implementation 
(GH-27196) (GH-27219)
https://github.com/python/cpython/commit/03aad3049d1591c76a219dfe089e5367f88f167e


--

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



[issue44654] Refactor and clean up the union type implementation

2021-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0fd27375cabd12e68a2f12cfeca11a2d5043429e by Serhiy Storchaka in 
branch 'main':
bpo-44654: Refactor and clean up the union type implementation (GH-27196)
https://github.com/python/cpython/commit/0fd27375cabd12e68a2f12cfeca11a2d5043429e


--

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



[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 2d055ce13250a4074f66a945381a149a3cf8c46f by Serhiy Storchaka in 
branch '3.10':
[3.10] bpo-44490: Add __parameters__ and __getitem__ to types.Union (GH-26980) 
(GH-27207)
https://github.com/python/cpython/commit/2d055ce13250a4074f66a945381a149a3cf8c46f


--

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests:  -25756

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25759
pull_request: https://github.com/python/cpython/pull/27218

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests:  -25744

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests:  -25745

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



[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka
nosy_count: 8.0 -> 9.0
pull_requests: +25743
pull_request: https://github.com/python/cpython/pull/27207

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



[issue44659] Remove Ivan from list of typing experts

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Remove Ivan from list of,typing experts -> Remove Ivan from list of 
typing experts

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



[issue44654] Refactor and clean up the union type implementation

2021-07-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> Yeah I noticed it re-lookups __module__ unnecessarily multiple times for the 
> same type.

Actually I thought about this change, but did not implement it. Because it does 
not look performance critical, and future versions will likely do different 
tests (for example, testing the existence of special attribute, or check 
against lazily imported and cached classes from the typing module). Also, the 
test for TypeVar can be shared between genericaliasobject.c and unionobject.c.

It is mostly simple clean up, a line here, two lines there. 
genericaliasobject.c and unionobject.c could be merged in a single file, 
because they share several functions not used anywhere more. We perhaps merge 
them if more C implementations for typing be added in future.

--

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



[issue44654] Refactor and clean up the union type implementation

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44654] Refactor and clean up the union type implementation

2021-07-16 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

I started reviewing and rewriting Objects/unionobject.c several weeks ago. Some 
discovered bugs were reported and fixed in separate issues: issue44606, 
issue44632, issue44635, issue44636, issue44646, issue44652. Before fixing the 
remaining bugs (issue44633, issue44642, issue44653) I want to merge some minor 
changes:

* Rename _Py_UnionType to _PyUnion_Type. It is how PyTypeObject instances are 
named.
* Add _PyUnion_Check() and _PyGenericAlias_Check(). It simplified the code.
* Do not expose _Py_Union(). It is only used locally.
* Move declarations of _Py_make_parameters and _Py_subs_parameters from 
genericaliasobject.h to internal/pycore_unionobject.h. They are for internal 
use only.
* Fix a possible leak in dedup_and_flatten_args().
* Significantly simplify union_richcompare(). The Python implementation can be 
used for comparing types.Union with typing.Union.
* Perform cheaper tests before more expensive tests in is_unionable().
* Optimize __module__ look up in is_typing_module() and support types without 
__module__.
* Fix outdated comments.
* Minor style fixes.
* Extract related tests to separate class.
* Make some tests more accurate: they should test for TypeError only specific 
operators, not constructors.

I am going to backport these changes to 3.10 to make backporting of future 
fixes easier.

--
components: Interpreter Core
messages: 397635
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refactor and clean up the union type implementation
versions: Python 3.10, Python 3.11

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Expected raising a TypeError.

--

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



[issue44653] Parameter substitution in the union type does not work with typing.Union

2021-07-16 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

>>> import typing
>>> T = typing.TypeVar('T')
>>> (int | T)[typing.Union[str, list]]
NotImplemented

See also issue44633. But in this case the expected result is int | str | list 
or typing.Union[init, str, list].

--
components: Interpreter Core
messages: 397624
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Parameter substitution in the union type does not work with typing.Union
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44652] Preserve natural order of args in the union type

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25726
pull_request: https://github.com/python/cpython/pull/27190

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



[issue44652] Preserve natural order of args in the union type

2021-07-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0cd2d51aadcd2a0c0739a5df0a6235d64f35619e by Serhiy Storchaka in 
branch 'main':
bpo-44652: Preserve natural order of args in the union type. (GH-27185)
https://github.com/python/cpython/commit/0cd2d51aadcd2a0c0739a5df0a6235d64f35619e


--

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



[issue44636] It is possible to create a 1-type union type

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44636] It is possible to create a 1-type union type

2021-07-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset c3007ab3c6cb384203bac8aa64d89c4b42f671a1 by Serhiy Storchaka in 
branch '3.10':
[3.10] bpo-44636: Collapse union of equal types (GH-27178) (GH-27181)
https://github.com/python/cpython/commit/c3007ab3c6cb384203bac8aa64d89c4b42f671a1


--

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



[issue44652] Preserve natural order of args in the union type

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44652] Preserve natural order of args in the union type

2021-07-16 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There are two issues related to the order of __args__ in typing.Union and the 
union type.

1. Indexing typing.Union preserves the order of arguments, but it is not always 
true when use the | operator.

>>> A = typing.NewType('A', str)
>>> typing.Union[typing.List[int], A]
typing.Union[typing.List[int], A]
>>> typing.Union[A, typing.List[int]]
typing.Union[A, typing.List[int]]
>>> typing.List[int] | A
typing.Union[typing.List[int], A]
>>> A | typing.List[int]
typing.Union[typing.List[int], A]

The cause is errors in __ror__ implementations.

2. There is a difference between deduplication algorithms for typing.Union and 
the union type.

>>> typing.Union[int, str, int]
typing.Union[int, str]
>>> int | str | int
str | int

It is not particularly important, because the order of __args__ mostly affects 
only representation. But it is better to be consistent, and it is easy to fix 
these tiny issues.

Note that it does not make the order of __args__ deterministic in all cases. 
Due to using caching for typing.Union it can be not always preserved if we 
merger typing.Union objects which differs only by order of arguments.

>>> import typing
>>> typing.Union[typing.Union[int, str], list]
typing.Union[int, str, list]
>>> typing.Union[typing.Union[str, int], list]
typing.Union[int, str, list]

--
components: Interpreter Core, Library (Lib)
messages: 397612
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Preserve natural order of args in the union type
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44636] It is possible to create a 1-type union type

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25718
pull_request: https://github.com/python/cpython/pull/27181

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



[issue44636] It is possible to create a 1-type union type

2021-07-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset d9f923280f204204f8703756aef4f655b579b4b8 by Serhiy Storchaka in 
branch 'main':
bpo-44636: Collapse union of equal types (GH-27178)
https://github.com/python/cpython/commit/d9f923280f204204f8703756aef4f655b579b4b8


--

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



[issue44646] hash() of the unity type is not consistent with equality

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44636] It is possible to create a 1-type union type

2021-07-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44651] An unclear definition in Doc/glossary.rst

2021-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +mark.dickinson

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



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

2021-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is only reminder that our test for NewType is arbitrary. And it is not 
compatible with PR 9951. Possible solutions are:

1. Make NewType a class and add more strict test. Pro -- we can make arbitrary 
repr, contra -- it has small negative effect on performance. See issue34963.

2. Remove the test for NewType at all and allow or-ing types and arbitrary 
functions.

3. Introduce a special attribute to distinguish unionable objects. It will make 
the code of unionobject.c simpler.

I lean towards option 1 (not excluding 3). Small performance losses seem 
inevitable.

--

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



[issue44646] hash() of the unity type is not consistent with equality

2021-07-15 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a rule: equal hashable objects should have the same hash. The unity 
type violates it.

>>> x = int | str
>>> y = str | int
>>> x == y
True
>>> hash(x) == hash(y)
False

And hashes of equal unity type and typing.Union are different too.

>>> import typing
>>> z = typing.Union[int, str]
>>> x == z
True
>>> hash(x) == hash(z)
False

There is also a problem with a single type (see issue44636).

--
components: Interpreter Core
messages: 397567
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: hash() of the unity type is not consistent with equality
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44636] It is possible to create a 1-type union type

2021-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a difference with typing.Union which can cause confusion. If the union 
type is like a tuple and we leave a 1-type union, why do we bother with 
deduplication? Why int | str | int is collapsed into int | str?

Also it complicates the comparison implementation and produces surprising 
exceptions:

>>> int | str == {}
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unhashable type: 'dict'

Also it breaks one of fundamental properties -- equal objects should have equal 
hashes.

>>> (int | int) == int
True
>>> hash(int | int) == hash(int)
False

--

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



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

2021-07-15 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The union type accepts any function from the typing module:

>>> import typing
>>> int | typing.cast
int | typing.cast
>>> int | typing.get_type_hints
int | typing.get_type_hints

It is a consequence of too lenient check for the typing.NewType() result (which 
does not work at all with PR 9951).

--
components: Interpreter Core
messages: 397528
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Union of a type and the typing module function
versions: Python 3.10, Python 3.11

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



[issue44636] It is possible to create a 1-type union type

2021-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Simple example (without indexing):

>>> import typing
>>> typing.Union[int, int]

>>> int | int
int

--

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



[issue44632] Union with TypeVar does not work as intended

2021-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44632] Union with TypeVar does not work as intended

2021-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset cc1a47c849a206441c9b370b6ca954862a523082 by Miss Islington (bot) 
in branch '3.10':
bpo-44632: Fix support of TypeVar in the union type (GH-27139) (GH-27143)
https://github.com/python/cpython/commit/cc1a47c849a206441c9b370b6ca954862a523082


--

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 6dec5255829a31826990ea40ca106cc496570df2 by Serhiy Storchaka in 
branch '3.10':
[3.10] bpo-44635: Convert None to NoneType in the union type constructor 
(GH-27136). (GH-27142)
https://github.com/python/cpython/commit/6dec5255829a31826990ea40ca106cc496570df2


--

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



[issue44632] Union with TypeVar does not work as intended

2021-07-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a158b20019b50e3ece6e4743ec4e6ae8d818b690 by Serhiy Storchaka in 
branch 'main':
bpo-44632: Fix support of TypeVar in the union type (GH-27139)
https://github.com/python/cpython/commit/a158b20019b50e3ece6e4743ec4e6ae8d818b690


--

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +25684
pull_request: https://github.com/python/cpython/pull/27142

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset b81cac05606c84958b52ada09f690463a3c7e949 by Serhiy Storchaka in 
branch 'main':
bpo-44635: Convert None to NoneType in the union type constructor (GH-27136)
https://github.com/python/cpython/commit/b81cac05606c84958b52ada09f690463a3c7e949


--

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



[issue44632] Union with TypeVar does not work as intended

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44632] Union with TypeVar does not work as intended

2021-07-14 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Good question. It works correctly in list[T]. There is a tiny difference 
between implementations of the check in genericaliasobject.c and unionobject.c.

--

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
dependencies: +Union with TypeVar does not work as intended

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



[issue44636] It is possible to create a 1-type union type

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
dependencies: +Union with TypeVar does not work as intended

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



[issue44636] It is possible to create a 1-type union type

2021-07-14 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

typing.Union always collapsed to a simple type if it contains a single type.

>>> import typing
>>> typing.Union[int, typing.T][int]


But the builtin union type can contain a single type:

>>> (int | typing.T)[int]
int
>>> type((int | typing.T)[int])


--
components: Interpreter Core
messages: 397476
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: It is possible to create a 1-type union type
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-14 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +gvanrossum, kj

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



[issue44635] Convert None to NoneType in the union type constructor

2021-07-14 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a difference between typing.Union and the builtin union type in 
representing None in __args__:

>>> import typing
>>> typing.Union[int, None].__args__
(, )
>>> typing.Union[int, type(None)].__args__
(, )
>>> (int | None).__args__
(, None)
>>> (int | type(None)).__args__
(, )

The former converts None to NoneType, the latter leaves it as is, and only 
performs conversion in __instancecheck__ and __subclasscheck__. In the 
discussion for issue44606 it was proposed to convert None to NoneType in the 
union type constructor to make more uniform with typing.Union and simplify 
__instancecheck__ and __subclasscheck__.

--
components: Interpreter Core
messages: 397475
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Convert None to NoneType in the union type constructor
type: enhancement
versions: Python 3.10, Python 3.11

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



[issue44608] Memory use increase in function _tkinter._flatten

2021-07-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44633] Indexing the union type can return NotImplemented

2021-07-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

>>> import typing
>>> (int | typing.T)[1]
NotImplemented

It is related to issue44632.

--
components: Interpreter Core
messages: 397468
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Indexing the union type can return NotImplemented
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44632] Union with TypeVar does not work as intended

2021-07-13 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

>>> import typing
>>> int | typing.T
int | ~T
>>> typing.T | int
typing.Union[~T, int]
>>> T2 = TypeVar('T2')
>>> int | T2
typing.Union[int, ~T2]
>>> T2 | int
typing.Union[~T2, int]

There is a support of TypeVar in type.__or__, but it does not work with user 
defined TypeVars, only with internal TypeVars defined in the typing module.

--
components: Interpreter Core
messages: 397466
nosy: gvanrossum, kj, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Union with TypeVar does not work as intended
type: behavior
versions: Python 3.10, Python 3.11

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44608] Memory use increase in function _tkinter._flatten

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f572cbf1faab33d9afbbe3e95738ed6fbe6e48e6 by Serhiy Storchaka in 
branch 'main':
bpo-44608: Fix memory leak in _tkinter._flatten() (GH-27107)
https://github.com/python/cpython/commit/f572cbf1faab33d9afbbe3e95738ed6fbe6e48e6


--

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 81989058de381108dfd0a4255b93d4fb34417002 by Serhiy Storchaka in 
branch 'main':
bpo-44606: Fix __instancecheck__ and __subclasscheck__ for the union type. 
(GH-27120)
https://github.com/python/cpython/commit/81989058de381108dfd0a4255b93d4fb34417002


--

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 27120 fixes __instancecheck__ and __subclasscheck__. Converting None to 
type(None) will be done in other PR.

--

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
type: behavior -> crash

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

3. There is also a crash in isinstance():

>>> class BadMeta(type):
... def __instancecheck__(cls, inst):
... 1/0
... 
>>> x = int | BadMeta('A', (), {})
>>> isinstance([], x)
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with 
an exception set
Python runtime state: initialized
Traceback (most recent call last):
  File "", line 3, in __instancecheck__
ZeroDivisionError: division by zero

The above exception was the direct cause of the following exception:

SystemError:  returned a result with an exception set

Current thread 0x7f024beb1280 (most recent call first):
  File "", line 1 in 
Aborted (core dumped)

--

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I have found this when refactored the code of Objects/unionobject.c. So I have 
a patch which fixes this, but I want to make sure what behavior is considered 
correct.

--

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



[issue44608] Memory use increase in function _tkinter._flatten

2021-07-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your report stardust222. Indeed, there is a leak if an argument 
is a sequence or set, but not list or tuple. PR 27107 fixes it.

--
components: +Extension Modules -C API, Tkinter
versions: +Python 3.10, Python 3.11

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



[issue44608] Memory use increase in function _tkinter._flatten

2021-07-13 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
nosy: +serhiy.storchaka
nosy_count: 1.0 -> 2.0
pull_requests: +25652
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27107

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



[issue44607] Teleport method for turtle class

2021-07-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What other Turtle implementations support the teleport command?

--
nosy: +serhiy.storchaka

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



[issue44606] Discrepancy between isinstance() and issubclass() for union types

2021-07-11 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

1. Different handling of None:

>>> isinstance(None, int | type(None))
True
>>> issubclass(type(None), int | type(None))
True
>>> isinstance(None, int | None)
True
>>> issubclass(type(None), int | None)
False

2. Different handling of virtual subclasses:

>>> import collections.abc
>>> isinstance({}, int | collections.abc.Mapping)
True
>>> issubclass(dict, int | collections.abc.Mapping)
False

I do not know what behavior is correct.

--
components: Interpreter Core
messages: 397281
nosy: gvanrossum, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Discrepancy between isinstance() and issubclass() for union types
type: behavior
versions: Python 3.10, Python 3.11

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



[issue43838] There is a way to access an underlying mapping in MappingProxyType

2021-07-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Example of modifying a builtin type:

>>> class Sneaky:
... def __eq__(self, other):
... other['real'] = 42
... 
>>> int.__dict__ == Sneaky()
>>> (1).real
42

But it can also lead to crash (due to outdated type cache):

>>> class Sneaky:
... def __eq__(self, other):
... other['bit_length'] = 42
... 
>>> int.__dict__ == Sneaky()
>>> (1).bit_length
Segmentation fault (core dumped)

--

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



[issue44596] Operand coercion breaks MappingProxyType encapsulation

2021-07-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a duplicate of issue43838.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> There is a way to access an underlying mapping in 
MappingProxyType

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



[issue34550] UnicodeDecodeError when invoke method configure() of Menu instance

2021-07-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> out of date
stage:  -> resolved
status: pending -> closed

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



[issue44592] tkinter focus_get() with non-tkinter Tk widget

2021-07-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a duplicate of issue734176.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Make Tkinter.py's nametowidget work with cloned menu widgets

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



[issue44571] itertools: takedowhile()

2021-07-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For convenience, the takewhile iterator can also have additional attributes: a 
boolean attribute which indicates that the falsifying element is set, and 
dynamic attribute which is equal to orig_iterator or chain([odd_element], 
orig_iterator).

--

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



[issue42778] Add follow_symlinks=True parameter to both os.path.samefile() and Path.samefile()

2021-07-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue42778>
___
___
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-07-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

On other hand, there are classes which define __int__ but not __trunc__: UUID 
and IP4Address. So it makes sense to keep separate __int__ and __trunc__.

--

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



[issue44571] itertools: takedowhile()

2021-07-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What if set the last item as an attribute of the takewhile iterator?

--
nosy: +serhiy.storchaka

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



[issue44562] types.GenericAlias should decref instead of using delete in tp_new

2021-07-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

AFAIK PyType_GenericAlloc is used indirectly in ga_new(), but not in 
Py_GenericAlias().

--

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



  1   2   3   4   5   6   7   8   9   10   >