Issue 17198: dbm.whichdb references unitialized 'ndbm' variable (original) (raw)

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:41 admin set github: 61400
2013-07-07 11:16:54 ezio.melotti set status: open -> closedassignee: ezio.melottiversions: - Python 3.2nosy: + ezio.melottimessages: + resolution: fixedstage: needs patch -> resolved
2013-07-07 11:16:15 python-dev set nosy: + python-devmessages: +
2013-07-07 10:57:14 umi set files: + patch_17198nosy: + umimessages: +
2013-02-14 03:10:45 r.david.murray set messages: +
2013-02-14 03:06:55 r.david.murray set title: dbm.whichdbm references non-existent 'ndbm' -> dbm.whichdb references unitialized 'ndbm' variablemessages: + stage: needs patch
2013-02-14 03:00:08 r.david.murray set nosy: + r.david.murraymessages: + stage: needs patch -> (no value)
2013-02-13 23:58:01 eric.araujo set keywords: + easynosy: + eric.araujo
2013-02-13 03🔞18 pjenvey create