Python thinks program.py arg is a python.exe arg

  • I’m new to Python 3.14. I’m used to using Python 3.11.9.
  • Python 3.14 is on Windows 2025 Datacenter v24H2. Windows 2025 is also new to me. The .venv is activated.
  • I’m using Windows Terminal to do run the got.bat file.

I’m running a program using a batch file called got.bat, in debug mode. This is the only line in the got.bat file: .venv\scripts\python -m pdb ptool.py -tablescsv. I would like to start the pdb debugger for the program pacetool.py.

But I get this error when running got.

usage: python.exe -m pdb [-h] [-c command] (-m module | -p pid | pyfile) [args ...]
python.exe -m pdb: error: argument -p/--pid: invalid int value: 'acetablescsv'

Python thinks -tablegscsv is a argument to the python.exe when it’s an argument to my program pacetool.py.

Is there any way to fix this? Other programs I have been working with today on this same machine, same installation of python work fine.

What I tried

  • python -m pdb ptool.py -tablescsv
  • python -m pdb ptool.py -v Showing version info actually works for my program.

but I still get the same error.

I also tried this in got.bat: python -m pdb test.py -tablescsv and get the same error. test.py contains:

print("Hello world")
print(f"sys.argv={sys.argv}")

Did I find a bug? Python is only processing the first letter of my program argument “-tablescsv”. It should process the whole argument.

Thank you.

EDIT: When I do python -h there is no -p or -pid option listed.

You’re right. This seems to be a bug introduced when pdb switched from using getopt to argparse in 3.13.

A solution is to use -- to make it clear that all following arguments are not options:

python -m pdb -- test.py -pacetablescsv
  • Should I file a bug report? How do I do that?
  • Would the bug be for pdb?

Is there someone able to confirm this is a bug in Python 3.14? Maybe the bug has been filed already. I have never filed a bug before.

When I do python -m pdb -- test.py -tablescsv I get the same error above.

These work fine (without pdb):

  • python test.py
  • python test.py -myarg

Possibly the same bug

Possible workaround: Add a double hyphen after the script name. This should terminate option parsing and pass the rest on to your script. Note that your script will then see the "--" argument in sys.argv, so it’ll need to ignore that.

rosuav@sikorsky:~$ python3.15 -m pdb test.py -p
usage: python3.15 -m pdb [-h] [-c command] (-m module | -p pid | pyfile) [args ...]
python3.15 -m pdb: error: argument -p/--pid: expected one argument
rosuav@sikorsky:~$ python3.15 -m pdb test.py -- -p
> /home/rosuav/test.py(1)<module>()
-> import sys
(Pdb) r
['test.py', '--', '-p']
--Return--
> /home/rosuav/test.py(2)<module>()->None
-> print(sys.argv)
(Pdb) q

Note that using a single hyphen with multiple letters is often interpreted as either a series of separate flags (eg ls -lat is equivalent to ls -l -a -t), or as a flag with a parameter (eg git commit -mHello is equivalent to --message Hello), and a number of tools and libraries will assume that one or other of these is true. The normal way to write a longer parameter name is with a double hyphen. So another workaround would be to change your script to accept --pacetablegscsv, which pdb won’t expect and will therefore pass on to your script, rather than interpreting -p as an option and acetablegscsv as its parameter.

1 Like

Thank you. I will look into this.

This issue still seems like a bug to me (similar bug reports in a previous post) as when -m pdb is used, the command line processor should look at all parameters after test.py as going to the program test.py.

It does seem so; what I suggested is a workaround, a way to have the script work correctly in spite of the oddity.

And it gets more weird. This is another program on the same Python 3.14 machine that works with single dash long options.

python -m pdb piecework.py -daily -test -adminemailonly

The only difference is the program above uses more than on option and no options begin with “-p”. So there still seems to be a special case where pdb doesn’t work right.

See above for the explanation of single-hyphen options. PDB recognizes four such options: -h, -c, -m, and -p. If your word starts with one of those, it will be interpreted accordingly.

What you have here is a conflict of interpretation. Yes, it’s only a conflict because of a bug, but to understand the behaviour, you have to understand the conflict that’s happening :slight_smile:

I do recommend sticking to the common convention of using a double hyphen for word options, though. It’ll make a lot of things easier.