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

Dead code in Objects/object.c #53540

Closed
pitrou opened this issue Jul 18, 2010 · 4 comments
Closed

Dead code in Objects/object.c #53540

pitrou opened this issue Jul 18, 2010 · 4 comments
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@pitrou
Copy link
Member

pitrou commented Jul 18, 2010

BPO 9294
Nosy @pitrou
Files
  • internal_print_remove.patch
  • 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 = None
    closed_at = <Date 2010-07-27.22:10:44.687>
    created_at = <Date 2010-07-18.14:55:42.721>
    labels = ['interpreter-core', 'easy']
    title = 'Dead code in Objects/object.c'
    updated_at = <Date 2010-07-27.22:10:44.685>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-07-27.22:10:44.685>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-07-27.22:10:44.687>
    closer = 'pitrou'
    components = ['Interpreter Core']
    creation = <Date 2010-07-18.14:55:42.721>
    creator = 'pitrou'
    dependencies = []
    files = ['18201']
    hgrepos = []
    issue_num = 9294
    keywords = ['patch', 'easy']
    message_count = 4.0
    messages = ['110651', '111564', '111572', '111734']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'glimberg']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue9294'
    versions = ['Python 3.1', 'Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Jul 18, 2010

    internal_print() is called from only one place, with the nesting argument wired to 0, therefore the following chunk of code in internal_print() never gets a chance to be executed:

        if (nesting > 10) {
            PyErr_SetString(PyExc_RuntimeError, "print recursion");
            return -1;
        }

    @pitrou pitrou added interpreter-core (Objects, Python, Grammar, and Parser dirs) easy labels Jul 18, 2010
    @glimberg
    Copy link
    Mannequin

    glimberg mannequin commented Jul 25, 2010

    It looks like at one point, internal_print was a recursive function, but this is no longer the case. I've updated the function parameters to no longer contain the "nesting" parameter and removed the if block shown in this case.

    @glimberg
    Copy link
    Mannequin

    glimberg mannequin commented Jul 25, 2010

    On second thought, internal_print() doesn't look like it's needed anymore as it's only called by PyObject_Print() and is no longer recursive. This second patch moves internal_print()'s function body into PyObject_Print and removes the internal_print function.

    @pitrou
    Copy link
    Member Author

    pitrou commented Jul 27, 2010

    Thank you! The patch was committed in r83184 (py3k) and r83185 (3.1).

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

    No branches or pull requests

    1 participant