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

Python 3 doesn't register script arguments #53230

Closed
Sworddragon mannequin opened this issue Jun 12, 2010 · 13 comments
Closed

Python 3 doesn't register script arguments #53230

Sworddragon mannequin opened this issue Jun 12, 2010 · 13 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Sworddragon
Copy link
Mannequin

Sworddragon mannequin commented Jun 12, 2010

BPO 8984
Nosy @loewis, @mdickinson, @merwok
Superseder
  • bpo-7936: sys.argv contains only scriptname
  • 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-06-12.22:23:15.683>
    created_at = <Date 2010-06-12.20:10:21.615>
    labels = ['type-bug', 'library']
    title = "Python 3 doesn't register script arguments"
    updated_at = <Date 2010-06-12.22:23:15.681>
    user = 'https://bugs.python.org/Sworddragon'

    bugs.python.org fields:

    activity = <Date 2010-06-12.22:23:15.681>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-06-12.22:23:15.683>
    closer = 'mark.dickinson'
    components = ['Library (Lib)']
    creation = <Date 2010-06-12.20:10:21.615>
    creator = 'Sworddragon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 8984
    keywords = []
    message_count = 13.0
    messages = ['107690', '107692', '107696', '107700', '107701', '107702', '107703', '107704', '107706', '107707', '107708', '107709', '107710']
    nosy_count = 4.0
    nosy_names = ['loewis', 'mark.dickinson', 'eric.araujo', 'Sworddragon']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '7936'
    type = 'behavior'
    url = 'https://bugs.python.org/issue8984'
    versions = ['Python 3.1']

    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    Python 3.1.2 hasn't any arguments except the file name in sys.argv[0]. For example: build.py test
    sys.argv[1] will be empty. I tried even the first example from the documentation 15.4 (optparse) but the filename is None. In Python 2.6.5 all is working fine.

    @Sworddragon Sworddragon mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 12, 2010
    @mdickinson
    Copy link
    Member

    It's not entirely clear to me what issue you're reporting here: could you provide a short example script that exhibits the problem, and list the exact steps necessary to reproduce, along with actual and expected results?

    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    Examplescript test.py:

    import sys
    print(sys.argv[1])

    Call this script now with an argument, for exmaple: test.py 1234
    I expect to see the string 1234 in the console but Python 3 says "IndexError: list index out of range". With Python 2.6.5 I be able to see the correct string 1234.

    @merwok
    Copy link
    Member

    merwok commented Jun 12, 2010

    Can’t reproduce here:
    $ python3.1 -c "import sys; print(sys.argv[1])" 1234
    1234
    $ python3.1 --version
    Python 3.1.2

    @merwok merwok added interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed stdlib Python modules in the Lib dir labels Jun 12, 2010
    @mdickinson
    Copy link
    Member

    Hmm. I don't see any difference between the two here (OS X 10.6). What platform are you on, and where did your copy of Python 3.1.2 come from?

    newton:~ dickinsm$ cat test.py
    import sys
    print(sys.argv[1])
    newton:~ dickinsm$ python3.1 test.py 1234
    1234
    newton:~ dickinsm$ python2.6 test.py 1234
    1234
    newton:~ dickinsm$ python3.1
    Python 3.1.2 (r312:79147, May 18 2010, 17:21:15) 
    [GCC 4.2.1 (Apple Inc. build 5659)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    newton:~ dickinsm$ python2.6
    Python 2.6.5 (r265:79063, May 18 2010, 17:12:15) 
    [GCC 4.2.1 (Apple Inc. build 5659)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    I'm using Windows XP Professional SP3. I downloaded Python 3.1.2 from this site. Even Python 3.0.1 hasn't worked.

    @Sworddragon Sworddragon mannequin added stdlib Python modules in the Lib dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 12, 2010
    @merwok
    Copy link
    Member

    merwok commented Jun 12, 2010

    3.0 should not be used and does not get fixes.

    Can you try downloading Python again and testing?

    P.S. please do not change the component; Lib means “Python files under Lib/ in the source checkout”, but sys is a module built by the interpreter core.

    @merwok merwok added interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed stdlib Python modules in the Lib dir labels Jun 12, 2010
    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    I have already installed Python 3.1.2 a second time. I have selected during the installation that the files shall be compiled into bytecode.

    @Sworddragon Sworddragon mannequin added stdlib Python modules in the Lib dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 12, 2010
    @mdickinson
    Copy link
    Member

    I'm failing to reproduce this on Windows 7, too.

    It sounds as though you're starting the python script without an explict 'python'. What are your filetype associations for python scripts?

    i.e., what's the result of typing 'assoc py' at a console prompt?
    And what's the result of the 'ftype' command for the above?

    Just for reference, I get:

    assoc.py
    .py=Python.File

    ftype Python.File
    Python.File=C:\Python31\python.exe "%1" %*

    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    assoc .py
    .py=Python.File

    I tried this now with Ubuntu and Python 3.1.2 and all works fine. But under Windows XP it doesn't work.

    @mdickinson
    Copy link
    Member

    Okay, thanks. What does

    ftype Python.File

    give?

    @Sworddragon
    Copy link
    Mannequin Author

    Sworddragon mannequin commented Jun 12, 2010

    ftype Python.File
    Python.File="E:\Python31\python.exe" "%1" %*

    @mdickinson
    Copy link
    Member

    I've just found issue bpo-7936, which looks like the same problem. I'm going to close this issue as a duplicate of that one; further discussion should be moved there.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants