Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make func_name writable #40704

Closed
mwhudson opened this issue Aug 6, 2004 · 9 comments
Closed

Make func_name writable #40704

mwhudson opened this issue Aug 6, 2004 · 9 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@mwhudson
Copy link

mwhudson commented Aug 6, 2004

BPO 1004703
Nosy @mwhudson, @loewis, @smontanaro
Files
  • writable-func_name.diff: mwh's patch Support "bpo-" in Misc/NEWS #1
  • writable-func_name-2.diff: mwh's patch Rename README to README.rst and enhance formatting #2
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/mwhudson'
    closed_at = <Date 2004-08-12.18:14:57.000>
    created_at = <Date 2004-08-06.16:06:35.000>
    labels = ['interpreter-core']
    title = 'Make func_name writable'
    updated_at = <Date 2004-08-12.18:14:57.000>
    user = 'https://github.com/mwhudson'

    bugs.python.org fields:

    activity = <Date 2004-08-12.18:14:57.000>
    actor = 'mwh'
    assignee = 'mwh'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2004-08-06.16:06:35.000>
    creator = 'mwh'
    dependencies = []
    files = ['6149', '6150']
    hgrepos = []
    issue_num = 1004703
    keywords = ['patch']
    message_count = 9.0
    messages = ['46564', '46565', '46566', '46567', '46568', '46569', '46570', '46571', '46572']
    nosy_count = 4.0
    nosy_names = ['mwh', 'loewis', 'skip.montanaro', 'anthonybaxter']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1004703'
    versions = ['Python 2.4']

    @mwhudson
    Copy link
    Author

    mwhudson commented Aug 6, 2004

    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.

    @mwhudson mwhudson closed this as completed Aug 6, 2004
    @mwhudson mwhudson self-assigned this Aug 6, 2004
    @mwhudson mwhudson added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Aug 6, 2004
    @mwhudson mwhudson closed this as completed Aug 6, 2004
    @mwhudson mwhudson self-assigned this Aug 6, 2004
    @mwhudson mwhudson added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Aug 6, 2004
    @smontanaro
    Copy link
    Contributor

    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)?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 6, 2004

    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.

    @anthonybaxter
    Copy link
    Mannequin

    anthonybaxter mannequin commented Aug 7, 2004

    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, ...

    @mwhudson
    Copy link
    Author

    mwhudson commented Aug 7, 2004

    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?).

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 7, 2004

    Logged In: YES
    user_id=21627

    These decisions are all fine with me.

    As for anonymous functions: It appears that compile.c
    2.36/funcobject.c 2.7 introduce the notion of anonymous code
    objects (30-Nov-93). compile.c 2.48 (18-Jul-95) takes this
    option out again, along with introducing keyword arguments.
    So it is probably safe to drop the support for anonymous
    functions.

    @mwhudson
    Copy link
    Author

    mwhudson commented Aug 7, 2004

    Logged In: YES
    user_id=6656

    OK, take 2. More documentation, removes the "if (func_name ==
    Py_None)" case in func_repr.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 12, 2004

    Logged In: YES
    user_id=21627

    I notice an inconsistency in the documentation: all
    attribute explanations start with a noun explaining the
    thing; func_dict starts with "Contains". I'd still like to
    see a \versionchanged indicating that the name is only
    writable since 2.4.

    Apart from that, the patch looks fine.

    @mwhudson
    Copy link
    Author

    Logged In: YES
    user_id=6656

    Thanks for the review; I've accomodated both your points.

    Checked in as:

    Doc/lib/libstdtypes.tex revision 1.163
    Doc/ref/ref3.tex revision 1.121
    Lib/test/test_funcattrs.py revision 1.14
    Objects/funcobject.c revision 2.66
    Misc/NEWS revision 1.1083

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants