summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2022-06-23 03:09:57 (GMT)
committerGitHub <noreply@github.com>2022-06-23 03:09:57 (GMT)
commit9877f4c6249ac7f374dc48beaf21ea2bf3ee6996 (patch)
treeeffea480b2dc3d7f87af00f3b8ee97c49f9e6a50 /Lib/argparse.py
parent576dd901170af30fc50b0a7f07a388b38fd724a9 (diff)
downloadcpython-9877f4c6249ac7f374dc48beaf21ea2bf3ee6996.zip
cpython-9877f4c6249ac7f374dc48beaf21ea2bf3ee6996.tar.gz
cpython-9877f4c6249ac7f374dc48beaf21ea2bf3ee6996.tar.bz2
gh-85308: argparse: Use filesystem encoding for arguments file (GH-93277)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 1c5520c..02e98bb 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -2161,7 +2161,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# replace arguments referencing files with the file content
else:
try:
- with open(arg_string[1:]) as args_file:
+ with open(arg_string[1:],
+ encoding=_sys.getfilesystemencoding(),
+ errors=_sys.getfilesystemencodeerrors()) as args_file:
arg_strings = []
for arg_line in args_file.read().splitlines():
for arg in self.convert_arg_line_to_args(arg_line):