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

str object got multiple values for keyword argument #71473

Closed
vadmium opened this issue Jun 10, 2016 · 13 comments
Closed

str object got multiple values for keyword argument #71473

vadmium opened this issue Jun 10, 2016 · 13 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@vadmium
Copy link
Member

vadmium commented Jun 10, 2016

BPO 27286
Nosy @rhettinger, @mdickinson, @ncoghlan, @larryhastings, @ambv, @vadmium, @serhiy-storchaka, @irushchyshyn
PRs
  • [3.5] bpo-29537: Tolerate legacy invalid bytecode #169
  • Files
  • BUILD_MAP_UNPACK_WITH_CALL-function_pos.patch
  • BUILD_MAP_UNPACK_WITH_CALL-function_pos2.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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-06-12.07:41:31.780>
    created_at = <Date 2016-06-10.09:37:11.397>
    labels = ['interpreter-core', 'type-bug']
    title = 'str object got multiple values for keyword argument'
    updated_at = <Date 2017-03-24.22:42:19.149>
    user = 'https://github.com/vadmium'

    bugs.python.org fields:

    activity = <Date 2017-03-24.22:42:19.149>
    actor = 'ncoghlan'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-06-12.07:41:31.780>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-06-10.09:37:11.397>
    creator = 'martin.panter'
    dependencies = []
    files = ['43331', '43332']
    hgrepos = []
    issue_num = 27286
    keywords = ['patch']
    message_count = 13.0
    messages = ['268110', '268121', '268123', '268128', '268336', '272360', '272368', '278158', '282148', '287506', '287508', '287526', '290270']
    nosy_count = 11.0
    nosy_names = ['rhettinger', 'jpe', 'mark.dickinson', 'ncoghlan', 'larry', 'lukasz.langa', 'python-dev', 'martin.panter', 'serhiy.storchaka', 'shai', 'ishcherb']
    pr_nums = ['169']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27286'
    versions = ['Python 3.5', 'Python 3.6']

    @vadmium
    Copy link
    Member Author

    vadmium commented Jun 10, 2016

    Playing with the generalized unpacking (PEP-448), I found a funny error message, when duplicate dictionary unpackings are included and also duplicate a literal keyword argument:

    >>> print(end=".\n", **dict(end="dupe"))  # No problem
    TypeError: print() got multiple values for keyword argument 'end'
    >>> print(**dict(end=".\n"), **dict(end="dupe"))  # No problem
    TypeError: print() got multiple values for keyword argument 'end'
    >>> print(end=".\n", **dict(end="dupe"), **dict(end="dupe 2"))  # str object?!
    TypeError: str object got multiple values for keyword argument 'end'

    @vadmium vadmium added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 10, 2016
    @serhiy-storchaka
    Copy link
    Member

    Here is a fix.

    @rhettinger
    Copy link
    Contributor

    This patch looks correct.

    @serhiy-storchaka
    Copy link
    Member

    Since currently generated bytecode is not correct, I think we should update the magic number for forcing the regenerating pyc-files.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 12, 2016

    New changeset 34d24c51eab6 by Serhiy Storchaka in branch '3.5':
    Issue bpo-27286: Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode. Calling
    https://hg.python.org/cpython/rev/34d24c51eab6

    New changeset 194549801bd5 by Serhiy Storchaka in branch 'default':
    Issue bpo-27286: Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode. Calling
    https://hg.python.org/cpython/rev/194549801bd5

    @jpe
    Copy link
    Mannequin

    jpe mannequin commented Aug 10, 2016

    Should the bytecode magic number be bumped in the 3.5 branch? This breaks .pyc / .pyo binary compatibility for python 3.5. As far as I can tell this has never been done before in a release after the major.minor.0 final release.

    This patch has made its way into debian's python 3.5 and I've gotten a bug report because of it for an app distributed without python source.

    Looking at the 3.5.2 tarball, it does not look like the change was included in 3.5.2. If the magic number is bumped in 3.5, the comment should be changed to reflect that it changes in 3.5.3 and not in 3.5.2

    @serhiy-storchaka
    Copy link
    Member

    Bytecode generated by 3.5.1 is not correct (wrong error message can be not the only effect). The only way to resolve this issue is regenerating the bytecode.

    3.5.2 was released two weeks after committing this patch. I expected it includes this change.

    @ambv
    Copy link
    Contributor

    ambv commented Oct 5, 2016

    The magic number change in a minor release was a mistake. Let's not do that with 3.6.x releases. Since Python doesn't check if there's a corresponding .py file that can be used to rebuild the .pyc file, we shouldn't reject existing .pyc files on the basis that they *might* be broken.

    @shai
    Copy link
    Mannequin

    shai mannequin commented Dec 1, 2016

    Following the last comment, and just as clarification for anyone else running into this and thinking like me: The bumped code is not included in v3.5.2, and v3.5.3 hasn't been released yet. Should it be undone?

    No, because the bump which was encountered by John Ehresman on Debian Testing has also made it into Ubuntu 16.04LTS. Undoing it, at this point, is liable to bring even worse breakage than the original change caused.

    http://changelogs.ubuntu.com/changelogs/pool/main/p/python3.5/python3.5_3.5.2-2ubuntu0\~16.04.1/changelog

    @mdickinson
    Copy link
    Member

    It's difficult to track down which versions of Python 3.5.x the bytecode change is in because the Misc/NEWS entry has vanished, apparently in this merge commit:

    aa0f9d8

    @larryhastings
    Copy link
    Contributor

    Sorry about that! It's almost like manually updating Misc/NEWS is a bad design :(

    @vadmium
    Copy link
    Member Author

    vadmium commented Feb 10, 2017

    Diff showing what changed relative to the main 3.5 branch when merging in the 3.5.2 release: <https://hg.python.org/cpython/rev/31a2a278dc85:1f8938164809\>.

    There are four news entries deleted from the 3.5.2rc1 section. Ideally they should have been moved to the 3.5.3rc1 section instead, because they were added after 3.5.2rc1 was branched, but before the 3.5.3rc1 heading appeared.

    Also, there were some minor corrections of mine and Victor’s that were undone.

    And I would suggest to restrict merge commits to changes that are already in at least one of the branches being merged. The edit to “byte-like” was not present in either of the branches being merged. In Git I think they call these changes “evil merges”.

    @ncoghlan
    Copy link
    Contributor

    New changeset 93602e3 by Nick Coghlan in branch '3.5':
    [3.5] bpo-29537: Tolerate legacy invalid bytecode (#169)
    93602e3

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    7 participants