Skip to content

Commit 8d063f3

Browse files
miss-islingtonjdunterAA-Turner
authored
[3.14] gh-54732: Make argparse error caused by empty rows in option files explicit (GH-136795) (#136818)
gh-54732: Make argparse error caused by empty rows in option files explicit (GH-136795) (cherry picked from commit 8ffc3ef) Co-authored-by: jdunter <2ve@mailbox.org> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 2a9aeb0 commit 8d063f3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/library/argparse.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,18 @@ arguments they contain. For example::
434434
>>> parser.parse_args(['-f', 'foo', '@args.txt'])
435435
Namespace(f='bar')
436436

437-
Arguments read from a file must by default be one per line (but see also
437+
Arguments read from a file must be one per line by default (but see also
438438
:meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they
439439
were in the same place as the original file referencing argument on the command
440440
line. So in the example above, the expression ``['-f', 'foo', '@args.txt']``
441441
is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``.
442442

443+
.. note::
444+
445+
Empty lines are treated as empty strings (``''``), which are allowed as values but
446+
not as arguments. Empty lines that are read as arguments will result in an
447+
"unrecognized arguments" error.
448+
443449
:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
444450
to read the file containing arguments.
445451

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy