Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 15595:0f42f6669e80 legacy-trunk
Add definitions for PySys_ResetWarnOptions() and
PySys_AddWarnOption().
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 15 Dec 2000 22:02:05 +0000 |
| parents | f0ca4c67957b |
| children | 1a00d21910c8 |
comparison
equal
deleted
inserted
replaced
| 15594:1779f8574a83 | 15595:0f42f6669e80 |
|---|---|
| 387 PyObject *v = PyList_AsTuple(list); | 387 PyObject *v = PyList_AsTuple(list); |
| 388 Py_DECREF(list); | 388 Py_DECREF(list); |
| 389 list = v; | 389 list = v; |
| 390 } | 390 } |
| 391 return list; | 391 return list; |
| 392 } | |
| 393 | |
| 394 static PyObject *warnoptions = NULL; | |
| 395 | |
| 396 void | |
| 397 PySys_ResetWarnOptions(void) | |
| 398 { | |
| 399 if (warnoptions == NULL || !PyList_Check(warnoptions)) | |
| 400 return; | |
| 401 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); | |
| 402 } | |
| 403 | |
| 404 void | |
| 405 PySys_AddWarnOption(char *s) | |
| 406 { | |
| 407 PyObject *str; | |
| 408 | |
| 409 if (warnoptions == NULL || !PyList_Check(warnoptions)) { | |
| 410 Py_XDECREF(warnoptions); | |
| 411 warnoptions = PyList_New(0); | |
| 412 if (warnoptions == NULL) | |
| 413 return; | |
| 414 } | |
| 415 str = PyString_FromString(s); | |
| 416 if (str != NULL) { | |
| 417 PyList_Append(warnoptions, str); | |
| 418 Py_DECREF(str); | |
| 419 } | |
| 392 } | 420 } |
| 393 | 421 |
| 394 /* XXX This doc string is too long to be a single string literal in VC++ 5.0. | 422 /* XXX This doc string is too long to be a single string literal in VC++ 5.0. |
| 395 Two literals concatenated works just fine. If you have a K&R compiler | 423 Two literals concatenated works just fine. If you have a K&R compiler |
| 396 or other abomination that however *does* understand longer strings, | 424 or other abomination that however *does* understand longer strings, |
| 551 Py_XDECREF(v); | 579 Py_XDECREF(v); |
| 552 PyDict_SetItemString(sysdict, "winver", | 580 PyDict_SetItemString(sysdict, "winver", |
| 553 v = PyString_FromString(PyWin_DLLVersionString)); | 581 v = PyString_FromString(PyWin_DLLVersionString)); |
| 554 Py_XDECREF(v); | 582 Py_XDECREF(v); |
| 555 #endif | 583 #endif |
| 584 if (warnoptions == NULL) { | |
| 585 warnoptions = PyList_New(0); | |
| 586 } | |
| 587 else { | |
| 588 Py_INCREF(warnoptions); | |
| 589 } | |
| 590 if (warnoptions != NULL) { | |
| 591 PyDict_SetItemString(sysdict, "warnoptions", v = warnoptions); | |
| 592 Py_DECREF(v); | |
| 593 } | |
| 594 | |
| 556 if (PyErr_Occurred()) | 595 if (PyErr_Occurred()) |
| 557 return NULL; | 596 return NULL; |
| 558 return m; | 597 return m; |
| 559 } | 598 } |
| 560 | 599 |
