[Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c
Neal Norwitz
nnorwitz at gmail.com
Mon May 8 05:58:07 CEST 2006
On 5/6/06, martin.v.loewis <python-checkins at python.org> wrote:
> Author: martin.v.loewis
> Date: Sat May 6 18:32:54 2006
> New Revision: 45925
>
> Modified: python/trunk/Lib/tempfile.py
> ==============================================================================
> --- python/trunk/Lib/tempfile.py (original)
> +++ python/trunk/Lib/tempfile.py Sat May 6 18:32:54 2006
> @@ -1497,7 +1533,29 @@
> are also valid. */
> PyErr_Clear();
> }
> -#endif /* Py_WIN_WIDE_FILENAMES */
> + if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding,
> + &path, &i))
> + return NULL;
> + Py_BEGIN_ALLOW_THREADS
> + attr = GetFileAttributesA(path);
> + if (attr != 0xFFFFFFFF) {
> + if (i & _S_IWRITE)
> + attr &= ~FILE_ATTRIBUTE_READONLY;
> + else
> + attr |= FILE_ATTRIBUTE_READONLY;
> + res = SetFileAttributesA(path, attr);
> + }
> + else
> + res = 0;
> + Py_END_ALLOW_THREADS
> + if (!res) {
> + win32_error("chmod", path);
> + PyMem_Free(path);
> + return NULL;
> + }
> + Py_INCREF(Py_None);
> + return Py_None;
PyMem_Free(path);
is needed before returning None to prevent a leak, isn't it?
n
More information about the Python-checkins
mailing list