-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-featureA feature request or enhancementA feature request or enhancement
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
if __name__ == "__main__": | |
for filename in sys.argv[1:]: | |
print(whichdb(filename) or "UNKNOWN", filename) |
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, ...)
Linked PRs
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-featureA feature request or enhancementA feature request or enhancement