This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Function's __name__ no longer accessible in restricted mode
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mwh Nosy List: mwh, tim.peters, tseaver
Priority: release blocker Keywords:

Created on 2005-02-16 21:34 by tseaver, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg24311 - (view) Author: Tres Seaver (tseaver) * Date: 2005-02-16 21:34
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 "<stdin>", line 1, in ?
  File "<string>", line 3, in ?
RuntimeError: function attributes not accessible in
restricted mode
>>> ^D
msg24312 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-02-16 21:58
Logged In: YES 
user_id=31435

Assigned to me, and boosted priority, since this should be 
addressed for 2.4.1.
msg24313 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-02-17 10:32
Logged In: YES 
user_id=6656

Oops.  My fault, easy to fix.
msg24314 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2005-02-17 10:44
Logged In: YES 
user_id=6656

Fixed on HEAD in 

Objects/funcobject.c revision 2.68
Lib/test/test_funcattrs.py revision 1.17

and on 24-maint in

Objects/funcobject.c revision 2.67.2.1
Lib/test/test_funcattrs.py revision 1.16.2.1

Copy and paste are evil...
msg24315 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-02-17 15:55
Logged In: YES 
user_id=31435

Thanks, Michael!  It _looked_ like a copy-paste glitch <wink>.

I've confirmed that the specific failing Zope test works with 
current release24-maint branch.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41587
2005-02-16 21:34:03tseavercreate