mirror of
https://github.com/python/cpython.git
synced 2025-11-15 16:09:29 +00:00
Patch #790000: Allow os.access to handle Unicode file name.
This commit is contained in:
parent
deadbf50e4
commit
1b699a5f00
2 changed files with 17 additions and 0 deletions
|
|
@ -100,6 +100,7 @@ class UnicodeFileTests(unittest.TestCase):
|
||||||
f.write((filename + '\n').encode("utf-8"))
|
f.write((filename + '\n').encode("utf-8"))
|
||||||
f.close()
|
f.close()
|
||||||
print repr(filename)
|
print repr(filename)
|
||||||
|
os.access(filename,os.R_OK)
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
os.chdir(oldwd)
|
os.chdir(oldwd)
|
||||||
os.rmdir(dirname)
|
os.rmdir(dirname)
|
||||||
|
|
|
||||||
|
|
@ -1027,6 +1027,22 @@ posix_access(PyObject *self, PyObject *args)
|
||||||
int mode;
|
int mode;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
#ifdef Py_WIN_WIDE_FILENAMES
|
||||||
|
if (unicode_file_names()) {
|
||||||
|
PyUnicodeObject *po;
|
||||||
|
if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) {
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
/* PyUnicode_AS_UNICODE OK without thread lock as
|
||||||
|
it is a simple dereference. */
|
||||||
|
res = _waccess(PyUnicode_AS_UNICODE(po), mode);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
return(PyBool_FromLong(res == 0));
|
||||||
|
}
|
||||||
|
/* Drop the argument parsing error as narrow strings
|
||||||
|
are also valid. */
|
||||||
|
PyErr_Clear();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!PyArg_ParseTuple(args, "si:access", &path, &mode))
|
if (!PyArg_ParseTuple(args, "si:access", &path, &mode))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue