[ python-Bugs-1396678 ] bsddb.__init__ causes error

SourceForge.net noreply at sourceforge.net
Wed Jan 4 10:56:32 CET 2006


Bugs item #1396678, was opened at 2006-01-04 10:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1396678&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Fabian_M (fmareyen)
Assigned to: Nobody/Anonymous (nobody)
Summary: bsddb.__init__ causes error

Initial Comment:
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()
                ...
        ...
-------------------------


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1396678&group_id=5470


More information about the Python-bugs-list mailing list