mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-37032: Add CodeType.replace() method (GH-13542)
This commit is contained in:
parent
561612d845
commit
a9f05d69cc
8 changed files with 401 additions and 33 deletions
10
Lib/types.py
10
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue