Issue 1124295: Function's name no longer accessible in restricted mode (original) (raw)
This change breaks an obscure bit of Zope's security machinery, which uses the name of a function to construct the synthetic attribute name under which the roles for a method are stored.
$ ../bin/python2.3 Python 2.3.4 (#3, Jan 27 2005, 10:46:13) [GCC 3.3.4 (Debian 1:3.3.4-9ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
code = """
... def func(): ... pass ... print func.name ... """ exec code func globs = {'builtins':{}} exec code in globs func ^D
$ ../bin/python2.4 Python 2.4 (#1, Feb 16 2005, 13:11:02) [GCC 3.3.4 (Debian 1:3.3.4-9ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
code = """
... def func(): ... pass ... print func.name ... """ exec code func globs = {'builtins':{}} exec code in globs Traceback (most recent call last): File "", line 1, in ? File "", line 3, in ? RuntimeError: function attributes not accessible in restricted mode ^D