Reputation: 972
> rpm -qi python3 Name python3 Version : 3.13.1 Release : 2.fc41 Architecture: x86_64 Source RPM : python3.13-3.13.1-2.fc41.src.rpm Build Date : Tue 10 Dec 2024 10:31:11 GMT
In here py changelog, gh-113548 is supposed to have fixed a argument parsing bug when using pdb with argparse.
I read that is fixed in version Python 3.13.0 alpha 6 released 2024-04-09.
and yet the problem still occurs, when debugging like this:
python -m pdb <myscript.py> -- --arg1 arg1value --arg2 arg2value --arg3 arg3value --arg4 arg4value --arg5
(Pdb) p sys.argv
['myscript.py', '--', '--arg1', 'arg1value', '--arg2', 'arg2value', '--arg3', 'arg3value', '--arg4' , 'arg4value', '--arg5']
but when the argparse code runs
parser = argparse.ArgumentParser(description='xxx')
parser.add_argument("--arg1", help="xxxx", action="store", type=int, required=True)
parser.add_argument("--arg2", help="xxxx", action="store", required=True)
parser.add_argument("--arg3", help="xxxx", action="store", required=True)
parser.add_argument("--arg4", help="xxx", action="store", required=True)
group = parser.add_mutually_exclusive_group(required=False)
group.add_argument("--arg5", help="xxx", action="store_true")
group.add_argument("--arg6", help="xxx", action="store_true")
parser.add_argument("--arg7", help="xxx", required=False, type=lambda t: t.split(','))
parser.add_argument("--arg8", help="xxx", action="store_true", required=False)
args = parser.parse_args()
It fails with
myscript.py: error: the following arguments are required: --arg1, --arg2, --arg3, --arg4
Upvotes: 0
Views: 30