Backport part of r86217: Fix issues when building without threads
diff --git a/Lib/collections.py b/Lib/collections.py
index 9b14431..a49ecc7 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -14,7 +14,7 @@
                       ifilter as _ifilter, imap as _imap
 try:
     from thread import get_ident
-except AttributeError:
+except ImportError:
     from dummy_thread import get_ident
 
 def _recursive_repr(user_function):