This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: import problem with 2.1c1
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, tim.peters
Priority: normal Keywords:

Created on 2001-04-14 09:39 by anonymous, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (3)
msg4249 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-04-14 09:39
I have built Python 2.1c1 under Linux and Irix
without the thread module.  When I import
threading an ImportError occurs as expected.
However, reissuing the import threading (not reloading)
statement does not raise an ImportError.  This causes a
failure in the regression tests with  the
following error message:

test test_threadedtempfile crashed --
exceptions.AttributeError: 'threading' module has no
attribute 'Event'

Here is a sample session from the interactive
interpreter.

>% ./python
Python 2.1c1 (#4, Apr 14 2001, 03:22:09) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)]
on linux2
Type "copyright", "credits" or "license" for more
information.
>>> import threading
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/raj/python/dist/src/Lib/threading.py",
line 5, in ?
    import thread
ImportError: No module named thread
>>> import threading # No import error here
>>> 

and under IRIX

% ./python 
Python 2.1c1 (#3, Apr 13 2001, 21:38:25) [C] on irix646
Type "copyright", "credits" or "license" for more
information.
>>> import threading
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File                              
"/usr/people/raj/python/dist/src/Lib/threading.py",                             
line 5, in
?                                                   
    import
thread                                                   
ImportError: No module named thread                 
>>> import threading # Again no import error
here                               
>>>
msg4250 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-04-14 20:19
Logged In: YES 
user_id=31435

Assigned to Guido, because I suspect he just fixed this in 
the CVS tree.
msg4251 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-04-14 23:54
Logged In: YES 
user_id=6380

I fixed the specific issue with the test suite.

The more general issue can't be fixed.  The first time you
import threading it fails, not on the import of threading
itself (which is always around), but on the import of thread
(which is a built-in module that's only there when you
enable threading).  The second time you import threading,
you get a stub of the threading module (initialized up to
the point where threading.py tried to import thread). 
Unfortunately there are good and deep reasons why the
threading module can't just be deleted after its
initialization failed.  (One being that you might want to
debug the situation.)
History
Date User Action Args
2022-04-10 16:03:57adminsetgithub: 34326
2001-04-14 09:39:50anonymouscreate