mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Replace PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,
"surrogateescape") by PyUnicode_DecodeFSDefault(val).
This commit is contained in:
parent
56fdb75453
commit
97c18ab6a5
4 changed files with 6 additions and 11 deletions
|
|
@ -46,11 +46,8 @@ mkgrent(struct group *p)
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#define FSDECODE(val) PyUnicode_Decode(val, strlen(val),\
|
|
||||||
Py_FileSystemDefaultEncoding,\
|
|
||||||
"surrogateescape")
|
|
||||||
for (member = p->gr_mem; *member != NULL; member++) {
|
for (member = p->gr_mem; *member != NULL; member++) {
|
||||||
PyObject *x = FSDECODE(*member);
|
PyObject *x = PyUnicode_DecodeFSDefault(*member);
|
||||||
if (x == NULL || PyList_Append(w, x) != 0) {
|
if (x == NULL || PyList_Append(w, x) != 0) {
|
||||||
Py_XDECREF(x);
|
Py_XDECREF(x);
|
||||||
Py_DECREF(w);
|
Py_DECREF(w);
|
||||||
|
|
@ -61,13 +58,13 @@ mkgrent(struct group *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
|
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
|
||||||
SET(setIndex++, FSDECODE(p->gr_name));
|
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
|
||||||
#ifdef __VMS
|
#ifdef __VMS
|
||||||
SET(setIndex++, Py_None);
|
SET(setIndex++, Py_None);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
#else
|
#else
|
||||||
if (p->gr_passwd)
|
if (p->gr_passwd)
|
||||||
SET(setIndex++, FSDECODE(p->gr_passwd));
|
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
|
||||||
else {
|
else {
|
||||||
SET(setIndex++, Py_None);
|
SET(setIndex++, Py_None);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
|
|
||||||
|
|
@ -2031,7 +2031,7 @@ posix_getcwd(int use_bytes)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
if (use_bytes)
|
if (use_bytes)
|
||||||
return PyBytes_FromStringAndSize(buf, strlen(buf));
|
return PyBytes_FromStringAndSize(buf, strlen(buf));
|
||||||
return PyUnicode_Decode(buf, strlen(buf), Py_FileSystemDefaultEncoding,"surrogateescape");
|
return PyUnicode_DecodeFSDefault(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(posix_getcwd__doc__,
|
PyDoc_STRVAR(posix_getcwd__doc__,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ static void
|
||||||
sets(PyObject *v, int i, const char* val)
|
sets(PyObject *v, int i, const char* val)
|
||||||
{
|
{
|
||||||
if (val) {
|
if (val) {
|
||||||
PyObject *o = PyUnicode_Decode(val, strlen(val),
|
PyObject *o = PyUnicode_DecodeFSDefault(val, strlen(val),
|
||||||
Py_FileSystemDefaultEncoding,
|
Py_FileSystemDefaultEncoding,
|
||||||
"surrogateescape");
|
"surrogateescape");
|
||||||
PyStructSequence_SET_ITEM(v, i, o);
|
PyStructSequence_SET_ITEM(v, i, o);
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,7 @@ static void
|
||||||
sets(PyObject *v, int i, const char* val)
|
sets(PyObject *v, int i, const char* val)
|
||||||
{
|
{
|
||||||
if (val) {
|
if (val) {
|
||||||
PyObject *o = PyUnicode_Decode(val, strlen(val),
|
PyObject *o = PyUnicode_DecodeFSDefault(val);
|
||||||
Py_FileSystemDefaultEncoding,
|
|
||||||
"surrogateescape");
|
|
||||||
PyStructSequence_SET_ITEM(v, i, o);
|
PyStructSequence_SET_ITEM(v, i, o);
|
||||||
} else {
|
} else {
|
||||||
PyStructSequence_SET_ITEM(v, i, Py_None);
|
PyStructSequence_SET_ITEM(v, i, Py_None);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue