Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31095/Pythonwin/pywin/tools
Modified Files:
browser.py
Log Message:
modernize type handling in pythonwin's browser and make py3k-friendly
Index: browser.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/tools/browser.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** browser.py 14 Jan 2009 12:11:04 -0000 1.15
--- browser.py 25 Jan 2009 03:08:42 -0000 1.16
***************
*** 6,9 ****
--- 6,11 ----
# or
# >>> browser.Browse(your_module)
+ import sys
+ import types
import __main__
import win32ui
***************
*** 11,15 ****
import hierlist
- from types import *
special_names = [ '__doc__', '__name__', '__self__' ]
--- 13,16 ----
***************
*** 265,286 ****
TypeMap = { type : HLIClass,
! FunctionType: HLIFunction,
tuple: HLITuple,
dict: HLIDict,
list: HLIList,
! ModuleType: HLIModule,
! CodeType : HLICode,
! BuiltinFunctionType : HLIBuiltinFunction,
! FrameType : HLIFrame,
! TracebackType : HLITraceback,
str : HLIString,
int: HLIPythonObject,
! ## LongType: HLIPythonObject, - hrm - fixme for py2k
float: HLIPythonObject,
}
- try:
- TypeMap[UnicodeType] = HLIString
- except NameError:
- pass # Python 1.5 - no Unicode - no problem!
def MakeHLI( ob, name=None ):
--- 266,285 ----
TypeMap = { type : HLIClass,
! types.FunctionType: HLIFunction,
tuple: HLITuple,
dict: HLIDict,
list: HLIList,
! types.ModuleType: HLIModule,
! types.CodeType : HLICode,
! types.BuiltinFunctionType : HLIBuiltinFunction,
! types.FrameType : HLIFrame,
! types.TracebackType : HLITraceback,
str : HLIString,
+ unicode : HLIString,
int: HLIPythonObject,
! long: HLIPythonObject,
! bool: HLIPythonObject,
float: HLIPythonObject,
}
def MakeHLI( ob, name=None ):
***************
*** 288,291 ****
--- 287,293 ----
cls = TypeMap[type(ob)]
except KeyError:
+ # hrmph - this check gets more and more bogus as Python
+ # improves. Its possible we should just *always* use
+ # HLIInstance?
if hasattr(ob, '__class__'): # 'new style' class
cls = HLIInstance
|