Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 6 Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -880,16 +880,16 @@ All of the following opcodes use their arguments.
.. versionadded:: 3.9


.. opcode:: DICT_UPDATE (i)
.. opcode:: DICT_UPDATE

Calls ``dict.update(TOS1[-i], TOS)``. Used to build dicts.
Calls ``dict.update(TOS1, TOS)``. Used to build dicts.

.. versionadded:: 3.9


.. opcode:: DICT_MERGE

Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys.
Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys.

.. versionadded:: 3.9

Expand Down
4 changes: 2 additions & 2 deletions 4 Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion 3 Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def _write_atomic(path, data, mode=0o666):
# Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156)
# Python 3.9a2 3424 (simplify bytecodes for *value unpacking)
# Python 3.9a2 3425 (simplify bytecodes for **value unpacking)
# Python 3.9a3 3426 (further simplify bytecodes for **value unpacking)

#
# MAGIC must change whenever the bytecode emitted by the compiler may no
Expand All @@ -286,7 +287,7 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3425).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3426).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

_PYCACHE = '__pycache__'
Expand Down
5 changes: 2 additions & 3 deletions 5 Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def jabs_op(name, op):
def_op('INPLACE_AND', 77)
def_op('INPLACE_XOR', 78)
def_op('INPLACE_OR', 79)

def_op('DICT_MERGE', 80)
def_op('DICT_UPDATE', 81)
def_op('LIST_TO_TUPLE', 82)
def_op('RETURN_VALUE', 83)
def_op('IMPORT_STAR', 84)
Expand Down Expand Up @@ -211,7 +212,5 @@ def jabs_op(name, op):

def_op('LIST_EXTEND', 162)
def_op('SET_UPDATE', 163)
def_op('DICT_MERGE', 164)
def_op('DICT_UPDATE', 165)

del def_op, name_op, jrel_op, jabs_op
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't use an oparg for ``DICT_MERGE`` and ``DICT_UPDATE`` opcodes.
6 changes: 3 additions & 3 deletions 6 Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)

case TARGET(DICT_UPDATE): {
PyObject *update = POP();
PyObject *dict = PEEK(oparg);
PyObject *dict = TOP();
if (PyDict_Update(dict, update) < 0) {
if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
_PyErr_Format(tstate, PyExc_TypeError,
Expand All @@ -2819,10 +2819,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)

case TARGET(DICT_MERGE): {
PyObject *update = POP();
PyObject *dict = PEEK(oparg);
PyObject *dict = TOP();

if (_PyDict_MergeEx(dict, update, 2) < 0) {
format_kwargs_error(tstate, PEEK(2 + oparg), update);
format_kwargs_error(tstate, PEEK(3), update);
Py_DECREF(update);
goto error;
}
Expand Down
12 changes: 6 additions & 6 deletions 12 Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3880,7 +3880,7 @@ compiler_dict(struct compiler *c, expr_ty e)
return 0;
}
if (have_dict) {
ADDOP_I(c, DICT_UPDATE, 1);
ADDOP(c, DICT_UPDATE);
}
have_dict = 1;
elements = 0;
Expand All @@ -3890,15 +3890,15 @@ compiler_dict(struct compiler *c, expr_ty e)
have_dict = 1;
}
VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i));
ADDOP_I(c, DICT_UPDATE, 1);
ADDOP(c, DICT_UPDATE);
}
else {
if (elements == 0xFFFF) {
if (!compiler_subdict(c, e, i - elements, i)) {
return 0;
}
if (have_dict) {
ADDOP_I(c, DICT_UPDATE, 1);
ADDOP(c, DICT_UPDATE);
}
have_dict = 1;
elements = 0;
Expand All @@ -3913,7 +3913,7 @@ compiler_dict(struct compiler *c, expr_ty e)
return 0;
}
if (have_dict) {
ADDOP_I(c, DICT_UPDATE, 1);
ADDOP(c, DICT_UPDATE);
}
have_dict = 1;
}
Expand Down Expand Up @@ -4303,7 +4303,7 @@ compiler_call_helper(struct compiler *c,
have_dict = 1;
}
VISIT(c, expr, kw->value);
ADDOP_I(c, DICT_MERGE, 1);
ADDOP(c, DICT_MERGE);
}
else {
nseen++;
Expand All @@ -4315,7 +4315,7 @@ compiler_call_helper(struct compiler *c,
return 0;
}
if (have_dict) {
ADDOP_I(c, DICT_MERGE, 1);
ADDOP(c, DICT_MERGE);
}
have_dict = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion 2 Python/importlib.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.