bpo-33261: guard access to __code__ attribute in inspect (GH-6448)

This commit is contained in:
Jeroen Demeyer 2019-04-02 16:03:42 +02:00 committed by Petr Viktorin
parent 487b73ab39
commit fcef60f59d
4 changed files with 29 additions and 9 deletions

View file

@ -80,3 +80,14 @@ try:
raise Exception()
except:
tb = sys.exc_info()[2]
class Callable:
def __call__(self, *args):
return args
def as_method_of(self, obj):
from types import MethodType
return MethodType(self, obj)
custom_method = Callable().as_method_of(42)
del Callable