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: bsddb.__init__ causes error
Type: Stage:
Components: None Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fmareyen, georg.brandl, nnorwitz
Priority: normal Keywords:

Created on 2006-01-04 09:56 by fmareyen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
show_error.py fmareyen, 2006-01-08 19:02 a short example-file to demonstrate the error
Messages (4)
msg27245 - (view) Author: Fabian_M (fmareyen) Date: 2006-01-04 09:56
I've found an Error in the bsddb.__init__.py-module:

pythonversion = 2.4 (problem may also be in version 2.3)

After creating and closing a db with bsddb.hashopen I
called globals().
Next there occured an Error:


#Error-Message
---------------------------------------------
>>> globals()
{'__builtins__': <module '__builtin__' (built-in)>,
'f4': <function f4 at 0x00B5A130>, 'dbtest1': Traceback
(most recent call last):
  File "<stdin>", line 1, in ?
  File "D:\Programme\python24\lib\UserDict.py", line
162, in __repr__
    return repr(dict(self.iteritems()))
  File "<string>", line 46, in iteritems
  File "<string>", line 4, in _make_iter_cursor
AttributeError: 'NoneType' object has no attribute 'cursor'
>>>
----------------------------------------------


#Way of the Error
The way of the Error is:
1.
globals() asked for bsddb._DBWithCursor.__repr__ with
the __repr__-method inherriting from bsddb._iter_mixin
based on UserDict.DictMixin.
2.
The __repr__-method in UserDict.DictMixin at line 162
calls self.iteritems overwritten by
bsddb._iter_mixin.iteritems at line 113.
3.
This method calls self._make_iter_cursor (line 115).
bsddb._iter_mixin._make_iter_cursor calls bsddb.db
which was set to None at closing the bd with db.close()
at line 223.


#Solution:
That way the error was created. To avoid this, the
bsddb._iter_mixin.iteritems-method should be something
like this:
-------------------------
def iteritems(self):
        if not self.db:
                return ""
        try:
                cur = self._make_iter_cursor()
                ...
        ...
-------------------------
msg27246 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-01-05 05:54
Logged In: YES 
user_id=33168

Can you attach a complete test case which demonstrates this
behaviour?
msg27247 - (view) Author: Fabian_M (fmareyen) Date: 2006-01-08 17:07
Logged In: YES 
user_id=1418961

I've added an example-file.
msg27248 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-19 00:54
Logged In: YES 
user_id=1188172

Thanks for the report. Fixed in rev. 42480.
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42760
2006-01-04 09:56:31fmareyencreate