Changeset 2989

Show
Ignore:
Timestamp:
03/27/07 10:45:10 (2 years ago)
Author:
ed
Message:

Fixes a bug that happened when setting a property that expects a string to a value that happened to be the name of something in the Python builtins module. This addresses the error reported in Tracker #1015.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dPemMixin.py

    r2986 r2989  
    9292        # in the 'attProperties' parameter, in which all values are strings. 
    9393        # Convert these to the properties dict. 
     94        builtinNames = __builtins__.keys() 
    9495        if attProperties: 
    9596            for prop, val in attProperties.items(): 
     
    9798                    # attProperties has lower precedence, so skip it 
    9899                    continue 
    99                 try: 
    100                     attVal = eval(val) 
    101                 except: 
     100                # Note: we may need to add more string props here. 
     101                if (val in builtinNames) and (prop in ("Caption",  
     102                        "FontFace", "Picture", "RegID", "ToolTipText")): 
     103                    # It's a string that happens to be the same as a built-in name 
    102104                    attVal = val 
     105                else: 
     106                    try: 
     107                        attVal = eval(val) 
     108                    except: 
     109                        attVal = val 
    103110                properties[prop] = attVal 
    104111        properties = dictStringify(properties) 
     
    22842291    # Property definitions follow 
    22852292    BackColor = property(_getBackColor, _setBackColor, None, 
    2286             _("Specifies the background color of the object. (tuple)")) 
     2293            _("Specifies the background color of the object. (str, 3-tuple, or wx.Colour)")) 
    22872294 
    22882295    BorderColor = property(_getBorderColor, _setBorderColor, None, 
    22892296            _("""Specifies the color of the border drawn around the control, if any.  
    22902297 
    2291             Default='black'  (str or color tuple)""")) 
     2298            Default='black'  (str, 3-tuple, or wx.Colour)""")) 
    22922299     
    22932300    BorderLineStyle = property(_getBorderLineStyle, _setBorderLineStyle, None, 
     
    23722379 
    23732380    ForeColor = property(_getForeColor, _setForeColor, None, 
    2374             _("Specifies the foreground color of the object. (tuple)") ) 
     2381            _("Specifies the foreground color of the object. (str, 3-tuple, or wx.Colour)") ) 
    23752382 
    23762383    Height = property(_getHeight, _setHeight, None,