[Tutor] Pythonwin bug (or misfeature)?

Terry Carroll carroll at tjc.com
Wed Dec 31 01:31:58 EST 2003


I suspect I've found a bug (or perhaps just an unimplemented feature) in 
PythonWin. Apparently, the "browse" facility will not work with an 
instance of a class inherited from a dictionary (although it will, if you 
instead inherit from UserDict.UserDict).

First, a check: is this really a bug, or am I just doing something wrong?

Here's my code:

-----------------------------------------------
class udict1(dict):
    def __init__(self, indices=None, entries=None):
        dict.__init__(self)
        if indices is not None:
            for i in range(0,len(indices)):
                self[indices[i]] = entries[i]

import UserDict
class udict2(UserDict.UserDict):
    def __init__(self, indices=None, entries=None):
        UserDict.UserDict.__init__(self)
        if indices is not None:
            for i in range(0,len(indices)):
                self.data[indices[i]] = entries[i]

z1 = udict1([1,2,3,4,5], ['a1', 'b1','c1', 'd1', 'e1'])
z2 = udict2([1,2,3,4,5], ['a2', 'b2','c2', 'd2', 'e2'])
print "    dict: len is", len(z1), z1
print "userdict: len is", len(z2), z2
-----------------------------------------------
Both instances print, as expected:

    dict: len is 5 {1: 'a1', 2: 'b1', 3: 'c1', 4: 'd1', 5: 'e1'}
userdict: len is 5 {1: 'a2', 2: 'b2', 3: 'c2', 4: 'd2', 5: 'e2'}

It also runs okay under pythonwin; but, underpythonwin, when I use the 
Tools / Browser menu item, I can browse z2 (the UserDict-based instance), 
but not z1 (the dict-based instance).  Trying to browse z1 gives an error 
"This object cannot be browsed."

Am I making an error either in my code or in Pythonwin?

Second question: I'm using the Activestate Python (2.3.2).  Pythonwin is 
not a standard part of Python, right?  If that's right, I wouldn't report 
this as a bug through the Python project at Sourceforge; but where would I 
report it (I don't think it's Activestate's, either)?



-- 
Terry Carroll
Santa Clara, CA
carroll at tjc.com 




More information about the Tutor mailing list