GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-54732: Tweak wording around empty lines in argument files by savannahostrowski · Pull Request #150980 · python/cpython

Conversation

@savannahostrowski

@savannahostrowski savannahostrowski commented Jun 5, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Follow-up to #136795.

Revises the empty-lines note to address the concerns raised in #54732 (comment), and adds a caveat to the convert_arg_line_to_args example that split-based parsing can't represent arguments containing spaces.

  • Issue: argparse has problem parsing option files containing empty rows #54732

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@savannahostrowski
Tweak wording around empty lines in argument files
8bc2d08
@savannahostrowski savannahostrowski added docs Documentation in the Doc dir needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Jun 5, 2026
@github-project-automation github-project-automation Bot added this to Docs PRs Jun 5, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jun 5, 2026
@bedevere-app bedevere-app Bot added awaiting core review skip news labels Jun 5, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 5, 2026
argparse has problem parsing option files containing empty rows #54732
Closed
@savannahostrowski savannahostrowski linked an issue Jun 5, 2026 that may be closed by this pull request
argparse has problem parsing option files containing empty rows #54732
Closed
@savannahostrowski
Merge branch 'main' into pythongh-54732-fromfile-empty-line-doc
08fe6b9
@read-the-docs-community

read-the-docs-community Bot commented Jun 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33060979 | 📁 Comparing 0f80836 against main (6544bf4)

  🔍 Preview build  

17 files changed · ± 17 modified

± Modified

  • c-api/long.html
  • c-api/typeobj.html
  • howto/functional.html
  • library/argparse.html
  • library/bisect.html
  • library/collections.abc.html
  • library/collections.html
  • library/importlib.resources.html
  • library/logging.handlers.html
  • library/math.html
  • and 7 more...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clytaemnestra
clytaemnestra reviewed Jun 9, 2026
View reviewed changes
Comment thread Doc/library/argparse.rst
Comment on lines +445 to +446
Each line is treated as a single argument, so an empty line is read as an
empty string (``''``).

@clytaemnestra clytaemnestra Jun 9, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to simulate the situation where empty strings are passed from a file and it doesn't return an unrecognized argument, so this note makes much more sense to me and is perfectly understandable.

I also tried to simulate the unrecognized arguments error to see when it appears and my understanding is that it's related to leftover tokens in general rather than empty strings. So, if my understanding is correct, it also makes sense that it was removed here.

So, overall, the new wording is much clearer to me.

>>> import argparse
>>> with open("args.txt", "w") as f:
...   f.write("-f\n\nbar\n")
...
8
>>> parser = argparse.ArgumentParser(fromfile_prefix_chars="@")
>>> parser.add_argument("-f")
_StoreAction(option_strings=['-f'], dest='f', nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)
>>> parser.add_argument("rest", nargs="*")
_StoreAction(option_strings=[], dest='rest', nargs='*', const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)
>>> parser._read_args_from_files(["@args.txt"])
['-f', '', 'bar']
>>> parser.parse_args(["@args.txt"])
Namespace(f='', rest=['bar'])
>>> p2 = argparse.ArgumentParser(fromfile_prefix_chars="@")
>>> p2.add_argument("-f")
_StoreAction(option_strings=['-f'], dest='f', nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)
>>> p2.parse_args(["@args.txt"])
usage: [-h] [-f F]
: error: unrecognized arguments: bar

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@savannahostrowski
Merge branch 'main' into pythongh-54732-fromfile-empty-line-doc
0f80836
@savannahostrowski
savannahostrowski enabled auto-merge (squash) June 9, 2026 15:28
@savannahostrowski
savannahostrowski merged commit 528550e into python:main Jun 9, 2026
30 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 9, 2026
@miss-islington-app

miss-islington-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

GH-151165 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jun 9, 2026
@bedevere-app

bedevere-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

GH-151166 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 9, 2026
@bedevere-app

bedevere-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

GH-151167 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed needs backport to 3.13 only security fixes awaiting core review labels Jun 9, 2026
savannahostrowski added a commit that referenced this pull request Jun 9, 2026
@miss-islington @savannahostrowski
[3.13] GH-54732: Tweak wording around empty lines in argument files (G…
b032f3f
…H-150980) (#151167)

GH-54732: Tweak wording around empty lines in argument files (GH-150980)
(cherry picked from commit 528550e)

Co-authored-by: Savannah Ostrowski <[email protected]>
savannahostrowski added a commit that referenced this pull request Jun 9, 2026
@miss-islington @savannahostrowski
[3.14] GH-54732: Tweak wording around empty lines in argument files (G…
9d92876
…H-150980) (#151166)

GH-54732: Tweak wording around empty lines in argument files (GH-150980)
(cherry picked from commit 528550e)

Co-authored-by: Savannah Ostrowski <[email protected]>
savannahostrowski added a commit that referenced this pull request Jun 9, 2026
@miss-islington @savannahostrowski
[3.15] GH-54732: Tweak wording around empty lines in argument files (G…
804be0a
…H-150980) (#151165)

GH-54732: Tweak wording around empty lines in argument files (GH-150980)
(cherry picked from commit 528550e)

Co-authored-by: Savannah Ostrowski <[email protected]>
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Jun 9, 2026
@savannahostrowski unknown
pythonGH-54732: Tweak wording around empty lines in argument files (p…
1bfa4fd
…ython#150980)
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@savannahostrowski @philthompson10
pythonGH-54732: Tweak wording around empty lines in argument files (p…
bd81be7
…ython#150980)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@clytaemnestra clytaemnestra clytaemnestra left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

argparse has problem parsing option files containing empty rows

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@savannahostrowski @clytaemnestra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.