[Patches] [ python-Patches-1004703 ] Make func_name writable

SourceForge.net noreply at sourceforge.net
Sat Aug 7 15:10:22 CEST 2004


Patches item #1004703, was opened at 2004-08-06 17:06
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1004703&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Make func_name writable

Initial Comment:
This was pretty easy: just copypasteandchange the code
for func_code :-)  I only allow func_name (or __name__)
to be set to a string.

Adds some simple tests.

I've corrected the one place in the docs that seems to
claim func_name is read only, but the docs for which
function attributes are or aren't read-only don't seem
to be especially accurate already.

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2004-08-07 14:10

Message:
Logged In: YES 
user_id=6656

> Should we require that the new function name is a valid
> identifier?

We could, but I don't really see it being worth the effort
(no attempt is made to ensure that a type's __name__ is a
valid identifier today).

> If not, is an empty string an acceptable function name?

Don't see why not.

> Also, are string subtypes allowed?

Again, don't see why not.

> There should be \versionchanged in the documentation.

Yes.  In fact the documentation of function attributes could
do with being rewritten entirely....

I'll note that all the possibilities you mention are
possiblities today, via new.function.  I'm really not
changing very much.

Agree with Anthony that we don't want to allow unicode.

(While we're at it, I see that func_repr takes into account
that func_name might be Py_None, but I don't think this is
actually possible.  Any ideas?).

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2004-08-07 11:49

Message:
Logged In: YES 
user_id=29957

For instance, allowing a unicode string as a function name
would probably break a truly amazing amount of things.
Tracebacks, pdb, ...


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2004-08-06 21:44

Message:
Logged In: YES 
user_id=21627

Should we require that the new function name is a valid
identifier? If not, is an empty string an acceptable
function name? Also, are string subtypes allowed?

There should be \versionchanged in the documentation.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2004-08-06 19:18

Message:
Logged In: YES 
user_id=44345

Looks good.  Less important in the current context, but for
any of the
attributes which are writable should there be PyFunction_Set
methods
available to help enforce desired behavior (not allowing
non-string
objects for function names for example)?


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1004703&group_id=5470


More information about the Patches mailing list