Issue 34110: cPickle may raise AttributeError when loading concurrently in threads

If two threads use cPickle to load objects simultaneously, one thread may raise an AttributeError. This problem is caused by the partially loaded module.

To reproduce, create a file 'foo.py':
import time
time.sleep(0.1)
class foo():
    pass

Then in main.py:
import threading
import cPickle 

threads = [threading.Thread(target=cPickle.loads, args=('cfoo\nfoo\np0\n.',)) for _ in range(2)]
[thread.start() for thread in threads]
[thread.join() for thread in threads]

Run main.py, there should be a crash:
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
AttributeError: 'module' object has no attribute 'foo'