This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: argparse: relative include of config files
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: bethard, louielu, paul.j3, roschi
Priority: normal Keywords: patch

Created on 2017-05-21 08:15 by roschi, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
argparse_relative_includes.patch roschi, 2017-05-21 08:15
argparse_relative_includes2.patch roschi, 2017-05-21 08:38 Fixed reference to os.
Pull Requests
URL Status Linked Edit
PR 1698 open roschi, 2017-05-21 12:01
Messages (3)
msg294086 - (view) Author: Robert Schindler (roschi) * Date: 2017-05-21 08:15
Hi,

When one includes an argument file at the command line using argparse and that file contains another include statement, the inner include path is treated as relative to os.getcwd(), what is not the way people expect it to be, I guess.

This patch modifies argparse so that it treats paths of files to include as relative to the location of the file the include was made from.

I also pulled statements that I think should not be enclosed by the try/except out of it and changed the workflow so that the file descriptor of an include file is closed before another one is opened by the recursive call to _read_args_from_files again.. That way, the number of file descriptors open at a time is kept low.

Best regards
Robert
msg294096 - (view) Author: Louie Lu (louielu) * Date: 2017-05-21 10:34
Hi Robert, the submit flow has migrate to GitHub pull requests workflow, and it is strongly preferred to used GitHub PR workflow, do you mind to convert your patch to GitHub?


* GitHub repo: https://github.com/python/cpython
* devguide about PR: http://cpython-devguide.readthedocs.io/pullrequest.html
msg294098 - (view) Author: Robert Schindler (roschi) * Date: 2017-05-21 10:52
Hi Louie,

oh, I didn't notice that. But that's great news. I'll send a PR soon.

Best regards
Robert
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74606
2017-09-02 16:37:28paul.j3setnosy: + paul.j3
2017-08-28 16:27:07terry.reedysetnosy: + bethard

versions: - Python 3.5
2017-05-21 12:01:37roschisetpull_requests: + pull_request1792
2017-05-21 10:52:20roschisetmessages: + msg294098
2017-05-21 10:34:39louielusetnosy: + louielu
messages: + msg294096
2017-05-21 08:38:23roschisetfiles: + argparse_relative_includes2.patch
2017-05-21 08:17:14roschisettitle: Relative include of config files -> argparse: relative include of config files
2017-05-21 08:15:42roschicreate