GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-96751: Remove dead code from `CALL_FUNCTION_EX` opcode (GH-96752) · python/cpython@e37ac5f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • test_extcall.py
  • Misc/NEWS.d/next/Core and Builtins
    • 2022-09-11-12-43-43.gh-issue-96751.anRT6a.rst
  • Python
    • ceval.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_extcall.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_extcall.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,27 @@
382382
...
383383
TypeError: test.test_extcall.g() got multiple values for keyword argument 'x'
384384
385+
Call with dict subtype:
386+
387+
>>> class MyDict(dict):
388+
... pass
389+
390+
>>> def s1(**kwargs):
391+
... return kwargs
392+
>>> def s2(*args, **kwargs):
393+
... return (args, kwargs)
394+
>>> def s3(*, n, **kwargs):
395+
... return (n, kwargs)
396+
397+
>>> md = MyDict({'a': 1, 'b': 2})
398+
>>> assert s1(**md) == {'a': 1, 'b': 2}
399+
>>> assert s2(*(1, 2), **md) == ((1, 2), {'a': 1, 'b': 2})
400+
>>> assert s3(**MyDict({'n': 1, 'b': 2})) == (1, {'b': 2})
401+
>>> s3(**md)
402+
Traceback (most recent call last):
403+
...
404+
TypeError: s3() missing 1 required keyword-only argument: 'n'
405+
385406
Another helper function
386407
387408
>>> def f2(*a, **b):
Collapse file

‎Misc/NEWS.d/next/Core and Builtins/2022-09-11-12-43-43.gh-issue-96751.anRT6a.rst‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove dead code from ``CALL_FUNCTION_EX`` opcode.
Collapse file

‎Python/ceval.c‎

Copy file name to clipboardExpand all lines: Python/ceval.c
+2-13Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,19 +4716,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
47164716
PyObject *func, *callargs, *kwargs = NULL, *result;
47174717
if (oparg & 0x01) {
47184718
kwargs = POP();
4719-
if (!PyDict_CheckExact(kwargs)) {
4720-
PyObject *d = PyDict_New();
4721-
if (d == NULL)
4722-
goto error;
4723-
if (_PyDict_MergeEx(d, kwargs, 2) < 0) {
4724-
Py_DECREF(d);
4725-
format_kwargs_error(tstate, SECOND(), kwargs);
4726-
Py_DECREF(kwargs);
4727-
goto error;
4728-
}
4729-
Py_DECREF(kwargs);
4730-
kwargs = d;
4731-
}
4719+
// DICT_MERGE is called before this opcode if there are kwargs.
4720+
// It converts all dict subtypes in kwargs into regular dicts.
47324721
assert(PyDict_CheckExact(kwargs));
47334722
}
47344723
callargs = POP();

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.