| LEFT | RIGHT |
| 1 | 1 |
| 2 /* Thread module */ | 2 /* Thread module */ |
| 3 /* Interface to Sjoerd's portable C thread library */ | 3 /* Interface to Sjoerd's portable C thread library */ |
| 4 | 4 |
| 5 #include "Python.h" | 5 #include "Python.h" |
| 6 | 6 |
| 7 #ifndef WITH_THREAD | 7 #ifndef WITH_THREAD |
| 8 #error "Error! The rest of Python is not compiled with thread support." | 8 #error "Error! The rest of Python is not compiled with thread support." |
| 9 #error "Rerun configure, adding a --with-threads option." | 9 #error "Rerun configure, adding a --with-threads option." |
| 10 #error "Then run `make clean' followed by `make'." | 10 #error "Then run `make clean' followed by `make'." |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 if (localdict == NULL) | 197 if (localdict == NULL) |
| 198 goto err; | 198 goto err; |
| 199 | 199 |
| 200 tdict = PyThreadState_GetDict(); | 200 tdict = PyThreadState_GetDict(); |
| 201 if (tdict == NULL) { | 201 if (tdict == NULL) { |
| 202 PyErr_SetString(PyExc_SystemError, | 202 PyErr_SetString(PyExc_SystemError, |
| 203 "Couldn't get thread-state dictionary"); | 203 "Couldn't get thread-state dictionary"); |
| 204 goto err; | 204 goto err; |
| 205 } | 205 } |
| 206 | 206 |
| 207 » if (PyDict_SetItem(tdict, self->key, localdict) < 0) | 207 » if (PyDict_SetItem(tdict, self->key, localdict) < 0) { |
| 208 » » Py_DECREF(localdict); |
| 208 goto err; | 209 goto err; |
| 210 } |
| 209 Py_DECREF(localdict); | 211 Py_DECREF(localdict); |
| 210 | 212 |
| 211 return (PyObject *)self; | 213 return (PyObject *)self; |
| 212 | 214 |
| 213 err: | 215 err: |
| 214 Py_DECREF(self); | 216 Py_DECREF(self); |
| 215 return NULL; | 217 return NULL; |
| 216 } | 218 } |
| 217 | 219 |
| 218 static int | 220 static int |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 return ldict; | 294 return ldict; |
| 293 } | 295 } |
| 294 | 296 |
| 295 static int | 297 static int |
| 296 local_setattro(localobject *self, PyObject *name, PyObject *v) | 298 local_setattro(localobject *self, PyObject *name, PyObject *v) |
| 297 { | 299 { |
| 298 PyObject *ldict = _ldict(self); | 300 PyObject *ldict = _ldict(self); |
| 299 if (ldict == NULL) | 301 if (ldict == NULL) |
| 300 return -1; | 302 return -1; |
| 301 | 303 |
| 302 » if (v != NULL) | 304 » if (v != NULL) { |
| 303 return PyDict_SetItem(ldict, name, v); | 305 return PyDict_SetItem(ldict, name, v); |
| 304 » else { | 306 » } else { |
| 305 int res; | 307 int res; |
| 306 res = PyDict_DelItem(ldict, name); | 308 res = PyDict_DelItem(ldict, name); |
| 307 » » if ((res < 0) | 309 » » if ((res < 0) && PyErr_ExceptionMatches(PyExc_KeyError)) { |
| 308 » » && PyErr_ExceptionMatches(PyExc_KeyError)) { | |
| 309 PyErr_SetObject(PyExc_AttributeError, name); | 310 PyErr_SetObject(PyExc_AttributeError, name); |
| 310 } | 311 } |
| 311 return res; | 312 return res; |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 | 315 |
| 315 static PyObject * | 316 static PyObject * |
| 316 local_getdict(localobject *self, void *closure) | 317 local_getdict(localobject *self, void *closure) |
| 317 { | 318 { |
| 318 PyObject *ldict = _ldict(self); | 319 PyObject *ldict = _ldict(self); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 Py_INCREF(&Locktype); | 705 Py_INCREF(&Locktype); |
| 705 PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype); | 706 PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype); |
| 706 | 707 |
| 707 Py_INCREF(&localtype); | 708 Py_INCREF(&localtype); |
| 708 if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) | 709 if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) |
| 709 return; | 710 return; |
| 710 | 711 |
| 711 /* Initialize the C thread library */ | 712 /* Initialize the C thread library */ |
| 712 PyThread_init_thread(); | 713 PyThread_init_thread(); |
| 713 } | 714 } |
| LEFT | RIGHT |