This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients steven.daprano
Date 2020-03-01.04:14:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583036076.94.0.162730222193.issue39805@roundup.psfhosted.org>
In-reply-to
Content
I think this is sufficient for a shallow copy.

import copy
import types

def copyfunction(func):
    new = types.FunctionType(
            func.__code__,
            func.__globals__,
            func.__name__,
            func.__defaults__,
            func.__closure__
            )
    vars(new).update(vars(func))
    new.__annotations__.update(func.__annotations__)
    if func.__kwdefaults__ is not None:
        new.__kwdefaults__ = func.__kwdefaults__.copy()
    return new
History
Date User Action Args
2020-03-01 04:14:36steven.dapranosetrecipients: + steven.daprano
2020-03-01 04:14:36steven.dapranosetmessageid: <1583036076.94.0.162730222193.issue39805@roundup.psfhosted.org>
2020-03-01 04:14:36steven.dapranolinkissue39805 messages
2020-03-01 04:14:36steven.dapranocreate