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: CALL_FUNCTION_KW opcode: keyword names must be non-empty
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, jdemeyer, petr.viktorin, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2019-05-16 09:21 by jdemeyer, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13357 closed jdemeyer, 2019-05-16 09:28
Messages (6)
msg342631 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-05-16 09:21
Document and add an assertion that the "keyword names" tuple of the CALL_FUNCTION_KW opcode must be non-empty. This is already the case with the current compiler: if there are no keyword arguments in a call, then the CALL_FUNCTION_KW opcode is not used.

In light of https://github.com/python/peps/pull/1049 it's good to make this an explicit guarantee.
msg342636 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-05-16 10:22
What happens when pass an empty tuple?
msg342638 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-05-16 10:37
> What happens when pass an empty tuple?

The way how bytecode is compiled, that doesn't actually happen so it's an entirely hypothetical question.

The various XXX_FastCallKeywords functions seem to allow passing an empty tuple to mean "no keyword arguments", so I guess that nothing breaks when you would actually pass an empty tuple
msg342640 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-05-16 11:28
Then I do not see a reason to add an assertion.
msg342641 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-05-16 11:41
Adding that assertion allows future optimizations and simplifications: with the assertion, "keyword arguments are passed" becomes equivalent to

  kwnames != NULL

instead of

  kwnames != NULL && PyTuple_GET_SIZE(kwnames) > 0

This may not be useful right now, but it will become more useful when implementing PEP 590.
msg343181 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-05-22 11:46
Closing per discussion in https://github.com/python/cpython/pull/13357
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81117
2019-05-22 11:46:56petr.viktorinsetstatus: open -> closed
resolution: not a bug
messages: + msg343181

stage: patch review -> resolved
2019-05-16 11:41:54jdemeyersetmessages: + msg342641
2019-05-16 11:28:00serhiy.storchakasetmessages: + msg342640
2019-05-16 10:37:23jdemeyersetmessages: + msg342638
2019-05-16 10:22:30serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg342636
2019-05-16 09:28:04jdemeyersetkeywords: + patch
stage: patch review
pull_requests: + pull_request13266
2019-05-16 09:21:33jdemeyercreate