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

Documentation claims that PySequence_Fast returns a tuple, when it actually returns a list. #60599

Closed
sfllaw mannequin opened this issue Nov 3, 2012 · 8 comments
Closed
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@sfllaw
Copy link
Mannequin

sfllaw mannequin commented Nov 3, 2012

BPO 16395
Nosy @rhettinger, @larryhastings, @merwok, @serhiy-storchaka, @MojoVampire
Files
  • 16395.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 2014-04-08.14:49:17.729>
    created_at = <Date 2012-11-03.15:18:21.787>
    labels = ['type-bug', 'docs']
    title = 'Documentation claims that PySequence_Fast returns a tuple, when it actually returns a list.'
    updated_at = <Date 2014-04-08.14:49:17.728>
    user = 'https://bugs.python.org/sfllaw'

    bugs.python.org fields:

    activity = <Date 2014-04-08.14:49:17.728>
    actor = 'python-dev'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2014-04-08.14:49:17.729>
    closer = 'python-dev'
    components = ['Documentation']
    creation = <Date 2012-11-03.15:18:21.787>
    creator = 'sfllaw'
    dependencies = []
    files = ['27857']
    hgrepos = []
    issue_num = 16395
    keywords = ['patch']
    message_count = 8.0
    messages = ['174633', '174636', '174637', '174654', '215728', '215729', '215761', '215763']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'larry', 'sfllaw', 'eric.araujo', 'docs@python', 'python-dev', 'serhiy.storchaka', 'josh.r']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue16395'
    versions = ['Python 2.7', 'Python 3.2']

    @sfllaw
    Copy link
    Mannequin Author

    sfllaw mannequin commented Nov 3, 2012

    The documentation in Python 2.7, 3.2, and 3.3 claim that:

    PyObject* PySequence_Fast(PyObject *o, const char *m)
    Return value: New reference.
    Returns the sequence o as a tuple, unless it is already a tuple or list, in which case o is returned...

    Unfortunately, the code does this in Objects/abstract.c:

        v = PySequence_List(it);

    And the header file in Include/abstract.h matches the documentation:

         PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
           /*
         Returns the sequence, o, as a tuple, unless it's already a
         tuple or list.
           */

    @sfllaw sfllaw mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 3, 2012
    @sfllaw
    Copy link
    Mannequin Author

    sfllaw mannequin commented Nov 3, 2012

    It looks like this was caught in the 3.3 branch, but only fixed it in the comment:

    changeset: 75448:d8f68195210e
    user: Larry Hastings <larry@hastings.org>
    date: Mon Mar 05 22:59:13 2012 -0800
    summary: Fix a comment: PySequence_Fast() creates a list, not a tuple.

    The included patch applies cleanly to Python 2.7 and 3.2. When applying to 3.3, include the failure in Objects/abstract.c because the same change has already been made.

    @merwok
    Copy link
    Member

    merwok commented Nov 3, 2012

    Larry, any objection to backporting this?

    @merwok merwok added docs Documentation in the Doc dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Nov 3, 2012
    @serhiy-storchaka
    Copy link
    Member

    PySequence_Tuple() was changed to PySequence_List() in the changeset 4714aff4bf75 in 2004. Are there any measurements which show PySequence_List() faster than PySequence_Tuple() on modern Python? I don't see any references in 4714aff4bf75 description.

    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented Apr 8, 2014

    Any news on this? I was about to open a bug of my own for this, since the docs and code are still out of sync.

    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented Apr 8, 2014

    As far as performance goes, presumably the length hinting API reduces the number of cases in which we're working with completely unsized iterables, right?

    @larryhastings
    Copy link
    Contributor

    I have no objections to someone backporting this.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 8, 2014

    New changeset b2187b82a658 by Benjamin Peterson in branch '3.4':
    PySequence_Fast generally returns a list not a tuple (closes bpo-16395)
    http://hg.python.org/cpython/rev/b2187b82a658

    New changeset b235db467cd5 by Benjamin Peterson in branch '2.7':
    PySequence_Fast generally returns a list not a tuple (closes bpo-16395)
    http://hg.python.org/cpython/rev/b235db467cd5

    New changeset c833c35aa13a by Benjamin Peterson in branch 'default':
    merge 3.4 (bpo-16395)
    http://hg.python.org/cpython/rev/c833c35aa13a

    @python-dev python-dev mannequin closed this as completed Apr 8, 2014
    @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
    docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants