ipython/ipython — Issue #966: dreload fails on Windows XP with iPython 0.11 "Unexpected Error"
Author: buchs-kevin
Created: 2011-11-02 19:13:53+00:00
State: open

I tried to reload a module which I had edited and I got this traceback:

In [97]: dreload bmpd.device
-------> dreload(bmpd.device)
Reloading bmpd.device
Reloading bmpd.device.AmDevice
Reloading bmpd.device.serial
Reloading serial
Reloading serial.sys
Reloading serial.os
Reloading os
Reloading errno
Reloading nt
Reloading ntpath
Reloading stat
Reloading genericpath
Reloading warnings
Reloading linecache
Reloading types
Reloading _warnings
Reloading UserDict
Reloading _abcoll
Reloading abc
Reloading _weakrefset
Reloading _weakref
Reloading copy_reg
Reloading serial.serialwin32
Reloading serial.ctypes
Reloading ctypes
Reloading ctypes.os
Reloading ctypes.sys
Reloading ctypes._ctypes
Reloading _ctypes
Reloading ctypes.struct
Reloading struct
Reloading _struct
Reloading ctypes.ctypes
Reloading serial.win32
Reloading ctypes.HANDLE
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (16, 0))

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
n:\PC_Software\dev\Python_Analysis_ws\Python_Analysis\ in ()

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in reload(module, ex
clude)
175 __builtin__.__import__ = deep_import_hook
176 try:
--> 177 ret = deep_reload_hook(module)
178 finally:
179 __builtin__.__import__ = original_import

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_reload_hook(
module)
157 pname = name[:i]
158 parent = sys.modules[pname]
--> 159 return import_module(name[i+1:], name, parent)
160
161 # Save the original hooks

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in import_module(par
tname, fqname, parent)
141
142 try:
--> 143 m = imp.load_module(fqname, fp, pathname, stuff)
144 finally:
145 if fp: fp.close()

n:\PC_Software\dev\Python_Analysis_ws\Python_Analysis\bmpd\device\__init__.pyc in ()
1
2
----> 3 from AmDevice import *
4 import RfParams

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_import_hook(
name, globals, locals, fromlist, level)
34 # with from __future__ import absolute_import

35 parent = determine_parent(globals)
---> 36 q, tail = find_head_package(parent, name)
37 m = load_tail(q, tail)
38 if not fromlist:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in find_head_package
(parent, name)
74 else:
75 qname = head
---> 76 q = import_module(head, qname, parent)
77 if q: return q, tail
78 if parent:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in import_module(par
tname, fqname, parent)
141
142 try:
--> 143 m = imp.load_module(fqname, fp, pathname, stuff)
144 finally:
145 if fp: fp.close()

n:\PC_Software\dev\Python_Analysis_ws\Python_Analysis\bmpd\device\AmDevice.py in ()
37
38 # The latest device USB stack uses virtual serial port

---> 39 import serial
40 import struct
41 import time

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_import_hook(
name, globals, locals, fromlist, level)
34 # with from __future__ import absolute_import

35 parent = determine_parent(globals)
---> 36 q, tail = find_head_package(parent, name)
37 m = load_tail(q, tail)
38 if not fromlist:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in find_head_package
(parent, name)
79 qname = head
80 parent = None
---> 81 q = import_module(head, qname, parent)
82 if q: return q, tail
83 raise ImportError, "No module named " + qname

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in import_module(par
tname, fqname, parent)
141
142 try:
--> 143 m = imp.load_module(fqname, fp, pathname, stuff)
144 finally:
145 if fp: fp.close()

c:\python27\lib\site-packages\pyserial-2.5-py2.7-win32.egg\serial\__init__.pyc in ()
17 # chose an implementation, depending on os

18 if os.name == 'nt': #sys.platform == 'win32':
---> 19 from serialwin32 import *
20 elif os.name == 'posix':
21 from serialposix import *

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_import_hook(
name, globals, locals, fromlist, level)
34 # with from __future__ import absolute_import

35 parent = determine_parent(globals)
---> 36 q, tail = find_head_package(parent, name)
37 m = load_tail(q, tail)
38 if not fromlist:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in find_head_package
(parent, name)
74 else:
75 qname = head
---> 76 q = import_module(head, qname, parent)
77 if q: return q, tail
78 if parent:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in import_module(par
tname, fqname, parent)
141
142 try:
--> 143 m = imp.load_module(fqname, fp, pathname, stuff)
144 finally:
145 if fp: fp.close()

c:\python27\lib\site-packages\pyserial-2.5-py2.7-win32.egg\serial\serialwin32.pyc in ()
10
11 import ctypes
---> 12 import win32
13
14 from serialutil import *

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_import_hook(
name, globals, locals, fromlist, level)
34 # with from __future__ import absolute_import

35 parent = determine_parent(globals)
---> 36 q, tail = find_head_package(parent, name)
37 m = load_tail(q, tail)
38 if not fromlist:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in find_head_package
(parent, name)
74 else:
75 qname = head
---> 76 q = import_module(head, qname, parent)
77 if q: return q, tail
78 if parent:

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in import_module(par
tname, fqname, parent)
141
142 try:
--> 143 m = imp.load_module(fqname, fp, pathname, stuff)
144 finally:
145 if fp: fp.close()

c:\python27\lib\site-packages\pyserial-2.5-py2.7-win32.egg\serial\win32.pyc in ()
1 from ctypes import *
----> 2 from ctypes.wintypes import HANDLE
3 from ctypes.wintypes import BOOL
4 from ctypes.wintypes import LPCWSTR
5 _stdcall_libraries = {}

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in deep_import_hook(
name, globals, locals, fromlist, level)
39 return q
40 if hasattr(m, "__path__"):
---> 41 ensure_fromlist(m, fromlist)
42 return m
43

c:\python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\lib\deepreload.pyc in ensure_fromlist(m
, fromlist, recursive)
117 submod = import_module(sub, subname, m)
118 if not submod:
--> 119 raise ImportError, "No module named " + subname
120
121 # Need to keep track of what we've already reloaded to prevent cyclic evil

ImportError: No module named ctypes.HANDLE

In [98]: