Open
Description
Bug report
Lib/dbm/__init__.py
contains a tiny if __name__ == "__main__"
section that repeatedly calls dbm.whichdb
on each of the given arguments:
Lines 188 to 190 in 841eacd
Test session:
$ python3
Python 3.13.0a3+ (heads/main-dirty:841eacd076, Jan 26 2024, 00:39:26) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbm
>>> import dbm.gnu
>>> import dbm.ndbm
>>> import dbm.dumb
>>> dbm.gnu.open("gnu.db", "c").close()
>>> dbm.ndbm.open("ndbm.db", "c").close()
>>> dbm.dumb.open("dumb.db", "c").close()
$ python3 -m dbm gnu.db ndbm.db dumb.db other.db
python3: No module named dbm.__main__; 'dbm' is a package and cannot be directly execute
$ python3 -m dbm.__init__ gnu.db ndbm.db dumb.db other.db
dbm.dumb dumb.db
dbm.gnu gnu.db
dbm.ndbm ndbm.db
UNKNOWN other.db
Some observations:
- there is no
__main__.py
; we must execute__init__.py
in order to run the script - there is no real CLI; just a list of arguments
Suggesting either to:
- remove the script
- promote it, by improving it (create
__main__.py
, add docs, add a simple argparse CLI, ...)