You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I'm writing a python program where I need to hook up the __import__ function in certain modules‘ __builtins__ dict to do some stuff, so that I can manage the imports in a way meta path hooks cannot provide.
In python3+ it works just fine, but in python2.7 the interpreter I got this error
File "six.py", line 625, in <module>
get_unbound_function, """Get the function out of a possibly unbound function"""
File "six.py", line 82, in _add_doc
func.__doc__ = doc
RuntimeError: restricted attribute
It turns out the python 2.7 interpreter does not allow changing function object's __doc__ attribute in a restricted frame, which is defined by the frame's __builtins__ reference is not pointing to the internal one.
Hi!
I'm writing a python program where I need to hook up the
__import__
function in certain modules‘__builtins__
dict to do some stuff, so that I can manage the imports in a way meta path hooks cannot provide.In python3+ it works just fine, but in python2.7 the interpreter I got this error
It turns out the python 2.7 interpreter does not allow changing function object's
__doc__
attribute in a restricted frame, which is defined by the frame's__builtins__
reference is not pointing to the internal one.here is a repro script
Thanks!
The text was updated successfully, but these errors were encountered: