diff -r 2b54e25d6ecb Doc/library/os.rst --- a/Doc/library/os.rst Sun Jun 24 04:37:41 2012 +0200 +++ b/Doc/library/os.rst Sat Jun 23 22:43:11 2012 -0700 @@ -2188,11 +2188,6 @@ Create a symbolic link pointing to *source* named *link_name*. - On Windows, a symlink represents either a file or a directory, and does not - morph to the target dynamically. If *target_is_directory* is set to ``True``, - the symlink will be created as a directory symlink, otherwise as a file symlink - (the default). On non-Window platforms, *target_is_directory* is ignored. - Symbolic link support was introduced in Windows 6.0 (Vista). :func:`symlink` will raise a :exc:`NotImplementedError` on Windows versions earlier than 6.0. @@ -2204,6 +2199,8 @@ :data:`os.supports_dir_fd`. If it is unavailable, using it will raise a :exc:`NotImplementedError`. + The *target_is_directory* argument is deprecated, and is always ignored. + .. note:: On Windows, the *SeCreateSymbolicLinkPrivilege* is required in order to @@ -2221,8 +2218,8 @@ Added support for Windows 6.0 (Vista) symbolic links. .. versionadded:: 3.3 - Added the *dir_fd* argument, and now allow *target_is_directory* - on non-Windows platforms. + Added the *dir_fd* argument, and deprecated the *target_is_directory* + argument. .. function:: sync() diff -r 2b54e25d6ecb Misc/NEWS --- a/Misc/NEWS Sun Jun 24 04:37:41 2012 +0200 +++ b/Misc/NEWS Sat Jun 23 22:43:11 2012 -0700 @@ -47,6 +47,10 @@ Library ------- +- Issue #14917: Deprecated the "target_is_directory" argument for + os.symlink. On Windows os.symlink now determines automatically + whether or not the target is a directory. + - Issue #15154: Add "dir_fd" parameter to os.rmdir, remove "rmdir" parameter from os.remove / os.unlink. diff -r 2b54e25d6ecb Modules/posixmodule.c --- a/Modules/posixmodule.c Sun Jun 24 04:37:41 2012 +0200 +++ b/Modules/posixmodule.c Sat Jun 23 22:43:11 2012 -0700 @@ -7161,15 +7161,13 @@ PyDoc_STRVAR(posix_symlink__doc__, "symlink(src, dst, target_is_directory=False, *, dir_fd=None)\n\n\ Create a symbolic link pointing to src named dst.\n\n\ -target_is_directory is required on Windows if the target is to be\n\ - interpreted as a directory. (On Windows, symlink requires\n\ - Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n\ - target_is_directory is ignored on non-Windows platforms.\n\ \n\ If dir_fd is not None, it should be a file descriptor open to a directory,\n\ and path should be relative; path will then be relative to that directory.\n\ dir_fd may not be implemented on your platform.\n\ - If it is unavailable, using it will raise a NotImplementedError."); + If it is unavailable, using it will raise a NotImplementedError.\n\ +\n\ +The target_is_directory parameter is deprecated, and is always ignored."); #if defined(MS_WINDOWS) @@ -7199,11 +7197,13 @@ path_t src; path_t dst; int dir_fd = DEFAULT_DIR_FD; - int target_is_directory = 0; + int ignored; static char *keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; PyObject *return_value; #ifdef MS_WINDOWS + int target_is_directory; + DWORD src_attr; DWORD result; #else int result; @@ -7230,7 +7230,7 @@ keywords, path_converter, &src, path_converter, &dst, - &target_is_directory, + &ignored, #ifdef HAVE_SYMLINKAT dir_fd_converter, &dir_fd #else @@ -7248,6 +7248,12 @@ #ifdef MS_WINDOWS Py_BEGIN_ALLOW_THREADS + if (src.wide) + src_attr = GetFileAttributesW(src.wide); + else + src_attr = GetFileAttributesA(src.narrow); + target_is_directory = (src_attr & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; + if (dst.wide) result = Py_CreateSymbolicLinkW(dst.wide, src.wide, target_is_directory);