This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dbm.whichdb references unitialized 'ndbm' variable
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: eric.araujo, ezio.melotti, georg.brandl, pjenvey, python-dev, r.david.murray, umi
Priority: normal Keywords: easy

Created on 2013-02-13 03:18 by pjenvey, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch_17198 umi, 2013-07-07 10:57 Add an import of ndbm + test review
Messages (7)
msg181990 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2013-02-13 03:18
There are a couple references to an 'ndbm' variable/module in this function on Python 3.2 and above (and just one reference on default). It appears to be leftover from the 3.x reworking of this module
msg182068 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-14 03:00
The code appears to be correct, but I think we need to add an explicit import for ndbm in the __init__ file.  Right now I think it is only passing the tests because the test infrastructure imports all the dbm modules, including ndbm.

(I did not realize that doing 'import X.abc' causes 'abc' to be defined in the X.__init__.py module's namespace, but of course it must once I thought about it.)

The tricky bit here is writing a test case :)
msg182069 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-14 03:06
By the way, this will demonstrate the bug:

  touch foo.pag
  python -m dbm.__init__ foo

Perhaps that could be the basis for the test (using subprocess).
msg182070 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-14 03:10
Well, that test works only on 3.2/3.3, because by 3.4 the ndbm variable is only referenced in the second try; make it 'touch foo.db' instead for 3.4.
msg192537 - (view) Author: Valentina Mukhamedzhanova (umi) * Date: 2013-07-07 10:57
I added a testcase to demonstrate the bug and an import of ndbm to dbm.__init__.py to fix the bug.
msg192541 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-07 11:16
New changeset 65fce1dad331 by Ezio Melotti in branch '3.3':
#17198: Fix a NameError in the dbm module.  Patch by Valentina Mukhamedzhanova.
http://hg.python.org/cpython/rev/65fce1dad331

New changeset e91e9b9ba180 by Ezio Melotti in branch 'default':
#17198: merge with 3.3.
http://hg.python.org/cpython/rev/e91e9b9ba180
msg192542 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-07-07 11:16
Fixed, thanks for the patch!
History
Date User Action Args
2022-04-11 14:57:41adminsetgithub: 61400
2013-07-07 11:16:54ezio.melottisetstatus: open -> closed

assignee: ezio.melotti
versions: - Python 3.2
nosy: + ezio.melotti

messages: + msg192542
resolution: fixed
stage: needs patch -> resolved
2013-07-07 11:16:15python-devsetnosy: + python-dev
messages: + msg192541
2013-07-07 10:57:14umisetfiles: + patch_17198
nosy: + umi
messages: + msg192537

2013-02-14 03:10:45r.david.murraysetmessages: + msg182070
2013-02-14 03:06:55r.david.murraysettitle: dbm.whichdbm references non-existent 'ndbm' -> dbm.whichdb references unitialized 'ndbm' variable
messages: + msg182069
stage: needs patch
2013-02-14 03:00:08r.david.murraysetnosy: + r.david.murray

messages: + msg182068
stage: needs patch -> (no value)
2013-02-13 23:58:01eric.araujosetkeywords: + easy
nosy: + eric.araujo
2013-02-13 03:18:18pjenveycreate