`python -m tqdm --log` with a missing or invalid level raises `IndexError` / `AttributeError`
Author: Q7xM4Created Sep 10, 2026Updated Sep 10, 2026
- I have marked all applicable categories:
- exception-raising bug
- visual output bug
- I have visited the source website, and in particular read the known issues
- I have searched through the issue tracker for duplicates
- I have mentioned version numbers, operating system and
environment, where applicable:
import tqdm, sys print(tqdm.__version__, sys.version, sys.platform)
When I was using tqdm, I found that when there was a problem with the parameters, it would not report a unified error, but rather a more profound error.
This might be because --log is parsed before the try block, and this block converts illegal command-line options into TqdmKeyError / TqdmTypeError, resulting in the following exceptions being unable to be caught:
--logis the last parameter:argv[log_idx + 1]exceeds the bounds, throwingIndexError.--log NOTALEVEL:getattr(logging, logLevel)fails, throwingAttributeError.
Reproduction 1.
$ python -m tqdm --log </dev/nulOutput:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/asfdf/Desktop/issues/tqdm-all/tqdm/tqdm/__main__.py", line 3, in <module>
main()
File "/home/asfdf/Desktop/issues/tqdm-all/tqdm/tqdm/cli.py", line 177, in main
logLevel = argv[log_idx + 1]
~~~~^^^^^^^^^^^^^
IndexError: list index out of range$ python -m tqdm --log NOTALEVEL </dev/nullOutput:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/asfdf/Desktop/issues/tqdm-all/tqdm/tqdm/__main__.py", line 3, in <module>
main()
File "/home/asfdf/Desktop/issues/tqdm-all/tqdm/tqdm/cli.py", line 178, in main
logging.basicConfig(level=getattr(logging, logLevel),
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'logging' has no attribute 'NOTALEVEL'It is recommended to move the parsing of --log into the try block and add checks for missing parameters and log level validation.
Environment
>>> print(tqdm.__version__, sys.version, sys.platform)
4.70.1.dev7+g8d6ff8de5 3.12.3 (main, Jun 19 2026, 12:46:00) [GCC 13.3.0] linuxSource: tqdm/tqdm