Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
332cd5ee
Commit
332cd5ee
authored
Jan 30, 2018
by
Mark Shannon
Committed by
Raymond Hettinger
Jan 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32550. Remove the STORE_ANNOTATION bytecode. (GH-5181)
parent
b6e43af6
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
149 additions
and
201 deletions
+149
-201
Doc/library/dis.rst
Doc/library/dis.rst
+0
-7
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.7.rst
+2
-0
Include/opcode.h
Include/opcode.h
+0
-1
Lib/importlib/_bootstrap_external.py
Lib/importlib/_bootstrap_external.py
+2
-1
Lib/opcode.py
Lib/opcode.py
+0
-1
Lib/test/test_dis.py
Lib/test/test_dis.py
+21
-17
Misc/NEWS.d/next/Core and Builtins/2018-01-14-12-42-17.bpo-32550.k0EK-4.rst
...ore and Builtins/2018-01-14-12-42-17.bpo-32550.k0EK-4.rst
+1
-0
Python/ceval.c
Python/ceval.c
+0
-55
Python/compile.c
Python/compile.c
+10
-6
Python/importlib_external.h
Python/importlib_external.h
+112
-112
Python/opcode_targets.h
Python/opcode_targets.h
+1
-1
No files found.
Doc/library/dis.rst
View file @
332cd5ee
...
...
@@ -993,13 +993,6 @@ All of the following opcodes use their arguments.
Deletes local ``co_varnames[var_num]``.
.. opcode:: STORE_ANNOTATION (namei)
Stores TOS as ``locals()['__annotations__'][co_names[namei]] = TOS``.
.. versionadded:: 3.6
.. opcode:: LOAD_CLOSURE (i)
Pushes a reference to the cell contained in slot *i* of the cell and free
...
...
Doc/whatsnew/3.7.rst
View file @
332cd5ee
...
...
@@ -1173,6 +1173,8 @@ CPython bytecode changes
* Added two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`CALL_METHOD`.
(Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.)
* Removed the STORE_ANNOTATION opcode.
Other CPython implementation changes
------------------------------------
...
...
Include/opcode.h
View file @
332cd5ee
...
...
@@ -99,7 +99,6 @@ extern "C" {
#define LOAD_FAST 124
#define STORE_FAST 125
#define DELETE_FAST 126
#define STORE_ANNOTATION 127
#define RAISE_VARARGS 130
#define CALL_FUNCTION 131
#define MAKE_FUNCTION 132
...
...
Lib/importlib/_bootstrap_external.py
View file @
332cd5ee
...
...
@@ -242,6 +242,7 @@ _code_type = type(_write_atomic.__code__)
# Python 3.7a0 3390 (add LOAD_METHOD and CALL_METHOD opcodes)
# Python 3.7a0 3391 (update GET_AITER #31709)
# Python 3.7a0 3392 (PEP 552: Deterministic pycs)
# Python 3.7a0 3393 (remove STORE_ANNOTATION opcode)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
# longer be understood by older implementations of the eval loop (usually
...
...
@@ -250,7 +251,7 @@ _code_type = type(_write_atomic.__code__)
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
MAGIC_NUMBER
=
(
339
2
).
to_bytes
(
2
,
'little'
)
+
b'
\
r
\
n
'
MAGIC_NUMBER
=
(
339
3
).
to_bytes
(
2
,
'little'
)
+
b'
\
r
\
n
'
_RAW_MAGIC_NUMBER
=
int
.
from_bytes
(
MAGIC_NUMBER
,
'little'
)
# For import.c
_PYCACHE
=
'__pycache__'
...
...
Lib/opcode.py
View file @
332cd5ee
...
...
@@ -169,7 +169,6 @@ def_op('STORE_FAST', 125) # Local variable number
haslocal
.
append
(
125
)
def_op
(
'DELETE_FAST'
,
126
)
# Local variable number
haslocal
.
append
(
126
)
name_op
(
'STORE_ANNOTATION'
,
127
)
# Index in name list
def_op
(
'RAISE_VARARGS'
,
130
)
# Number of raise arguments (1, 2, or 3)
def_op
(
'CALL_FUNCTION'
,
131
)
# #args
...
...
Lib/test/test_dis.py
View file @
332cd5ee
...
...
@@ -226,23 +226,27 @@ dis_annot_stmt_str = """\
2 LOAD_CONST 0 (1)
4 STORE_NAME 0 (x)
6 LOAD_NAME 1 (int)
8 STORE_ANNOTATION 0 (x)
3 10 LOAD_NAME 2 (fun)
12 LOAD_CONST 0 (1)
14 CALL_FUNCTION 1
16 STORE_ANNOTATION 3 (y)
4 18 LOAD_CONST 0 (1)
20 LOAD_NAME 4 (lst)
22 LOAD_NAME 2 (fun)
24 LOAD_CONST 1 (0)
26 CALL_FUNCTION 1
28 STORE_SUBSCR
30 LOAD_NAME 1 (int)
32 POP_TOP
34 LOAD_CONST 2 (None)
36 RETURN_VALUE
8 LOAD_NAME 2 (__annotations__)
10 LOAD_CONST 1 ('x')
12 STORE_SUBSCR
3 14 LOAD_NAME 3 (fun)
16 LOAD_CONST 0 (1)
18 CALL_FUNCTION 1
20 LOAD_NAME 2 (__annotations__)
22 LOAD_CONST 2 ('y')
24 STORE_SUBSCR
4 26 LOAD_CONST 0 (1)
28 LOAD_NAME 4 (lst)
30 LOAD_NAME 3 (fun)
32 LOAD_CONST 3 (0)
34 CALL_FUNCTION 1
36 STORE_SUBSCR
38 LOAD_NAME 1 (int)
40 POP_TOP
42 LOAD_CONST 4 (None)
44 RETURN_VALUE
"""
compound_stmt_str
=
"""
\
...
...
Misc/NEWS.d/next/Core and Builtins/2018-01-14-12-42-17.bpo-32550.k0EK-4.rst
0 → 100644
View file @
332cd5ee
Remove the STORE_ANNOTATION bytecode.
Python/ceval.c
View file @
332cd5ee
...
...
@@ -1574,61 +1574,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
DISPATCH
();
}
TARGET
(
STORE_ANNOTATION
)
{
_Py_IDENTIFIER
(
__annotations__
);
PyObject
*
ann_dict
;
PyObject
*
ann
=
POP
();
PyObject
*
name
=
GETITEM
(
names
,
oparg
);
int
err
;
if
(
f
->
f_locals
==
NULL
)
{
PyErr_Format
(
PyExc_SystemError
,
"no locals found when storing annotation"
);
Py_DECREF
(
ann
);
goto
error
;
}
/* first try to get __annotations__ from locals... */
if
(
PyDict_CheckExact
(
f
->
f_locals
))
{
ann_dict
=
_PyDict_GetItemId
(
f
->
f_locals
,
&
PyId___annotations__
);
if
(
ann_dict
==
NULL
)
{
PyErr_SetString
(
PyExc_NameError
,
"__annotations__ not found"
);
Py_DECREF
(
ann
);
goto
error
;
}
Py_INCREF
(
ann_dict
);
}
else
{
PyObject
*
ann_str
=
_PyUnicode_FromId
(
&
PyId___annotations__
);
if
(
ann_str
==
NULL
)
{
Py_DECREF
(
ann
);
goto
error
;
}
ann_dict
=
PyObject_GetItem
(
f
->
f_locals
,
ann_str
);
if
(
ann_dict
==
NULL
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_KeyError
))
{
PyErr_SetString
(
PyExc_NameError
,
"__annotations__ not found"
);
}
Py_DECREF
(
ann
);
goto
error
;
}
}
/* ...if succeeded, __annotations__[name] = ann */
if
(
PyDict_CheckExact
(
ann_dict
))
{
err
=
PyDict_SetItem
(
ann_dict
,
name
,
ann
);
}
else
{
err
=
PyObject_SetItem
(
ann_dict
,
name
,
ann
);
}
Py_DECREF
(
ann_dict
);
Py_DECREF
(
ann
);
if
(
err
!=
0
)
{
goto
error
;
}
DISPATCH
();
}
TARGET
(
DELETE_SUBSCR
)
{
PyObject
*
sub
=
TOP
();
PyObject
*
container
=
SECOND
();
...
...
Python/compile.c
View file @
332cd5ee
...
...
@@ -213,7 +213,7 @@ static int compiler_async_comprehension_generator(
expr_ty
elt
,
expr_ty
val
,
int
type
);
static
PyCodeObject
*
assemble
(
struct
compiler
*
,
int
addNone
);
static
PyObject
*
__doc__
;
static
PyObject
*
__doc__
,
*
__annotations__
;
#define CAPSULE_NAME "compile.c compiler unit"
...
...
@@ -311,7 +311,11 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
if
(
!
__doc__
)
return
NULL
;
}
if
(
!
__annotations__
)
{
__annotations__
=
PyUnicode_InternFromString
(
"__annotations__"
);
if
(
!
__annotations__
)
return
NULL
;
}
if
(
!
compiler_init
(
&
c
))
return
NULL
;
Py_INCREF
(
filename
);
...
...
@@ -1056,8 +1060,6 @@ stack_effect(int opcode, int oparg, int jump)
return
-
1
;
case
DELETE_FAST
:
return
0
;
case
STORE_ANNOTATION
:
return
-
1
;
case
RAISE_VARARGS
:
return
-
oparg
;
...
...
@@ -4711,8 +4713,10 @@ compiler_annassign(struct compiler *c, stmt_ty s)
else
{
VISIT
(
c
,
expr
,
s
->
v
.
AnnAssign
.
annotation
);
}
/* ADDOP_N decrefs its argument */
ADDOP_N
(
c
,
STORE_ANNOTATION
,
mangled
,
names
);
ADDOP_NAME
(
c
,
LOAD_NAME
,
__annotations__
,
names
);
ADDOP_O
(
c
,
LOAD_CONST
,
mangled
,
consts
);
Py_DECREF
(
mangled
);
ADDOP
(
c
,
STORE_SUBSCR
);
}
break
;
case
Attribute_kind
:
...
...
Python/importlib_external.h
View file @
332cd5ee
This diff is collapsed.
Click to expand it.
Python/opcode_targets.h
View file @
332cd5ee
...
...
@@ -126,7 +126,7 @@ static void *opcode_targets[256] = {
&&
TARGET_LOAD_FAST
,
&&
TARGET_STORE_FAST
,
&&
TARGET_DELETE_FAST
,
&&
TARGET_STORE_ANNOTATION
,
&&
_unknown_opcode
,
&&
_unknown_opcode
,
&&
_unknown_opcode
,
&&
TARGET_RAISE_VARARGS
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment