This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Weird keyword parameter names in builtins
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, r.david.murray, rhettinger, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2017-03-02 14:54 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
deprecate-keyword-x.patch serhiy.storchaka, 2017-03-02 14:54 review
deprecate-keyword-sequence.patch serhiy.storchaka, 2017-03-02 14:54
deprecate-bad-keywords.patch serhiy.storchaka, 2017-03-02 16:05
remove-bad-keywords.patch serhiy.storchaka, 2017-03-06 06:54
Pull Requests
URL Status Linked Edit
PR 486 merged serhiy.storchaka, 2017-03-05 21:55
PR 518 merged serhiy.storchaka, 2017-03-06 14:34
PR 520 merged serhiy.storchaka, 2017-03-06 15:39
PR 703 larry, 2017-03-17 21:00
PR 552 closed dstufft, 2017-03-31 16:36
Messages (19)
msg288802 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 14:54
Proposed patches deprecate the "x" keyword parameter in int(), bool() and float() and the "sequence" keyword parameter in list() and tuple(). Name "x" is meaningless, and name "sequence" is misleading (any iterable is accepted, not just sequence). The documentation uses name "iterable" for list() and tuple().

It is never documented that any of these parameters are accepted by keywords. There was only a test for int(), but it was added just for increasing coverity, not to test intended behavior. Does this mean that the support of keyword arguments can be removed without deprecation?

