[Python-checkins] r80459 - python/branches/py3k/Modules/syslogmodule.c
sean.reifschneider
python-checkins at python.org
Sun Apr 25 08:31:55 CEST 2010
Author: sean.reifschneider
Date: Sun Apr 25 08:31:55 2010
New Revision: 80459
Log:
Porting commit 80458 to python 3
Modified:
python/branches/py3k/Modules/syslogmodule.c
Modified: python/branches/py3k/Modules/syslogmodule.c
==============================================================================
--- python/branches/py3k/Modules/syslogmodule.c (original)
+++ python/branches/py3k/Modules/syslogmodule.c Sun Apr 25 08:31:55 2010
@@ -56,6 +56,7 @@
/* only one instance, only one syslog, so globals should be ok */
static PyObject *S_ident_o = NULL; /* identifier, held by openlog() */
+static char S_log_open = 0;
static PyObject *
@@ -135,6 +136,7 @@
*/
openlog(S_ident_o ? _PyUnicode_AsString(S_ident_o) : NULL, logopt, facility);
+ S_log_open = 1;
Py_INCREF(Py_None);
return Py_None;
@@ -160,8 +162,8 @@
if (message == NULL)
return NULL;
- /* call openlog if no current identifier */
- if (!S_ident_o) {
+ /* if log is not opened, open it now */
+ if (!S_log_open) {
PyObject *openargs;
/* Continue even if PyTuple_New fails, because openlog(3) is optional.
@@ -184,9 +186,12 @@
static PyObject *
syslog_closelog(PyObject *self, PyObject *unused)
{
- closelog();
- Py_XDECREF(S_ident_o);
- S_ident_o = NULL;
+ if (S_log_open) {
+ closelog();
+ Py_XDECREF(S_ident_o);
+ S_ident_o = NULL;
+ S_log_open = 0;
+ }
Py_INCREF(Py_None);
return Py_None;
}
More information about the Python-checkins
mailing list