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

2021-12-10 Thread Irit Katriel


Irit Katriel  added the comment:

I am unable to reproduce this problem on 3.11 on a Mac.

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-21 Thread paul j3

paul j3 added the comment:

This overlaps with http://bugs.python.org/issue22240
argparse support for python -m module in help

This issue also tries to handle zip files as well.

Deducing the `prog` was moved to a separate function.

One challenge with that issue was constructing a test framework.  Here the 
testing might simpler since the `foo/` directory doesn't have to exist (or at 
least we can fake it with a custom `sys.argv`).

--
nosy: +paul.j3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-20 Thread Mert Bora Alper

Mert Bora Alper added the comment:

 Thanks for the patch.  We'll want a unit test for the behavior before 
 committing this.

You're welcome. Since I have no experience in writing unit tests, I don't 
really know where to start but I will try to do my best.

I added bethard to the Nosy List, as he is the author of argparse's test.

(In addition, you may want to change cpython/Lib/test/test_argparse.py:2163 )

--
nosy: +bethard

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-19 Thread R. David Murray

R. David Murray added the comment:

Thanks for the patch.  We'll want a unit test for the behavior before 
committing this.

--
nosy: +r.david.murray
stage:  - test needed
versions: +Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-19 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag
resolution: fixed - 

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-19 Thread Mert Bora Alper

Mert Bora Alper added the comment:

 I think this was just overlooked when implementing argparse.  Most code out 
 there is likely to get the executable name using:

 os.path.basename(sys.argv[0])

 Which is going to do exactly what you are seeing here when sys.argv[0] ends 
 with a /.
 
 feel free to submit a patch.  perhaps as simple as this?

  os.path.basename(sys.argv[0].rstrip(os.path.sep))

 But I'd expect a bunch of other code out there to have the same problem.

It is exactly as you said: 
https://hg.python.org/cpython/file/3.4/Lib/argparse.py#l1619

Patch included. Created and tested using latest source at 
https://hg.python.org/cpython/.

--
keywords: +patch
resolution:  - fixed
Added file: http://bugs.python.org/file39120/argparse.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-18 Thread Gregory P. Smith

Gregory P. Smith added the comment:

I think this was just overlooked when implementing argparse.  Most code out 
there is likely to get the executable name using:

os.path.basename(sys.argv[0])

Which is going to do exactly what you are seeing here when sys.argv[0] ends 
with a /.

feel free to submit a patch.  perhaps as simple as this?

 os.path.basename(sys.argv[0].rstrip(os.path.sep))

But I'd expect a bunch of other code out there to have the same problem.

--
nosy: +gregory.p.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2015-04-18 Thread Mert Bora Alper

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 rep...@bugs.python.org
http://bugs.python.org/issue23994
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com