mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
bpo-33261: guard access to __code__ attribute in inspect (GH-6448)
This commit is contained in:
parent
487b73ab39
commit
fcef60f59d
4 changed files with 29 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue