-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed as not planned
Closed as not planned
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Consider the code
import argparse
import sys
print(f"argv = {sys.argv}")
parser = argparse.ArgumentParser(description='Print value.')
parser.add_argument('--value', type=str, dest="value")
args = parser.parse_args()
print(f"Passed --value = '{args.value}'")
Running as:
python temp.py --value ''
Result on Windows:
argv = ['temp.py', '--value']
usage: temp.py [-h] [--value VALUE]
temp.py: error: argument --value: expected one argument
Result on Linux (I used Ubuntu from WSL):
argv = ['temp.py', '--value', '']
Passed --value = ''
As a simple solution, we can just remove empty values from the argv to have the same initial list of arguments on both OSes. If we need to preserve the existing logic of taking empty string on Linux, we may implement a smarter algorithm. Feel free to hint me which way we will go if any. I'll be honored to contribute to Python 馃槉.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

