diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2011-09-28 07:41:54 +0200 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2011-09-28 07:41:54 +0200 |
commit | d1d013c01c268d869597b35cbcd8b5d7c5baf2ae (patch) | |
tree | ac42dafc2067cce1d896e613738a7bd263601d36 /Modules/syslogmodule.c | |
parent | 5292805e03b80f41e608ea20ce6bc3f64d6566dd (diff) | |
download | cpython-d1d013c01c268d869597b35cbcd8b5d7c5baf2ae.tar.gz |
Implement PEP 393.
Diffstat (limited to 'Modules/syslogmodule.c')
-rw-r--r-- | Modules/syslogmodule.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 5b86963fc8..f6dadf43fa 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -70,7 +70,7 @@ syslog_get_argv(void) Py_ssize_t argv_len, scriptlen; PyObject *scriptobj; - Py_UNICODE *atslash, *atstart; + Py_ssize_t slash; PyObject *argv = PySys_GetObject("argv"); if (argv == NULL) { @@ -95,11 +95,13 @@ syslog_get_argv(void) return(NULL); } - atstart = PyUnicode_AS_UNICODE(scriptobj); - atslash = Py_UNICODE_strrchr(atstart, SEP); - if (atslash) { - return(PyUnicode_FromUnicode(atslash + 1, - scriptlen - (atslash - atstart) - 1)); + slash = PyUnicode_FindChar(scriptobj, SEP, + 0, PyUnicode_GET_LENGTH(scriptobj), -1); + if (slash == -2) + return NULL; + if (slash != -1) { + return PyUnicode_Substring(scriptobj, slash, + PyUnicode_GET_LENGTH(scriptobj)); } else { Py_INCREF(scriptobj); return(scriptobj); |