Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-54732: Fix argparse arg file parsing#134115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
StanFromIreland wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromStanFromIreland:argparse-fix
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsLib/argparse.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2363,6 +2363,8 @@ def _read_args_from_files(self, arg_strings):
errors=_sys.getfilesystemencodeerrors()) as args_file:
arg_strings = []
for arg_line in args_file.read().splitlines():
if not arg_line.strip():
continue
for arg in self.convert_arg_line_to_args(arg_line):
arg_strings.append(arg)
arg_strings = self._read_args_from_files(arg_strings)
Expand Down
2 changes: 2 additions & 0 deletionsLib/test/test_argparse.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1715,6 +1715,7 @@ def setUp(self):
b'@hello'),
('invalid', b'@no-such-path\n'),
('undecodable', self.undecodable + b'\n'),
('blanklines', b'spam\n\nham\n')
]
for path, text in file_texts:
with open(path, 'wb') as file:
Expand All@@ -1736,6 +1737,7 @@ def setUp(self):
('-a B @recursive Y Z', NS(a='A', x=hello, y=['Y', 'Z'])),
('X @recursive Z -a B', NS(a='B', x='X', y=[hello, 'Z'])),
(["-a", "", "X", "Y"], NS(a='', x='X', y=['Y'])),
('@blanklines', NS(a=None, x='spam', y=['ham'])),
]
if os_helper.TESTFN_UNDECODABLE:
undecodable = os_helper.TESTFN_UNDECODABLE.lstrip(b'@')
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix issue in :mod:`argparse` where an args file with blank lines could not be parsed.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp