[Python-checkins] cpython (merge 3.2 -> 3.2): merge heads
benjamin.peterson
python-checkins at python.org
Tue Jan 24 15:07:24 CET 2012
http://hg.python.org/cpython/rev/f7d3a754bc02
changeset: 74594:f7d3a754bc02
branch: 3.2
parent: 74591:308f4af9548e
parent: 74589:839fa289e226
user: Benjamin Peterson <benjamin at python.org>
date: Tue Jan 24 09:07:06 2012 -0500
summary:
merge heads
files:
Doc/library/functools.rst | 2 +-
Doc/library/os.rst | 9 +++------
Doc/library/stdtypes.rst | 2 +-
Lib/test/test_os.py | 9 +++++++--
Misc/NEWS | 4 ++++
Modules/posixmodule.c | 11 -----------
6 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -20,7 +20,7 @@
.. function:: cmp_to_key(func)
- Transform an old-style comparison function to a key-function. Used with
+ Transform an old-style comparison function to a key function. Used with
tools that accept key functions (such as :func:`sorted`, :func:`min`,
:func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`,
:func:`itertools.groupby`). This function is primarily used as a transition
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1429,11 +1429,9 @@
*target_is_directory*, which defaults to ``False``.
On Windows, a symlink represents a file or a directory, and does not morph to
- the target dynamically. For this reason, when creating a symlink on Windows,
- if the target is not already present, the symlink will default to being a
- file symlink. If *target_is_directory* is set to ``True``, the symlink will
- be created as a directory symlink. This parameter is ignored if the target
- exists (and the symlink is created with the same type as the target).
+ 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).
Symbolic link support was introduced in Windows 6.0 (Vista). :func:`symlink`
will raise a :exc:`NotImplementedError` on Windows versions earlier than 6.0.
@@ -1446,7 +1444,6 @@
administrator level. Either obtaining the privilege or running your
application as an administrator are ways to successfully create symlinks.
-
:exc:`OSError` is raised when the function is called by an unprivileged
user.
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -873,7 +873,7 @@
| ``s * n, n * s`` | *n* shallow copies of *s* | \(2) |
| | concatenated | |
+------------------+--------------------------------+----------+
-| ``s[i]`` | *i*'th item of *s*, origin 0 | \(3) |
+| ``s[i]`` | *i*\ th item of *s*, origin 0 | \(3) |
+------------------+--------------------------------+----------+
| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |
+------------------+--------------------------------+----------+
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -476,7 +476,12 @@
f.write("I'm " + path + " and proud of it. Blame test_os.\n")
f.close()
if support.can_symlink():
- os.symlink(os.path.abspath(t2_path), link_path)
+ if os.name == 'nt':
+ def symlink_to_dir(src, dest):
+ os.symlink(src, dest, True)
+ else:
+ symlink_to_dir = os.symlink
+ symlink_to_dir(os.path.abspath(t2_path), link_path)
sub2_tree = (sub2_path, ["link"], ["tmp3"])
else:
sub2_tree = (sub2_path, [], ["tmp3"])
@@ -1106,7 +1111,7 @@
os.remove(self.missing_link)
def test_directory_link(self):
- os.symlink(self.dirlink_target, self.dirlink)
+ os.symlink(self.dirlink_target, self.dirlink, True)
self.assertTrue(os.path.exists(self.dirlink))
self.assertTrue(os.path.isdir(self.dirlink))
self.assertTrue(os.path.islink(self.dirlink))
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -108,6 +108,10 @@
Library
-------
+- Issue #13772: In os.symlink() under Windows, do not try to guess the link
+ target's type (file or directory). The detection was buggy and made the
+ call non-atomic (therefore prone to race conditions).
+
- Issue #6631: Disallow relative file paths in urllib urlopen methods.
- Issue #13722: Avoid silencing ImportErrors when initializing the codecs
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5330,7 +5330,6 @@
PyObject *src, *dest;
int target_is_directory = 0;
DWORD res;
- WIN32_FILE_ATTRIBUTE_DATA src_info;
if (!check_CreateSymbolicLinkW())
{
@@ -5351,16 +5350,6 @@
return NULL;
}
- /* if src is a directory, ensure target_is_directory==1 */
- if(
- GetFileAttributesExW(
- PyUnicode_AsUnicode(src), GetFileExInfoStandard, &src_info
- ))
- {
- target_is_directory = target_is_directory ||
- (src_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
- }
-
Py_BEGIN_ALLOW_THREADS
res = Py_CreateSymbolicLinkW(
PyUnicode_AsUnicode(dest),
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list