[New-bugs-announce] [issue30421] Relative include of config files

Robert Schindler report at bugs.python.org
Sun May 21 04:15:42 EDT 2017


New submission from Robert Schindler:

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

----------
components: Library (Lib)
files: argparse_relative_includes.patch
keywords: patch
messages: 294086
nosy: roschi
priority: normal
severity: normal
status: open
title: Relative include of config files
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46881/argparse_relative_includes.patch

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


More information about the New-bugs-announce mailing list