Menu

#538 No module named new (216 - py3.1)

closed-fixed
nobody
None
5
2011-04-24
2011-03-04
pachalmars
No

Using pywin32-216.win32-py3.1, i get the error :

File "C:\Python31\lib\site-packages\win32com\client\__init__.py", line 320, in WithEvents
import new
ImportError: No module named new

Can be corrected by replacing lines 320-324 :

import new
events_class = getevents(clsid)
if events_class is None:
raise ValueError("This COM object does not support events.")
result_class = new.classobj("COMEventClass", (events_class, user_event_class), {})

with :

try:
from types import ClassType as new_type
except ImportError:
new_type = type # py3k
events_class = getevents(clsid)
if events_class is None:
raise ValueError("This COM object does not support events.")
result_class = new_type("COMEventClass", (events_class, user_event_class), {})

Discussion

  • Mark Hammond

    Mark Hammond - 2011-04-24

    Thanks! Fixed in rev 7f44ae5e7785

     
  • Mark Hammond

    Mark Hammond - 2011-04-24
    • status: open --> closed-fixed