Skip to content

Commit 2d0f169

Browse files
miss-islingtonjdunterAA-Turner
authored
[3.13] gh-54732: Make argparse error caused by empty rows in option files explicit (GH-136795) (#136819)
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 ff8de16 commit 2d0f169

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
@@ -415,12 +415,18 @@ arguments they contain. For example::
415415
>>> parser.parse_args(['-f', 'foo', '@args.txt'])
416416
Namespace(f='bar')
417417

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

424+
.. note::
425+
426+
Empty lines are treated as empty strings (``''``), which are allowed as values but
427+
not as arguments. Empty lines that are read as arguments will result in an
428+
"unrecognized arguments" error.
429+
424430
:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
425431
to read the file containing arguments.
426432

0 commit comments

Comments
 (0)