From 0a0649f157ce27cd509d84a899633c6645535b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Cholewi=C5=84ski?= Date: Fri, 10 Apr 2015 12:32:23 +0200 Subject: [PATCH] Python 3 support: use f.__* instead of f.func_* --- boltons/funcutils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/boltons/funcutils.py b/boltons/funcutils.py index 9ffad01..644641a 100644 --- a/boltons/funcutils.py +++ b/boltons/funcutils.py @@ -89,12 +89,11 @@ def copy_function(orig, copy_dict=True): copy_dict (bool): Also copy any attributes set on the function instance. Defaults to ``True``. """ - # TODO: Python 3 compat - ret = FunctionType(orig.func_code, - orig.func_globals, - name=orig.func_name, - argdefs=orig.func_defaults, - closure=orig.func_closure) + ret = FunctionType(orig.__code__, + orig.__globals__, + name=orig.__name__, + argdefs=getattr(orig, "__defaults__", None), + closure=getattr(orig, "__closure__", None)) if copy_dict: ret.__dict__.update(orig.__dict__) return ret