summaryrefslogtreecommitdiff
path: root/Lib/types.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-24 23:57:23 +0200
committerGitHub <noreply@github.com>2019-05-24 23:57:23 +0200
commita9f05d69ccbf3c75cdd604c25094282697789a62 (patch)
treeb26677a8437f12e011b3adb574f32aa0bbff8739 /Lib/types.py
parent561612d8456cfab5672c9b445521113b847bd6b3 (diff)
downloadcpython-git-a9f05d69ccbf3c75cdd604c25094282697789a62.tar.gz
bpo-37032: Add CodeType.replace() method (GH-13542)
Diffstat (limited to 'Lib/types.py')
-rw-r--r--Lib/types.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/types.py b/Lib/types.py
index 37ba4bb1f4..ea3c0b29d5 100644
--- a/Lib/types.py
+++ b/Lib/types.py
@@ -262,14 +262,8 @@ def coroutine(func):
if co_flags & 0x20:
# TODO: Implement this in C.
co = func.__code__
- func.__code__ = CodeType(
- co.co_argcount, co.co_posonlyargcount, co.co_kwonlyargcount, co.co_nlocals,
- co.co_stacksize,
- co.co_flags | 0x100, # 0x100 == CO_ITERABLE_COROUTINE
- co.co_code,
- co.co_consts, co.co_names, co.co_varnames, co.co_filename,
- co.co_name, co.co_firstlineno, co.co_lnotab, co.co_freevars,
- co.co_cellvars)
+ # 0x100 == CO_ITERABLE_COROUTINE
+ func.__code__ = co.replace(co_flags=co.co_flags | 0x100)
return func
# The following code is primarily to support functions that