The general idea got preliminary approval from Guido (https://mail.python.org/pipermail/python-ideas/2017-March/044959.html).
msg288803 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-03-02 14:59
I don't think we should do it without deprecation, since it could break working code.  But it certainly sounds like a marginal case: I doubt there is *much* code that uses the existing keyword names.
msg288804 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-03-02 15:09
R. David Murray added the comment:
> I don't think we should do it without deprecation, since it could break working code.  But it certainly sounds like a marginal case: I doubt there is *much* code that uses the existing keyword names.

I'm not sure that it's worth it to add a deprecation warning in Python
3.7. It's trivial to fix code passing an argument by keyword rather
than by position.
msg288805 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 15:12
Well, I was feeling the same, but asked just for the case.

Could you then look at deprecation messages? I'm sure that 'The "x" keyword argument of int() is deprecated' is not the best wording, and may be even ugly wording. Could you please suggest better wording David?

Patches don't document new deprecations because it is not documented that keyword arguments are supported either. Is mentioning in What's New enough?
msg288806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-03-02 15:22
"What's New in Python 3.7" has a section for such changes: "Porting to
Python 3.7: Changes to the Python API".
https://docs.python.org/dev/whatsnew/3.7.html#porting-to-python-3-7

Oh, I see that you already made a similar change but this one had a
deprecation period of 2 releases (3.5 and 3.6): "A format string
argument for string.Formatter.format() is now positional-only."

See also the positional-only arguments discussion on python-ideas:
* https://mail.python.org/pipermail/python-ideas/2017-February/044879.html
* https://mail.python.org/pipermail/python-ideas/2017-March/044956.html
msg288808 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-03-02 15:37
So these will become positional only?  In that case I'd say "Using 'x' as a keyword argument is deprecated; specify the value as a positional argument instead"
msg288809 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 15:42
See also issue20283. Obviously wrong keyword parameter names in regex methods were deprecated in 2.7, 3.3 and 3.4 and removed in 3.6.
msg288811 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 16:05
Thank you David! Updated warning messages for your suggestion and added entries in Misc/NEWS and What's New.
msg289052 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-03-05 23:32
I concur with Victor and Serhiy that we can bypass a deprecation phase here and just get it done.  In the rare case of int(x=3.14), the fix is trivial.
msg289067 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-06 06:54
I already merged the patch as 58d23e68068996c76cac78887ec67dee68cdbc72.

If you think that it would be better to remove without deprecation, the following patch does this.
msg289068 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-03-06 07:04
I do think it would be better to not have the deprecation.
msg289105 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-03-06 14:24
> If you think that it would be better to remove without deprecation, the following patch does this.

@Serhiy: Can you please create a PR for it?
msg289107 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-06 14:34
If David agrees with this.
msg289110 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-03-06 14:50
If Raymond is on the side of skipping the deprecation than I'm good with it.  Like I said, this is a marginal case.
msg289114 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-06 15:11
Thanks all!
msg289115 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-03-06 15:16
Unhappy buildbot.

http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.x/builds/456/steps/test/logs/stdio

======================================================================
ERROR: test_keyword_arguments (test.test_descr.ClassPropertiesAndMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_descr.py", line 3451, in test_keyword_arguments
    list.__init__(a, sequence=[0, 1, 2])
TypeError: list() does not take keyword arguments

======================================================================
ERROR: test_keywords (test.test_descr.ClassPropertiesAndMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_descr.py", line 2888, in test_keywords
    self.assertEqual(int(x=1), 1)
TypeError: 'x' is an invalid keyword argument for this function
msg290285 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2017-03-24 22:47
New changeset d908fd9ee1c307f7066023eb2031c0f509036cbc by Brett Cannon (Serhiy Storchaka) in branch 'master':
bpo-29695: Fixed tests after removing keyword args support in some basic type constructors. (GH-520)
https://github.com/python/cpython/commit/d908fd9ee1c307f7066023eb2031c0f509036cbc
msg290289 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:49
New changeset 2e5642422f6234fd8d0c082142b27340e588f96e by Serhiy Storchaka in branch 'master':
bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). (#518)
https://github.com/python/cpython/commit/2e5642422f6234fd8d0c082142b27340e588f96e
msg290294 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 22:53
New changeset 58d23e68068996c76cac78887ec67dee68cdbc72 by Serhiy Storchaka in branch 'master':
bpo-29695: Deprecated using bad named keyword arguments in builtings: (#486)
https://github.com/python/cpython/commit/58d23e68068996c76cac78887ec67dee68cdbc72
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73881
2017-03-31 16:36:09dstufftsetpull_requests: + pull_request847
2017-03-24 22:53:00serhiy.storchakasetmessages: + msg290294
2017-03-24 22:49:54serhiy.storchakasetmessages: + msg290289
2017-03-24 22:47:17brett.cannonsetnosy: + brett.cannon
messages: + msg290285
2017-03-17 21:00:33larrysetpull_requests: + pull_request589
2017-03-07 19:47:54serhiy.storchakasetstatus: open -> closed
resolution: fixed
2017-03-06 15:39:58serhiy.storchakasetpull_requests: + pull_request430
2017-03-06 15:16:04vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg289115
2017-03-06 15:11:25serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg289114

stage: patch review -> resolved
2017-03-06 14:50:45r.david.murraysetmessages: + msg289110
2017-03-06 14:34:51serhiy.storchakasetmessages: + msg289107
2017-03-06 14:34:05serhiy.storchakasetpull_requests: + pull_request428
2017-03-06 14:24:33vstinnersetmessages: + msg289105
2017-03-06 07:04:51rhettingersetmessages: + msg289068
2017-03-06 06:54:15serhiy.storchakasetfiles: + remove-bad-keywords.patch

messages: + msg289067
2017-03-05 23:32:41rhettingersetnosy: + rhettinger
messages: + msg289052
2017-03-05 21:55:08serhiy.storchakasetpull_requests: + pull_request399
2017-03-02 18:18:58gvanrossumsetnosy: - gvanrossum
2017-03-02 16:05:13serhiy.storchakasetfiles: + deprecate-bad-keywords.patch

messages: + msg288811
2017-03-02 15:42:41serhiy.storchakasetmessages: + msg288809
2017-03-02 15:37:54r.david.murraysetmessages: + msg288808
2017-03-02 15:22:25vstinnersetmessages: + msg288806
2017-03-02 15:12:40serhiy.storchakasetmessages: + msg288805
2017-03-02 15:09:58vstinnersetmessages: + msg288804
2017-03-02 14:59:22r.david.murraysetnosy: + r.david.murray
messages: + msg288803
2017-03-02 14:54:17serhiy.storchakasetfiles: + deprecate-keyword-sequence.patch
2017-03-02 14:54:04serhiy.storchakacreate