[New-bugs-announce] [issue23994] argparse fails to detect program name when there is a slash at the end of the program's path

Mert Bora Alper report at bugs.python.org
Sat Apr 18 19:48:03 CEST 2015


New submission from Mert Bora Alper:

Sorry if the title is not descriptive enough.

When I try to execute a program from a directory which contains an `__main__.py` file, argparse fails to detect programs name. For example:

    $ ls foo
    __main__.py
    $ python3 foo
    usage: foo [-h] [-c COUNT] length
    foo: error: the following arguments are required: length
    $ python3 foo/
    usage: [-h] [-c COUNT] length
    : error: the following arguments are required: length

----

    >>> argparse.__version__
    '1.1'

I followed same steps using Python 2.7.6 and got same result. It will probably be same on other versions too. Same result can also be obtained when using zip files instead of directories.

I don't know if this is a bug since I don't know if I do something wrong or is this a design decision or not.

Thank you,
Bora

----------
components: Library (Lib)
files: __main__.py
messages: 241434
nosy: boramalper
priority: normal
severity: normal
status: open
title: argparse fails to detect program name when there is a slash at the end of the program's path
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file39106/__main__.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23994>
_______________________________________


More information about the New-bugs-announce mailing list