summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
commitdd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch)
treeb2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /PC
parente98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff)
downloadcpython-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')
-rw-r--r--PC/_msi.c12
-rw-r--r--PC/_subprocess.c30
-rw-r--r--PC/_winreg.c40
-rwxr-xr-xPC/msvcrtmodule.c4
-rw-r--r--PC/winsound.c2
5 files changed, 44 insertions, 44 deletions
diff --git a/PC/_msi.c b/PC/_msi.c
index 6b1c594..58b2530 100644
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -35,7 +35,7 @@ uuidcreate(PyObject* obj, PyObject*args)
return NULL;
}
- oresult = PyBytes_FromString(cresult);
+ oresult = PyString_FromString(cresult);
RpcStringFree(&cresult);
return oresult;
@@ -136,14 +136,14 @@ static FNFCIGETNEXTCABINET(cb_getnextcabinet)
PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
if (result == NULL)
return -1;
- if (!PyBytes_Check(result)) {
+ if (!PyString_Check(result)) {
PyErr_Format(PyExc_TypeError,
"Incorrect return type %s from getnextcabinet",
result->ob_type->tp_name);
Py_DECREF(result);
return FALSE;
}
- strncpy(pccab->szCab, PyBytes_AsString(result), sizeof(pccab->szCab));
+ strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab));
return TRUE;
}
return FALSE;
@@ -554,7 +554,7 @@ summary_getproperty(msiobj* si, PyObject *args)
PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
return NULL;
case VT_LPSTR:
- result = PyBytes_FromStringAndSize(sval, ssize);
+ result = PyString_FromStringAndSize(sval, ssize);
if (sval != sbuf)
free(sval);
return result;
@@ -586,9 +586,9 @@ summary_setproperty(msiobj* si, PyObject *args)
if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
return NULL;
- if (PyBytes_Check(data)) {
+ if (PyString_Check(data)) {
status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
- 0, NULL, PyBytes_AsString(data));
+ 0, NULL, PyString_AsString(data));
} else if (PyInt_Check(data)) {
status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
PyInt_AsLong(data), NULL, NULL);
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[] = {
diff --git a/PC/_winreg.c b/PC/_winreg.c
index edf2897..74d3343 100644
--- a/PC/_winreg.c
+++ b/PC/_winreg.c
@@ -424,7 +424,7 @@ PyHKEY_strFunc(PyObject *ob)
PyHKEYObject *pyhkey = (PyHKEYObject *)ob;
char resBuf[160];
wsprintf(resBuf, "<PyHKEY:%p>", pyhkey->hkey);
- return PyBytes_FromString(resBuf);
+ return PyString_FromString(resBuf);
}
static int
@@ -767,11 +767,11 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
return FALSE;
need_decref = 1;
}
- if (!PyBytes_Check(value))
+ if (!PyString_Check(value))
return FALSE;
*retDataSize = 1 + strlen(
- PyBytes_AS_STRING(
- (PyBytesObject *)value));
+ PyString_AS_STRING(
+ (PyStringObject *)value));
}
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize);
if (*retDataBuf==NULL){
@@ -782,8 +782,8 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
strcpy((char *)*retDataBuf, "");
else
strcpy((char *)*retDataBuf,
- PyBytes_AS_STRING(
- (PyBytesObject *)value));
+ PyString_AS_STRING(
+ (PyStringObject *)value));
if (need_decref)
Py_DECREF(value);
break;
@@ -808,7 +808,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
PyObject *t;
t = PyList_GET_ITEM(
(PyListObject *)value,j);
- if (PyBytes_Check(t)) {
+ if (PyString_Check(t)) {
obs[j] = t;
Py_INCREF(t);
} else if (PyUnicode_Check(t)) {
@@ -821,8 +821,8 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
} else
goto reg_multi_fail;
size += 1 + strlen(
- PyBytes_AS_STRING(
- (PyBytesObject *)obs[j]));
+ PyString_AS_STRING(
+ (PyStringObject *)obs[j]));
}
*retDataSize = size + 1;
@@ -839,11 +839,11 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
PyObject *t;
t = obs[j];
strcpy(P,
- PyBytes_AS_STRING(
- (PyBytesObject *)t));
+ PyString_AS_STRING(
+ (PyStringObject *)t));
P += 1 + strlen(
- PyBytes_AS_STRING(
- (PyBytesObject *)t));
+ PyString_AS_STRING(
+ (PyStringObject *)t));
Py_DECREF(obs[j]);
}
/* And doubly-terminate the list... */
@@ -1085,7 +1085,7 @@ PyEnumKey(PyObject *self, PyObject *args)
if (rc != ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx");
- retStr = PyBytes_FromStringAndSize(tmpbuf, len);
+ retStr = PyString_FromStringAndSize(tmpbuf, len);
return retStr; /* can be NULL */
}
@@ -1303,17 +1303,17 @@ PyQueryValue(PyObject *self, PyObject *args)
!= ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc,
"RegQueryValue");
- retStr = PyBytes_FromStringAndSize(NULL, bufSize);
+ retStr = PyString_FromStringAndSize(NULL, bufSize);
if (retStr == NULL)
return NULL;
- retBuf = PyBytes_AS_STRING(retStr);
+ retBuf = PyString_AS_STRING(retStr);
if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize))
!= ERROR_SUCCESS) {
Py_DECREF(retStr);
return PyErr_SetFromWindowsErrWithFunction(rc,
"RegQueryValue");
}
- _PyBytes_Resize(&retStr, strlen(retBuf));
+ _PyString_Resize(&retStr, strlen(retBuf));
return retStr;
}
@@ -1414,14 +1414,14 @@ PySetValue(PyObject *self, PyObject *args)
return NULL;
}
/* XXX - need Unicode support */
- str = PyBytes_AsString(obStrVal);
+ str = PyString_AsString(obStrVal);
if (str == NULL)
return NULL;
- len = PyBytes_Size(obStrVal);
+ len = PyString_Size(obStrVal);
if (obSubKey == Py_None)
subKey = NULL;
else {
- subKey = PyBytes_AsString(obSubKey);
+ subKey = PyString_AsString(obSubKey);
if (subKey == NULL)
return NULL;
}
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index 757d85e..e110ed8 100755
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -140,7 +140,7 @@ msvcrt_getch(PyObject *self, PyObject *args)
ch = _getch();
Py_END_ALLOW_THREADS
s[0] = ch;
- return PyBytes_FromStringAndSize(s, 1);
+ return PyString_FromStringAndSize(s, 1);
}
static PyObject *
@@ -172,7 +172,7 @@ msvcrt_getche(PyObject *self, PyObject *args)
ch = _getche();
Py_END_ALLOW_THREADS
s[0] = ch;
- return PyBytes_FromStringAndSize(s, 1);
+ return PyString_FromStringAndSize(s, 1);
}
static PyObject *
diff --git a/PC/winsound.c b/PC/winsound.c
index 4caadb3..e6ff226 100644
--- a/PC/winsound.c
+++ b/PC/winsound.c
@@ -151,7 +151,7 @@ static struct PyMethodDef sound_methods[] =
static void
add_define(PyObject *dict, const char *key, long value)
{
- PyObject *k=PyBytes_FromString(key);
+ PyObject *k=PyString_FromString(key);
PyObject *v=PyLong_FromLong(value);
if(v&&k)
{