Mercurial > cpython-lru_cache-weakref
diff Python/getargs.c @ 47294:4fe192d48960 legacy-trunk
Renamed PyString to PyBytes
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Mon, 26 May 2008 12:51:38 +0000 |
| parents | f33f66a2082f |
| children | 52294af4b663 |
line wrap: on
line diff
--- a/Python/getargs.c Mon May 26 12:29:46 2008 +0000 +++ b/Python/getargs.c Mon May 26 12:51:38 2008 +0000 @@ -418,7 +418,7 @@ n++; } - if (!PySequence_Check(arg) || PyString_Check(arg)) { + if (!PySequence_Check(arg) || PyBytes_Check(arg)) { levels[0] = 0; PyOS_snprintf(msgbuf, bufsize, toplevel ? "expected %d arguments, not %.50s" : @@ -765,8 +765,8 @@ case 'c': {/* char */ char *p = va_arg(*p_va, char *); - if (PyString_Check(arg) && PyString_Size(arg) == 1) - *p = PyString_AS_STRING(arg)[0]; + if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1) + *p = PyBytes_AS_STRING(arg)[0]; else return converterr("char", arg, msgbuf, bufsize); break; @@ -777,9 +777,9 @@ void **p = (void **)va_arg(*p_va, char **); FETCH_SIZE; - if (PyString_Check(arg)) { - *p = PyString_AS_STRING(arg); - STORE_SIZE(PyString_GET_SIZE(arg)); + if (PyBytes_Check(arg)) { + *p = PyBytes_AS_STRING(arg); + STORE_SIZE(PyBytes_GET_SIZE(arg)); } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { @@ -787,8 +787,8 @@ if (uarg == NULL) return converterr(CONV_UNICODE, arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - STORE_SIZE(PyString_GET_SIZE(uarg)); + *p = PyBytes_AS_STRING(uarg); + STORE_SIZE(PyBytes_GET_SIZE(uarg)); } #endif else { /* any buffer-like object */ @@ -802,20 +802,20 @@ } else { char **p = va_arg(*p_va, char **); - if (PyString_Check(arg)) - *p = PyString_AS_STRING(arg); + if (PyBytes_Check(arg)) + *p = PyBytes_AS_STRING(arg); #ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { uarg = UNICODE_DEFAULT_ENCODING(arg); if (uarg == NULL) return converterr(CONV_UNICODE, arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); + *p = PyBytes_AS_STRING(uarg); } #endif else return converterr("string", arg, msgbuf, bufsize); - if ((Py_ssize_t)strlen(*p) != PyString_Size(arg)) + if ((Py_ssize_t)strlen(*p) != PyBytes_Size(arg)) return converterr("string without null bytes", arg, msgbuf, bufsize); } @@ -831,9 +831,9 @@ *p = 0; STORE_SIZE(0); } - else if (PyString_Check(arg)) { - *p = PyString_AS_STRING(arg); - STORE_SIZE(PyString_GET_SIZE(arg)); + else if (PyBytes_Check(arg)) { + *p = PyBytes_AS_STRING(arg); + STORE_SIZE(PyBytes_GET_SIZE(arg)); } #ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { @@ -841,8 +841,8 @@ if (uarg == NULL) return converterr(CONV_UNICODE, arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); - STORE_SIZE(PyString_GET_SIZE(uarg)); + *p = PyBytes_AS_STRING(uarg); + STORE_SIZE(PyBytes_GET_SIZE(uarg)); } #endif else { /* any buffer-like object */ @@ -858,15 +858,15 @@ if (arg == Py_None) *p = 0; - else if (PyString_Check(arg)) - *p = PyString_AS_STRING(arg); + else if (PyBytes_Check(arg)) + *p = PyBytes_AS_STRING(arg); #ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { uarg = UNICODE_DEFAULT_ENCODING(arg); if (uarg == NULL) return converterr(CONV_UNICODE, arg, msgbuf, bufsize); - *p = PyString_AS_STRING(uarg); + *p = PyBytes_AS_STRING(uarg); } #endif else @@ -878,11 +878,11 @@ if (arg == Py_None) *q = 0; else - *q = PyString_Size(arg); + *q = PyBytes_Size(arg); format++; } else if (*p != NULL && - (Py_ssize_t)strlen(*p) != PyString_Size(arg)) + (Py_ssize_t)strlen(*p) != PyBytes_Size(arg)) return converterr( "string without null bytes or None", arg, msgbuf, bufsize); @@ -923,7 +923,7 @@ arg, msgbuf, bufsize); /* Encode object */ - if (!recode_strings && PyString_Check(arg)) { + if (!recode_strings && PyBytes_Check(arg)) { s = arg; Py_INCREF(s); } @@ -946,7 +946,7 @@ if (s == NULL) return converterr("(encoding failed)", arg, msgbuf, bufsize); - if (!PyString_Check(s)) { + if (!PyBytes_Check(s)) { Py_DECREF(s); return converterr( "(encoder failed to return a string)", @@ -956,7 +956,7 @@ return converterr("string<e>", arg, msgbuf, bufsize); #endif } - size = PyString_GET_SIZE(s); + size = PyBytes_GET_SIZE(s); /* Write output; output is guaranteed to be 0-terminated */ if (*format == '#') { @@ -1013,7 +1013,7 @@ } } memcpy(*buffer, - PyString_AS_STRING(s), + PyBytes_AS_STRING(s), size + 1); STORE_SIZE(size); } else { @@ -1030,7 +1030,7 @@ PyMem_Free()ing it after usage */ - if ((Py_ssize_t)strlen(PyString_AS_STRING(s)) + if ((Py_ssize_t)strlen(PyBytes_AS_STRING(s)) != size) { Py_DECREF(s); return converterr( @@ -1049,7 +1049,7 @@ arg, msgbuf, bufsize); } memcpy(*buffer, - PyString_AS_STRING(s), + PyBytes_AS_STRING(s), size + 1); } Py_DECREF(s); @@ -1083,7 +1083,7 @@ case 'S': { /* string object */ PyObject **p = va_arg(*p_va, PyObject **); - if (PyString_Check(arg)) + if (PyBytes_Check(arg)) *p = arg; else return converterr("string", arg, msgbuf, bufsize); @@ -1473,12 +1473,12 @@ while (PyDict_Next(keywords, &pos, &key, &value)) { int match = 0; char *ks; - if (!PyString_Check(key)) { + if (!PyBytes_Check(key)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); return cleanreturn(0, freelist); } - ks = PyString_AsString(key); + ks = PyBytes_AsString(key); for (i = 0; i < len; i++) { if (!strcmp(ks, kwlist[i])) { match = 1;
