[issue43413] tuple subclasses allow arbitrary kwargs

2021-12-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset ad4857884b4821fc2c9bd23b63d03f9570eb03d1 by Serhiy Storchaka in 
branch 'main':
bpo-43413: Revert changes in set.__init__ (GH-28403)
https://github.com/python/cpython/commit/ad4857884b4821fc2c9bd23b63d03f9570eb03d1


--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-17 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Oh, and I see now Serhiy has proposed a change that looks reasonable.

--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-17 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

>> Subclass of set can now define
> Is there any use case for this?

Is your concern about a use-case for the general concept or for set 
specifically?

I appreciate that Serhiy has taken the time to evaluate the specific concern I 
raised and extrapolate it to the implications for most/all built-in types. It 
seems worthwhile to me that built-in types have consistent behaviors. Moreover, 
it seems preferable to provide the intuitive behavior (allowing simply 
overriding `__new__`) without the baggage of needing to define `__init__`. I'd 
not be surprised if there was a real-world use-case in which `set.__new__` was 
overridden in a subclass and the user was forced to add an `__init__` just to 
bypass "set() takes no keyword arguments". Interestingly, searching the web for 
that exact error doesn't emit any results, so if someone has encountered it, it 
wasn't posted with the error message.

After exploring this some, I'm convinced there may not be a strong case for 
this behavior.

Raymond, if this new behavior was removed, how would you propose to rewrite the 
test (specifically 
https://github.com/python/cpython/blob/778b07565e38cc94aa90318eb47b9cd09716756a/Lib/test/test_set.py#L665-L673)?

--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not have any particular use case. It was a side effect of unification code 
that uses _PyArg_NoKeywords().

--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26815
pull_request: https://github.com/python/cpython/pull/28403

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Subclass of set can now define a __new__() method with 
> additional keyword parameters without overriding also __init__().

Is there any use case for this?   Offhand, I can't think of any reason.

The new code in set.__init__ is somewhat opaque and is likely slower, so I 
prefer the previous code unless there is a legitimate use case being served.

--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-12 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-09-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 92bf8691fb78f3484bf2daba836c416efedb1d8d by Serhiy Storchaka in 
branch 'main':
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes 
(GH-26456)
https://github.com/python/cpython/commit/92bf8691fb78f3484bf2daba836c416efedb1d8d


--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +rhettinger

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Surprisingly there were almost no tests for keyword arguments in subclasses.

PR 26456 makes checks for some classes (like tuple, list, frozenset) more 
strict: if subclass does not define __init__ or __new__, it will reject 
arbitrary keyword arguments.

It also makes the check in set.__init__() more lenient for uniformity with 
frozenset and list. Subclass of set can now define a __new__() method with 
additional keyword parameters without overriding also __init__().

Added tests for some of builtin classes.

Raymond, please take a look. It touches classes maintained tracked by you: 
set/frozenset, itertools, random.

--

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-28 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
versions: +Python 3.11 -Python 3.10, 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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-27 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue43413] tuple subclasses allow arbitrary kwargs

2021-05-26 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
title: tuple subclasses allow kwargs -> tuple subclasses allow arbitrary kwargs

___
Python tracker 

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