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

trace changes sys.argv from list to tuple #77033

Closed
altendky mannequin opened this issue Feb 15, 2018 · 5 comments
Closed

trace changes sys.argv from list to tuple #77033

altendky mannequin opened this issue Feb 15, 2018 · 5 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir

Comments

@altendky
Copy link
Mannequin

altendky mannequin commented Feb 15, 2018

BPO 32852
Nosy @serhiy-storchaka, @altendky, @miss-islington
PRs
  • bpo-32852: Fix trace changing sys.argv to tuple #5692
  • 3.6 bpo-32852: Fix trace changing sys.argv to tuple GH-5692 #5702
  • 3.7 bpo-32852: Fix trace changing sys.argv to tuple GH-5692 #5703
  • 3.6 bpo-32852: Fix trace changing sys.argv to tuple GH-5692 #5704
  • 3.7 bpo-32852: Fix trace changing sys.argv to tuple GH-5692 #5705
  • [3.7] bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692) #5719
  • [3.6] bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692) #5720
  • 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 2018-02-17.08:03:25.220>
    created_at = <Date 2018-02-15.16:39:05.773>
    labels = ['3.8', '3.7', 'library']
    title = 'trace changes sys.argv from list to tuple'
    updated_at = <Date 2018-02-17.08:03:25.218>
    user = 'https://github.com/altendky'

    bugs.python.org fields:

    activity = <Date 2018-02-17.08:03:25.218>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-02-17.08:03:25.220>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-02-15.16:39:05.773>
    creator = 'altendky'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32852
    keywords = ['patch']
    message_count = 5.0
    messages = ['312213', '312271', '312272', '312273', '312274']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'altendky', 'miss-islington']
    pr_nums = ['5692', '5702', '5703', '5704', '5705', '5719', '5720']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue32852'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @altendky
    Copy link
    Mannequin Author

    altendky mannequin commented Feb 15, 2018

    Normally sys.argv is a list but when using the trace module sys.argv gets changed to a tuple. In my case this caused an issue with running an entry point due to the line:

    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])

    When researching I found:
    https://stackoverflow.com/questions/47688568/trace-sys-argv-args-typeerror-tuple-object-does-not-support-item-assig

    They point out where trace assigns a tuple to sys.argv.
    https://github.com/python/cpython/blob/master/Lib/trace.py#L708

    I'll see what I can do to put together a quick patch.

    $ cat t.py
    import sys
    print(sys.version)
    
    print(type(sys.argv))
    $ /home/altendky/.pyenv/versions/3.7.0a2/bin/python t.py
    3.7.0a2 (default, Feb 15 2018, 11:20:36) 
    [GCC 6.3.0 20170516]
    <class 'list'>
    $ /home/altendky/.pyenv/versions/3.7.0a2/bin/python -m trace --trace t.py
     --- modulename: t, funcname: <module>
    t.py(1): import sys
    t.py(3): print(sys.version)
    3.7.0a2 (default, Feb 15 2018, 11:20:36) 
    [GCC 6.3.0 20170516]
    t.py(5): print(type(sys.argv))
    <class 'tuple'>
     --- modulename: trace, funcname: _unsettrace
    trace.py(71):     sys.settrace(None)

    @altendky altendky mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir 3.8 only security fixes labels Feb 15, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset 9f42232 by Serhiy Storchaka (Kyle Altendorf) in branch 'master':
    bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
    9f42232

    @miss-islington
    Copy link
    Contributor

    New changeset afb5e55 by Miss Islington (bot) in branch '3.7':
    bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
    afb5e55

    @miss-islington
    Copy link
    Contributor

    New changeset dda9386 by Miss Islington (bot) in branch '3.6':
    bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
    dda9386

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution Kyle.

    Usually backports a made after merging the original PR. Thanks to bots this is done in half-automatical way.

    @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
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants