| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3de0f55 commit 341b86e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,17 +270,29 @@ static PyMemberDef union_members[] = { | |||
| 270 | 270 | {0} | |
| 271 | 271 | }; | |
| 272 | 272 | ||
| 273 | - static PyObject * | ||
| 274 | - union_getitem(PyObject *self, PyObject *item) | ||
| 273 | + // Populate __parameters__ if needed. | ||
| 274 | + static int | ||
| 275 | + union_init_parameters(unionobject *alias) | ||
| 275 | 276 | { | |
| 276 | - unionobject *alias = (unionobject *)self; | ||
| 277 | - // Populate __parameters__ if needed. | ||
| 277 | + int result = 0; | ||
| 278 | + Py_BEGIN_CRITICAL_SECTION(alias); | ||
| 278 | 279 | if (alias->parameters == NULL) { | |
| 279 | 280 | alias->parameters = _Py_make_parameters(alias->args); | |
| 280 | 281 | if (alias->parameters == NULL) { | |
| 281 | - return NULL; | ||
| 282 | + result = -1; | ||
| 282 | 283 | } | |
| 283 | 284 | } | |
| 285 | + Py_END_CRITICAL_SECTION(); | ||
| 286 | + return result; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + static PyObject * | ||
| 290 | + union_getitem(PyObject *self, PyObject *item) | ||
| 291 | + { | ||
| 292 | + unionobject *alias = (unionobject *)self; | ||
| 293 | + if (union_init_parameters(alias) < 0) { | ||
| 294 | + return NULL; | ||
| 295 | + } | ||
| 284 | 296 | ||
| 285 | 297 | PyObject *newargs = _Py_subs_parameters(self, alias->args, alias->parameters, item); | |
| 286 | 298 | if (newargs == NULL) { | |
@@ -314,11 +326,8 @@ static PyObject * | |||
| 314 | 326 | union_parameters(PyObject *self, void *Py_UNUSED(unused)) | |
| 315 | 327 | { | |
| 316 | 328 | unionobject *alias = (unionobject *)self; | |
| 317 | - if (alias->parameters == NULL) { | ||
| 318 | - alias->parameters = _Py_make_parameters(alias->args); | ||
| 319 | - if (alias->parameters == NULL) { | ||
| 320 | - return NULL; | ||
| 321 | - } | ||
| 329 | + if (union_init_parameters(alias) < 0) { | ||
| 330 | + return NULL; | ||
| 322 | 331 | } | |
| 323 | 332 | return Py_NewRef(alias->parameters); | |
| 324 | 333 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments