549,555c549,557 < PyThread_delete_key(autoTLSkey); < if ((autoTLSkey = PyThread_create_key()) == -1) < Py_FatalError("Could not allocate TLS entry"); < < /* re-associate the current thread state with the new key */ < if (PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0) < Py_FatalError("Couldn't create autoTLSkey mapping"); --- > if (tstate) { > PyThread_delete_key(autoTLSkey); > if ((autoTLSkey = PyThread_create_key()) == -1) > Py_FatalError("Could not allocate TLS entry"); > > /* re-associate the current thread state with the new key */ > if (PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0) > Py_FatalError("Couldn't create autoTLSkey mapping"); > }