Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1503/win32/src
Modified Files:
win32apimodule.cpp
Log Message:
win32api.GetFileAttributes will call GetFileAttributesW if passed with
a Unicode object (previously it would throw a type-error)
Index: win32apimodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** win32apimodule.cpp 10 Jan 2006 05:35:47 -0000 1.52
--- win32apimodule.cpp 15 Mar 2006 04:00:08 -0000 1.53
***************
*** 1171,1185 ****
PyGetFileAttributes (PyObject *self, PyObject *args)
{
! char *pathName;
// @pyparm string|pathName||The name of the file whose attributes are to be returned.
! if (!PyArg_ParseTuple (args, "s:GetFileAttributes", &pathName))
return NULL;
! PyW32_BEGIN_ALLOW_THREADS
! DWORD rc = ::GetFileAttributes(pathName);
! PyW32_END_ALLOW_THREADS
if (rc==(DWORD)0xFFFFFFFF)
return ReturnAPIError("GetFileAttributes");
return Py_BuildValue("i", rc);
// @pyseeapi GetFileAttributes
// @rdesc The return value is a combination of the win32con.FILE_ATTRIBUTE_* constants.
// <nl>An exception is raised on failure.
--- 1171,1196 ----
PyGetFileAttributes (PyObject *self, PyObject *args)
{
! PyObject *obPathName;
// @pyparm string|pathName||The name of the file whose attributes are to be returned.
! // If this param is a unicode object, GetFileAttributesW is called.
! if (!PyArg_ParseTuple (args, "O:GetFileAttributes", &obPathName))
return NULL;
! DWORD rc;
! if (PyString_Check(obPathName)) {
! PyW32_BEGIN_ALLOW_THREADS
! rc = ::GetFileAttributes(PyString_AS_STRING(obPathName));
! PyW32_END_ALLOW_THREADS
! } else if (PyUnicode_Check(obPathName)) {
! PyW32_BEGIN_ALLOW_THREADS
! rc = ::GetFileAttributesW(PyUnicode_AS_UNICODE(obPathName));
! PyW32_END_ALLOW_THREADS
! } else
! return PyErr_Format(PyExc_TypeError, "pathName arg must be string or unicode");
!
if (rc==(DWORD)0xFFFFFFFF)
return ReturnAPIError("GetFileAttributes");
return Py_BuildValue("i", rc);
// @pyseeapi GetFileAttributes
+ // @pyseeapi GetFileAttributesW
// @rdesc The return value is a combination of the win32con.FILE_ATTRIBUTE_* constants.
// <nl>An exception is raised on failure.
|