[Scipy-tickets] [SciPy] #1136: ppimport fails to postpone import scitools

SciPy Trac scipy-tickets@scipy....
Wed Mar 24 07:35:25 CDT 2010


#1136: ppimport fails to postpone import scitools
--------------------+-------------------------------------------------------
 Reporter:  pbrod   |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:  0.8.0   
Component:  Other   |     Version:  0.7.0   
 Keywords:          |  
--------------------+-------------------------------------------------------
 ppimport fails to postpone import scitools.
 Running the following simple example

 {{{
 from scipy.misc.ppimport import ppimport
 st = ppimport('scitools')

 def main():
     t = st.numpytools.linspace(0,1)
     print(t)

 if __name__ == '__main__':
     main()
 }}}

 gives the following error:

 {{{
 scitools.easyviz backend is matplotlib
 Traceback (most recent call last):
   File
 "C:\pab\matlab\wafogooglesvn\pywafo\pywafo\src\wafo\test_ppimport.py",
 line 9, in <module>
     main()
   File
 "C:\pab\matlab\wafogooglesvn\pywafo\pywafo\src\wafo\test_ppimport.py",
 line 5, in main
     t = st.numpytools.linspace(0,1)
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 303,
 in __getattr__
     module = self._ppimport_importer()
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 282,
 in _ppimport_importer
     self.__dict__ = module.__dict__
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 296,
 in __setattr__
     module = self._ppimport_importer()
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 264,
 in _ppimport_importer
     assert module is self,`(module, self)`
 AssertionError: (<module 'scitools' from 'C:\Python26\lib\site-
 packages\scitools\__init__.pyc'>, <module 'scitools' from 'sys.path'
 [import postponed]>)
 }}}

 A suggested fix to this bug is to replace line 282, in _ppimport_importer
 with

 {{{
 self.__dict__.update(module.__dict__)
 }}}

 Running again gives another bug:

 {{{
 Traceback (most recent call last):
   File
 "C:\pab\matlab\wafogooglesvn\pywafo\pywafo\src\wafo\test_ppimport.py",
 line 9, in <module>
     main()
   File
 "C:\pab\matlab\wafogooglesvn\pywafo\pywafo\src\wafo\test_ppimport.py",
 line 5, in main
     t = st.numpytools.linspace(0,1)
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 303,
 in __getattr__
     module = self._ppimport_importer()
   File "C:\Python26\lib\site-packages\scipy\misc\ppimport.py", line 288,
 in _ppimport_importer
     test = Tester(os.path.dirname(module)).test
   File "C:\Python26\lib\ntpath.py", line 205, in dirname
     return split(p)[0]
   File "C:\Python26\lib\ntpath.py", line 170, in split
     d, p = splitdrive(p)
   File "C:\Python26\lib\ntpath.py", line 125, in splitdrive
     if p[1:2] == ':':
 TypeError: 'module' object is unsubscriptable
 }}}

 A suggested fix to this bug is to replace line 288, in _ppimport_importer
 with

 {{{
 test = Tester(os.path.dirname(module.__file__)).test
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1136>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list