diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-09 04:58:54 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-09 04:58:54 (GMT) |
commit | dd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch) | |
tree | b2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /PC/_subprocess.c | |
parent | e98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff) | |
download | cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.zip cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.gz cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.bz2 |
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
Diffstat (limited to 'PC/_subprocess.c')
-rw-r--r-- | PC/_subprocess.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/PC/_subprocess.c b/PC/_subprocess.c index 60f3bfe..c93f84b 100644 --- a/PC/_subprocess.c +++ b/PC/_subprocess.c @@ -304,42 +304,42 @@ getenvironment(PyObject* environment) if (!keys || !values) goto error; - out = PyBytes_FromStringAndSize(NULL, 2048); + out = PyString_FromStringAndSize(NULL, 2048); if (! out) goto error; - p = PyBytes_AS_STRING(out); + p = PyString_AS_STRING(out); for (i = 0; i < envsize; i++) { int ksize, vsize, totalsize; PyObject* key = PyList_GET_ITEM(keys, i); PyObject* value = PyList_GET_ITEM(values, i); - if (! PyBytes_Check(key) || ! PyBytes_Check(value)) { + if (! PyString_Check(key) || ! PyString_Check(value)) { PyErr_SetString(PyExc_TypeError, "environment can only contain strings"); goto error; } - ksize = PyBytes_GET_SIZE(key); - vsize = PyBytes_GET_SIZE(value); - totalsize = (p - PyBytes_AS_STRING(out)) + ksize + 1 + + ksize = PyString_GET_SIZE(key); + vsize = PyString_GET_SIZE(value); + totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 + vsize + 1 + 1; - if (totalsize > PyBytes_GET_SIZE(out)) { - int offset = p - PyBytes_AS_STRING(out); - _PyBytes_Resize(&out, totalsize + 1024); - p = PyBytes_AS_STRING(out) + offset; + if (totalsize > PyString_GET_SIZE(out)) { + int offset = p - PyString_AS_STRING(out); + _PyString_Resize(&out, totalsize + 1024); + p = PyString_AS_STRING(out) + offset; } - memcpy(p, PyBytes_AS_STRING(key), ksize); + memcpy(p, PyString_AS_STRING(key), ksize); p += ksize; *p++ = '='; - memcpy(p, PyBytes_AS_STRING(value), vsize); + memcpy(p, PyString_AS_STRING(value), vsize); p += vsize; *p++ = '\0'; } /* add trailing null byte */ *p++ = '\0'; - _PyBytes_Resize(&out, p - PyBytes_AS_STRING(out)); + _PyString_Resize(&out, p - PyString_AS_STRING(out)); /* PyObject_Print(out, stdout, 0); */ @@ -413,7 +413,7 @@ sp_CreateProcess(PyObject* self, PyObject* args) NULL, inherit_handles, creation_flags, - environment ? PyBytes_AS_STRING(environment) : NULL, + environment ? PyString_AS_STRING(environment) : NULL, current_directory, &si, &pi); @@ -516,7 +516,7 @@ sp_GetModuleFileName(PyObject* self, PyObject* args) if (! result) return PyErr_SetFromWindowsErr(GetLastError()); - return PyBytes_FromString(filename); + return PyString_FromString(filename); } static PyMethodDef sp_functions[] = { |