diff -r b66e82c9f852 Doc/library/os.rst --- a/Doc/library/os.rst Tue Jun 26 23:05:27 2012 +0200 +++ b/Doc/library/os.rst Wed Jun 27 11:50:55 2012 +0300 @@ -1212,7 +1212,7 @@ your platform using :data:`os.supports_fd`. If it is unavailable, using it will raise a :exc:`NotImplementedError`. - If the function also supports *dir_fd* or *follow_symlinks* arguments, it is + If the function also supports *dir_fd* or *followlinks* arguments, it is an error to specify one of those when supplying *path* as a file descriptor. .. _dir_fd: @@ -1227,21 +1227,21 @@ :data:`os.supports_dir_fd`. If it is unavailable, using it will raise a :exc:`NotImplementedError`. -.. _follow_symlinks: - -* **not following symlinks:** If *follow_symlinks* is +.. _followlinks: + +* **not following symbolic links:** If *followlinks* is ``False``, and the last element of the path to operate on is a symbolic link, the function will operate on the symbolic link itself instead of the file the link points to. (For POSIX systems, Python will call the ``l...`` version of the function.) - You can check whether or not *follow_symlinks* is supported on your platform - using :data:`os.supports_follow_symlinks`. If it is unavailable, using it + You can check whether or not *followlinks* is supported on your platform + using :data:`os.supports_followlinks`. If it is unavailable, using it will raise a :exc:`NotImplementedError`. -.. function:: access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True) +.. function:: access(path, mode, *, dir_fd=None, effective_ids=False, followlinks=True) Use the real uid/gid to test for access to *path*. Note that most operations will use the effective uid/gid, therefore this routine can be used in a @@ -1253,7 +1253,7 @@ information. This function can support specifying :ref:`paths relative to directory - descriptors ` and :ref:`not following symlinks `. + descriptors ` and :ref:`not following symbolic links `. If *effective_ids* is ``True``, :func:`access` will perform its access checks using the effective uid/gid instead of the real uid/gid. @@ -1293,7 +1293,7 @@ permissions semantics beyond the usual POSIX permission-bit model. .. versionchanged:: 3.3 - Added the *dir_fd*, *effective_ids*, and *follow_symlinks* parameters. + Added the *dir_fd*, *effective_ids*, and *followlinks* parameters. .. data:: F_OK @@ -1322,7 +1322,7 @@ on some platforms. -.. function:: chflags(path, flags, *, follow_symlinks=True) +.. function:: chflags(path, flags, *, followlinks=True) Set the flags of *path* to the numeric *flags*. *flags* may take a combination (bitwise OR) of the following values (as defined in the :mod:`stat` module): @@ -1340,15 +1340,15 @@ * :data:`stat.SF_NOUNLINK` * :data:`stat.SF_SNAPSHOT` - This function can support :ref:`not following symlinks `. + This function can support :ref:`not following symbolic links `. Availability: Unix. .. versionadded:: 3.3 - The *follow_symlinks* argument. - - -.. function:: chmod(path, mode, *, dir_fd=None, follow_symlinks=True) + The *followlinks* argument. + + +.. function:: chmod(path, mode, *, dir_fd=None, followlinks=True) Change the mode of *path* to the numeric *mode*. *mode* may take one of the following values (as defined in the :mod:`stat` module) or bitwise ORed @@ -1376,7 +1376,7 @@ This function can support :ref:`specifying a file descriptor `, :ref:`paths relative to directory descriptors ` and :ref:`not - following symlinks `. + following symbolic links `. Availability: Unix, Windows. @@ -1388,17 +1388,17 @@ .. versionadded:: 3.3 Added support for specifying *path* as an open file descriptor, - and the *dir_fd* and *follow_symlinks* arguments. - - -.. function:: chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True) + and the *dir_fd* and *followlinks* arguments. + + +.. function:: chown(path, uid, gid, *, dir_fd=None, followlinks=True) Change the owner and group id of *path* to the numeric *uid* and *gid*. To leave one of the ids unchanged, set it to -1. This function can support :ref:`specifying a file descriptor `, :ref:`paths relative to directory descriptors ` and :ref:`not - following symlinks `. + following symbolic links `. See :func:`shutil.chown` for a higher-level function that accepts names in addition to numeric ids. @@ -1407,7 +1407,7 @@ .. versionadded:: 3.3 Added support for specifying an open file descriptor for *path*, - and the *dir_fd* and *follow_symlinks* arguments. + and the *dir_fd* and *followlinks* arguments. .. function:: chroot(path) @@ -1444,17 +1444,17 @@ Set the flags of *path* to the numeric *flags*, like :func:`chflags`, but do not follow symbolic links. As of Python 3.3, this is equivalent to - ``os.chflags(path, flags, follow_symlinks=False)``. + ``os.chflags(path, flags, followlinks=False)``. Availability: Unix. .. function:: lchmod(path, mode) - Change the mode of *path* to the numeric *mode*. If path is a symlink, this - affects the symlink rather than the target. See the docs for :func:`chmod` + Change the mode of *path* to the numeric *mode*. If path is a symbolic link, this + affects the symbolic link rather than the target. See the docs for :func:`chmod` for possible values of *mode*. As of Python 3.3, this is equivalent to - ``os.chmod(path, mode, follow_symlinks=False)``. + ``os.chmod(path, mode, followlinks=False)``. Availability: Unix. @@ -1463,18 +1463,18 @@ Change the owner and group id of *path* to the numeric *uid* and *gid*. This function will not follow symbolic links. As of Python 3.3, this is equivalent - to ``os.chown(path, uid, gid, follow_symlinks=False)``. + to ``os.chown(path, uid, gid, followlinks=False)``. Availability: Unix. -.. function:: link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True) +.. function:: link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, followlinks=True) Create a hard link pointing to *src* named *dst*. This function can support specifying *src_dir_fd* and/or *dst_dir_fd* to supply :ref:`paths relative to directory descriptors `, and :ref:`not - following symlinks `. + following symbolic links `. Availability: Unix, Windows. @@ -1482,7 +1482,7 @@ Added Windows support. .. versionadded:: 3.3 - Added the *src_dir_fd*, *dst_dir_fd*, and *follow_symlinks* arguments. + Added the *src_dir_fd*, *dst_dir_fd*, and *followlinks* arguments. .. function:: listdir(path='.') @@ -1516,7 +1516,7 @@ Similar to :func:`~os.stat`, but does not follow symbolic links. On platforms that do not support symbolic links, this is an alias for :func:`~os.stat`. As of Python 3.3, this is equivalent to ``os.stat(path, - dir_fd=dir_fd, follow_symlinks=False)``. + dir_fd=dir_fd, followlinks=False)``. This function can also support :ref:`paths relative to directory descriptors `. @@ -1780,12 +1780,12 @@ The *dir_fd* parameter. -.. function:: stat(path, *, dir_fd=None, follow_symlinks=True) +.. function:: stat(path, *, dir_fd=None, followlinks=True) Perform the equivalent of a :c:func:`stat` system call on the given path. *path* may be specified as either a string or as an open file descriptor. - (This function normally follows symlinks; to stat a symlink add the argument - ``follow_symlinks=False``, or use :func:`lstat`.) + (This function normally follows symbolic links; to stat a symbolic link add the + argument ``followlinks=False``, or use :func:`lstat`.) The return value is an object whose attributes correspond roughly to the members of the :c:type:`stat` structure, namely: @@ -1857,7 +1857,7 @@ This function can support :ref:`specifying a file descriptor `, :ref:`specifying a file descriptor ` and :ref:`not - following symlinks `. + following symbolic links `. .. index:: module: stat @@ -1879,7 +1879,7 @@ Availability: Unix, Windows. .. versionadded:: 3.3 - Added the *dir_fd* and *follow_symlinks* arguments, + Added the *dir_fd* and *followlinks* arguments, specifying a file descriptor instead of a path, and the :attr:`st_atime_ns`, :attr:`st_mtime_ns`, and :attr:`st_ctime_ns` members. @@ -1998,21 +1998,21 @@ .. versionadded:: 3.3 -.. data:: supports_follow_symlinks +.. data:: supports_followlinks A :class:`~collections.Set` object indicating which functions in the - :mod:`os` module permit use of their *follow_symlinks* parameter. Different + :mod:`os` module permit use of their *followlinks* parameter. Different platforms provide different functionality, and an option that might work on one might be unsupported on another. For consistency's sakes, functions that - support *follow_symlinks* always allow specifying the parameter, but will + support *followlinks* always allow specifying the parameter, but will throw an exception if the functionality is not actually available. - To check whether a particular function permits use of its *follow_symlinks* - parameter, use the ``in`` operator on ``supports_follow_symlinks``. As an - example, this expression determines whether the *follow_symlinks* parameter + To check whether a particular function permits use of its *followlinks* + parameter, use the ``in`` operator on ``supports_followlinks``. As an + example, this expression determines whether the *followlinks* parameter of :func:`os.stat` is locally available:: - os.stat in os.supports_follow_symlinks + os.stat in os.supports_followlinks .. versionadded:: 3.3 @@ -2021,9 +2021,9 @@ Create a symbolic link pointing to *source* named *link_name*. - On Windows, a symlink represents either a file or a directory, and does not + On Windows, a symbolic link 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 symbolic link will be created as a directory symbolic link, otherwise as a file symbolic link (the default). On non-Window platforms, *target_is_directory* is ignored. Symbolic link support was introduced in Windows 6.0 (Vista). :func:`symlink` @@ -2035,10 +2035,10 @@ .. note:: On Windows, the *SeCreateSymbolicLinkPrivilege* is required in order to - successfully create symlinks. This privilege is not typically granted to + successfully create symbolic links. This privilege is not typically granted to regular users but is available to accounts which can escalate privileges to the administrator level. Either obtaining the privilege or running your - application as an administrator are ways to successfully create symlinks. + application as an administrator are ways to successfully create symbolic links. :exc:`OSError` is raised when the function is called by an unprivileged user. @@ -2087,7 +2087,7 @@ The *dir_fd* parameter. -.. function:: utime(path, times=None, *, ns=None, dir_fd=None, follow_symlinks=True) +.. function:: utime(path, times=None, *, ns=None, dir_fd=None, followlinks=True) Set the access and modified times of the file specified by *path*. @@ -2119,13 +2119,13 @@ This function can support :ref:`specifying a file descriptor `, :ref:`paths relative to directory descriptors ` and :ref:`not - following symlinks `. + following symbolic links `. Availability: Unix, Windows. .. versionadded:: 3.3 Added support for specifying an open file descriptor for *path*, - and the *dir_fd*, *follow_symlinks*, and *ns* parameters. + and the *dir_fd*, *followlinks*, and *ns* parameters. .. function:: walk(top, topdown=True, onerror=None, followlinks=False) @@ -2169,7 +2169,7 @@ By default, :func:`walk` will not walk down into symbolic links that resolve to directories. Set *followlinks* to ``True`` to visit directories pointed to by - symlinks, on systems that support them. + symbolic links, on systems that support them. .. note:: @@ -2272,17 +2272,17 @@ These functions are all available on Linux only. -.. function:: getxattr(path, attribute, *, follow_symlinks=True) +.. function:: getxattr(path, attribute, *, followlinks=True) Return the value of the extended filesystem attribute *attribute* for *path*. *attribute* can be bytes or str. If it is str, it is encoded with the filesystem encoding. This function can support :ref:`specifying a file descriptor ` and - :ref:`not following symlinks `. - - -.. function:: listxattr(path=None, *, follow_symlinks=True) + :ref:`not following symbolic links `. + + +.. function:: listxattr(path=None, *, followlinks=True) Return a list of the extended filesystem attributes on *path*. The attributes in the list are represented as strings decoded with the filesystem @@ -2290,20 +2290,20 @@ directory. This function can support :ref:`specifying a file descriptor ` and - :ref:`not following symlinks `. - - -.. function:: removexattr(path, attribute, *, follow_symlinks=True) + :ref:`not following symbolic links `. + + +.. function:: removexattr(path, attribute, *, followlinks=True) Removes the extended filesystem attribute *attribute* from *path*. *attribute* should be bytes or str. If it is a string, it is encoded with the filesystem encoding. This function can support :ref:`specifying a file descriptor ` and - :ref:`not following symlinks `. - - -.. function:: setxattr(path, attribute, value, flags=0, *, follow_symlinks=True) + :ref:`not following symbolic links `. + + +.. function:: setxattr(path, attribute, value, flags=0, *, followlinks=True) Set the extended filesystem attribute *attribute* on *path* to *value*. *attribute* must be a bytes or str with no embedded NULs. If it is a str, @@ -2314,7 +2314,7 @@ attribute will not be created and ``ENODATA`` will be raised. This function can support :ref:`specifying a file descriptor ` and - :ref:`not following symlinks `. + :ref:`not following symbolic links `. .. note:: diff -r b66e82c9f852 Lib/os.py --- a/Lib/os.py Tue Jun 26 23:05:27 2012 +0200 +++ b/Lib/os.py Wed Jun 27 11:50:55 2012 +0300 @@ -198,7 +198,7 @@ # fchmodat() minimally works. # # Therefore we simply ignore fchmodat() when deciding whether or not - # os.chmod supports follow_symlinks. Just checking lchmod() is + # os.chmod supports followlinks. Just checking lchmod() is # sufficient. After all--if you have a working fchmodat(), your # lchmod() almost certainly works too. # @@ -215,7 +215,7 @@ _add("HAVE_FSTATAT", "stat") _add("HAVE_UTIMENSAT", "utime") _add("MS_WINDOWS", "stat") - supports_follow_symlinks = _set + supports_followlinks = _set del _set del _have_functions @@ -434,8 +434,8 @@ `dirpath`, `dirnames` and `filenames` are identical to walk() output, and `dirfd` is a file descriptor referring to the directory `dirpath`. - The advantage of fwalk() over walk() is that it's safe against symlink - races (when followlinks is False). + The advantage of fwalk() over walk() is that it's safe against symbolic + link races (when followlinks is False). If dir_fd is not None, it should be a file descriptor open to a directory, and top should be relative; top will then be relative to that directory. @@ -459,7 +459,7 @@ """ # Note: To guard against symlink races, we use the standard # lstat()/open()/fstat() trick. - orig_st = stat(top, follow_symlinks=False, dir_fd=dir_fd) + orig_st = stat(top, followlinks=False, dir_fd=dir_fd) topfd = open(top, O_RDONLY, dir_fd=dir_fd) try: if (followlinks or (st.S_ISDIR(orig_st.st_mode) and @@ -488,7 +488,7 @@ except FileNotFoundError: try: # Add dangling symlinks, ignore disappeared files - if st.S_ISLNK(stat(name, dir_fd=topfd, follow_symlinks=False) + if st.S_ISLNK(stat(name, dir_fd=topfd, followlinks=False) .st_mode): nondirs.append(name) except FileNotFoundError: @@ -499,7 +499,7 @@ for name in dirs: try: - orig_st = stat(name, dir_fd=topfd, follow_symlinks=followlinks) + orig_st = stat(name, dir_fd=topfd, followlinks=followlinks) dirfd = open(name, O_RDONLY, dir_fd=topfd) except error as err: if onerror is not None: diff -r b66e82c9f852 Lib/shutil.py --- a/Lib/shutil.py Tue Jun 26 23:05:27 2012 +0200 +++ b/Lib/shutil.py Wed Jun 27 11:50:55 2012 +0300 @@ -139,7 +139,7 @@ only if both `src` and `dst` are symlinks. """ - def _nop(*args, ns=None, follow_symlinks=None): + def _nop(*args, ns=None, followlinks=None): pass # follow symlinks (aka don't not follow symlinks) @@ -150,22 +150,22 @@ return getattr(os, name, _nop) else: # use the real function only if it exists - # *and* it supports follow_symlinks + # *and* it supports followlinks def lookup(name): fn = getattr(os, name, _nop) - if fn in os.supports_follow_symlinks: + if fn in os.supports_followlinks: return fn return _nop - st = lookup("stat")(src, follow_symlinks=follow) + st = lookup("stat")(src, followlinks=follow) mode = stat.S_IMODE(st.st_mode) lookup("utime")(dst, ns=(st.st_atime_ns, st.st_mtime_ns), - follow_symlinks=follow) + followlinks=follow) try: - lookup("chmod")(dst, mode, follow_symlinks=follow) + lookup("chmod")(dst, mode, followlinks=follow) except NotImplementedError: # if we got a NotImplementedError, it's because - # * follow_symlinks=False, + # * followlinks=False, # * lchown() is unavailable, and # * either # * fchownat() is unvailable or @@ -177,7 +177,7 @@ pass if hasattr(st, 'st_flags'): try: - lookup("chflags")(dst, st.st_flags, follow_symlinks=follow) + lookup("chflags")(dst, st.st_flags, followlinks=follow) except OSError as why: for err in 'EOPNOTSUPP', 'ENOTSUP': if hasattr(errno, err) and why.errno == getattr(errno, err): @@ -195,10 +195,10 @@ """ - for name in os.listxattr(src, follow_symlinks=symlinks): + for name in os.listxattr(src, followlinks=symlinks): try: - value = os.getxattr(src, name, follow_symlinks=symlinks) - os.setxattr(dst, name, value, follow_symlinks=symlinks) + value = os.getxattr(src, name, followlinks=symlinks) + os.setxattr(dst, name, value, followlinks=symlinks) except OSError as e: if e.errno not in (errno.EPERM, errno.ENOTSUP, errno.ENODATA): raise diff -r b66e82c9f852 Lib/test/test_os.py --- a/Lib/test/test_os.py Tue Jun 26 23:05:27 2012 +0200 +++ b/Lib/test/test_os.py Wed Jun 27 11:50:55 2012 +0300 @@ -351,14 +351,14 @@ requires_utime_fd = unittest.skipUnless( os.utime in os.supports_fd, "fd support for utime required for this test.") - requires_utime_nofollow_symlinks = unittest.skipUnless( - os.utime in os.supports_follow_symlinks, - "follow_symlinks support for utime required for this test.") + requires_utime_nofollowlinks = unittest.skipUnless( + os.utime in os.supports_followlinks, + "followlinks support for utime required for this test.") - @requires_utime_nofollow_symlinks + @requires_utime_nofollowlinks def test_lutimes_ns(self): def lutimes_ns(file, times): - return os.utime(file, ns=times, follow_symlinks=False) + return os.utime(file, ns=times, followlinks=False) self._test_utime_ns(lutimes_ns) @requires_utime_fd @@ -424,10 +424,10 @@ os.close(dirfd) self._test_utime_subsecond(set_time) - @requires_utime_nofollow_symlinks + @requires_utime_nofollowlinks def test_lutimes_subsecond(self): def set_time(filename, atime, mtime): - os.utime(filename, (atime, mtime), follow_symlinks=False) + os.utime(filename, (atime, mtime), followlinks=False) self._test_utime_subsecond(set_time) @requires_utime_dir_fd @@ -803,7 +803,7 @@ for name in files: os.unlink(name, dir_fd=rootfd) for name in dirs: - st = os.stat(name, dir_fd=rootfd, follow_symlinks=False) + st = os.stat(name, dir_fd=rootfd, followlinks=False) if stat.S_ISDIR(st.st_mode): os.rmdir(name, dir_fd=rootfd) else: @@ -1930,7 +1930,7 @@ def test_lpath(self): self._check_xattrs(os.getxattr, os.setxattr, os.removexattr, - os.listxattr, follow_symlinks=False) + os.listxattr, followlinks=False) def test_fds(self): def getxattr(path, *args): diff -r b66e82c9f852 Lib/test/test_posix.py --- a/Lib/test/test_posix.py Tue Jun 26 23:05:27 2012 +0200 +++ b/Lib/test/test_posix.py Wed Jun 27 11:50:55 2012 +0300 @@ -256,16 +256,16 @@ finally: os.close(fd) - @unittest.skipUnless(os.utime in os.supports_follow_symlinks, "test needs follow_symlinks support in os.utime") - def test_utime_nofollow_symlinks(self): + @unittest.skipUnless(os.utime in os.supports_followlinks, "test needs followlinks support in os.utime") + def test_utime_nofollowlinks(self): now = time.time() - posix.utime(support.TESTFN, None, follow_symlinks=False) - self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None), follow_symlinks=False) - self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None), follow_symlinks=False) - self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now), follow_symlinks=False) - posix.utime(support.TESTFN, (int(now), int(now)), follow_symlinks=False) - posix.utime(support.TESTFN, (now, now), follow_symlinks=False) - posix.utime(support.TESTFN, follow_symlinks=False) + posix.utime(support.TESTFN, None, followlinks=False) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None), followlinks=False) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None), followlinks=False) + self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now), followlinks=False) + posix.utime(support.TESTFN, (int(now), int(now)), followlinks=False) + posix.utime(support.TESTFN, (now, now), followlinks=False) + posix.utime(support.TESTFN, followlinks=False) @unittest.skipUnless(hasattr(posix, 'writev'), "test needs posix.writev()") def test_writev(self): @@ -552,7 +552,7 @@ @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()') def test_lchflags_regular_file(self): self._test_chflags_regular_file(posix.lchflags, support.TESTFN) - self._test_chflags_regular_file(posix.chflags, support.TESTFN, follow_symlinks=False) + self._test_chflags_regular_file(posix.chflags, support.TESTFN, followlinks=False) @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()') def test_lchflags_symlink(self): @@ -565,7 +565,7 @@ dummy_symlink_st = os.lstat(_DUMMY_SYMLINK) def chflags_nofollow(path, flags): - return posix.chflags(path, flags, follow_symlinks=False) + return posix.chflags(path, flags, followlinks=False) for fn in (posix.lchflags, chflags_nofollow): fn(_DUMMY_SYMLINK, @@ -726,10 +726,10 @@ posix.utime(support.TESTFN, dir_fd=f, times=(int(now), int((now - int(now)) * 1e9))) - # try dir_fd and follow_symlinks together - if os.utime in os.supports_follow_symlinks: + # try dir_fd and followlinks together + if os.utime in os.supports_followlinks: try: - posix.utime(support.TESTFN, follow_symlinks=False, dir_fd=f) + posix.utime(support.TESTFN, followlinks=False, dir_fd=f) except ValueError: # whoops! using both together not supported on this platform. pass diff -r b66e82c9f852 Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Tue Jun 26 23:05:27 2012 +0200 +++ b/Lib/test/test_shutil.py Wed Jun 27 11:50:55 2012 +0300 @@ -199,7 +199,7 @@ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod') @support.skip_unless_symlink - def test_copymode_follow_symlinks(self): + def test_copymode_followlinks(self): tmp_dir = self.mkdtemp() src = os.path.join(tmp_dir, 'foo') dst = os.path.join(tmp_dir, 'bar') @@ -299,7 +299,7 @@ # don't follow shutil.copystat(src_link, dst_link, symlinks=True) dst_link_stat = os.lstat(dst_link) - if os.utime in os.supports_follow_symlinks: + if os.utime in os.supports_followlinks: for attr in 'st_atime', 'st_mtime': # The modification times may be truncated in the new file. self.assertLessEqual(getattr(src_link_stat, attr), @@ -327,7 +327,7 @@ def make_chflags_raiser(err): ex = OSError() - def _chflags_raiser(path, flags, *, follow_symlinks=True): + def _chflags_raiser(path, flags, *, followlinks=True): ex.errno = err raise ex return _chflags_raiser @@ -392,13 +392,13 @@ write_file(src, 'foo') os.symlink(src, src_link) os.setxattr(src, 'trusted.foo', b'42') - os.setxattr(src_link, 'trusted.foo', b'43', follow_symlinks=False) + os.setxattr(src_link, 'trusted.foo', b'43', followlinks=False) dst = os.path.join(tmp_dir, 'bar') dst_link = os.path.join(tmp_dir, 'qux') write_file(dst, 'bar') os.symlink(dst, dst_link) shutil._copyxattr(src_link, dst_link, symlinks=True) - self.assertEqual(os.getxattr(dst_link, 'trusted.foo', follow_symlinks=False), b'43') + self.assertEqual(os.getxattr(dst_link, 'trusted.foo', followlinks=False), b'43') self.assertRaises(OSError, os.getxattr, dst, 'trusted.foo') shutil._copyxattr(src_link, dst, symlinks=True) self.assertEqual(os.getxattr(dst, 'trusted.foo'), b'43') @@ -450,7 +450,7 @@ self.assertTrue(os.path.islink(dst)) self.assertEqual(os.readlink(dst), os.readlink(src_link)) dst_stat = os.lstat(dst) - if os.utime in os.supports_follow_symlinks: + if os.utime in os.supports_followlinks: for attr in 'st_atime', 'st_mtime': # The modification times may be truncated in the new file. self.assertLessEqual(getattr(src_link_stat, attr), diff -r b66e82c9f852 Misc/NEWS --- a/Misc/NEWS Tue Jun 26 23:05:27 2012 +0200 +++ b/Misc/NEWS Wed Jun 27 11:50:55 2012 +0300 @@ -126,7 +126,7 @@ - Issue #11024: Fixes and additional tests for Time2Internaldate. - Issue #14626: Large refactoring of functions / parameters in the os module. - Many functions now support "dir_fd" and "follow_symlinks" parameters; + Many functions now support "dir_fd" and "followlinks" parameters; some also support accepting an open file descriptor in place of of a path string. Added os.support_* collections as LBYL helpers. Removed many functions only previously seen in 3.3 alpha releases (often starting with diff -r b66e82c9f852 Modules/posixmodule.c --- a/Modules/posixmodule.c Tue Jun 26 23:05:27 2012 +0200 +++ b/Modules/posixmodule.c Wed Jun 27 11:50:55 2012 +0300 @@ -719,11 +719,11 @@ } static int -follow_symlinks_specified(char *function_name, int follow_symlinks) { - if (follow_symlinks) +followlinks_specified(char *function_name, int followlinks) { + if (followlinks) return 0; - argument_unavailable_error(function_name, "follow_symlinks"); + argument_unavailable_error(function_name, "followlinks"); return 1; } @@ -750,11 +750,11 @@ } static int -fd_and_follow_symlinks_invalid(char *function_name, int fd, - int follow_symlinks) { - if ((fd > 0) && (!follow_symlinks)) { +fd_and_followlinks_invalid(char *function_name, int fd, + int followlinks) { + if ((fd > 0) && (!followlinks)) { PyErr_Format(PyExc_ValueError, - "%s: cannot use fd and follow_symlinks together", + "%s: cannot use fd and followlinks together", function_name); return 1; } @@ -762,11 +762,11 @@ } static int -dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd, - int follow_symlinks) { - if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) { +dir_fd_and_followlinks_invalid(char *function_name, int dir_fd, + int followlinks) { + if ((dir_fd != DEFAULT_DIR_FD) && (!followlinks)) { PyErr_Format(PyExc_ValueError, - "%s: cannot use dir_fd and follow_symlinks together", + "%s: cannot use dir_fd and followlinks together", function_name); return 1; } @@ -2232,19 +2232,19 @@ static PyObject * posix_do_stat(char *function_name, path_t *path, - int dir_fd, int follow_symlinks) + int dir_fd, int followlinks) { STRUCT_STAT st; int result; #if !defined(MS_WINDOWS) && !defined(HAVE_FSTATAT) && !defined(HAVE_LSTAT) - if (follow_symlinks_specified(function_name, follow_symlinks)) + if (followlinks_specified(function_name, followlinks)) return NULL; #endif if (path_and_dir_fd_invalid("stat", path, dir_fd) || dir_fd_and_fd_invalid("stat", dir_fd, path->fd) || - fd_and_follow_symlinks_invalid("stat", path->fd, follow_symlinks)) + fd_and_followlinks_invalid("stat", path->fd, followlinks)) return NULL; Py_BEGIN_ALLOW_THREADS @@ -2253,7 +2253,7 @@ else #ifdef MS_WINDOWS if (path->wide) { - if (follow_symlinks) + if (followlinks) result = win32_stat_w(path->wide, &st); else result = win32_lstat_w(path->wide, &st); @@ -2261,14 +2261,14 @@ else #endif #if defined(HAVE_LSTAT) || defined(MS_WINDOWS) - if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD)) + if ((!followlinks) && (dir_fd == DEFAULT_DIR_FD)) result = LSTAT(path->narrow, &st); else #endif #ifdef HAVE_FSTATAT - if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks) + if ((dir_fd != DEFAULT_DIR_FD) || !followlinks) result = fstatat(dir_fd, path->narrow, &st, - follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW); + followlinks ? 0 : AT_SYMLINK_NOFOLLOW); else #endif result = STAT(path->narrow, &st); @@ -2281,7 +2281,7 @@ } PyDoc_STRVAR(posix_stat__doc__, -"stat(path, *, dir_fd=None, follow_symlinks=True) -> stat result\n\n\ +"stat(path, *, dir_fd=None, followlinks=True) -> stat result\n\n\ Perform a stat system call on the given path.\n\ \n\ path may be specified as either a string or as an open file descriptor.\n\ @@ -2290,19 +2290,19 @@ and path should be relative; path will then be relative to that directory.\n\ dir_fd may not be supported on your platform; if it is unavailable, using\n\ it will raise a NotImplementedError.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, stat will examine the symbolic link itself instead of the file the\n\ link points to.\n\ -It is an error to use dir_fd or follow_symlinks when specifying path as\n\ +It is an error to use dir_fd or followlinks when specifying path as\n\ an open file descriptor."); static PyObject * posix_stat(PyObject *self, PyObject *args, PyObject *kwargs) { - static char *keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; + static char *keywords[] = {"path", "dir_fd", "followlinks", NULL}; path_t path; int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; + int followlinks = 1; PyObject *return_value; memset(&path, 0, sizeof(path)); @@ -2314,9 +2314,9 @@ #else dir_fd_unavailable, &dir_fd, #endif - &follow_symlinks)) - return NULL; - return_value = posix_do_stat("stat", &path, dir_fd, follow_symlinks); + &followlinks)) + return NULL; + return_value = posix_do_stat("stat", &path, dir_fd, followlinks); path_cleanup(&path); return return_value; } @@ -2324,7 +2324,7 @@ PyDoc_STRVAR(posix_lstat__doc__, "lstat(path, *, dir_fd=None) -> stat result\n\n\ Like stat(), but do not follow symbolic links.\n\ -Equivalent to stat(path, follow_symlinks=False)."); +Equivalent to stat(path, followlinks=False)."); static PyObject * posix_lstat(PyObject *self, PyObject *args, PyObject *kwargs) @@ -2332,7 +2332,7 @@ static char *keywords[] = {"path", "dir_fd", NULL}; path_t path; int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 0; + int followlinks = 0; PyObject *return_value; memset(&path, 0, sizeof(path)); @@ -2345,14 +2345,14 @@ #endif )) return NULL; - return_value = posix_do_stat("stat", &path, dir_fd, follow_symlinks); + return_value = posix_do_stat("stat", &path, dir_fd, followlinks); path_cleanup(&path); return return_value; } PyDoc_STRVAR(posix_access__doc__, "access(path, mode, *, dir_fd=None, effective_ids=False,\ - follow_symlinks=True)\n\n\ + followlinks=True)\n\n\ Use the real uid/gid to test for access to a path. Returns True if granted,\n\ False otherwise.\n\ \n\ @@ -2360,10 +2360,10 @@ and path should be relative; path will then be relative to that directory.\n\ If effective_ids is True, access will use the effective uid/gid instead of\n\ the real uid/gid.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, access will examine the symbolic link itself instead of the file the\n\ link points to.\n\ -dir_fd, effective_ids, and follow_symlinks may not be implemented\n\ +dir_fd, effective_ids, and followlinks may not be implemented\n\ on your platform. If they are unavailable, using them will raise a\n\ NotImplementedError.\n\ \n\ @@ -2377,12 +2377,12 @@ posix_access(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[] = {"path", "mode", "dir_fd", "effective_ids", - "follow_symlinks", NULL}; + "followlinks", NULL}; path_t path; int mode; int dir_fd = DEFAULT_DIR_FD; int effective_ids = 0; - int follow_symlinks = 1; + int followlinks = 1; PyObject *return_value = NULL; #ifdef MS_WINDOWS @@ -2399,11 +2399,11 @@ #else dir_fd_unavailable, &dir_fd, #endif - &effective_ids, &follow_symlinks)) + &effective_ids, &followlinks)) return NULL; #ifndef HAVE_FACCESSAT - if (follow_symlinks_specified("access", follow_symlinks)) + if (followlinks_specified("access", followlinks)) goto exit; if (effective_ids) { @@ -2439,9 +2439,9 @@ #ifdef HAVE_FACCESSAT if ((dir_fd != DEFAULT_DIR_FD) || effective_ids || - !follow_symlinks) { + !followlinks) { int flags = 0; - if (!follow_symlinks) + if (!followlinks) flags |= AT_SYMLINK_NOFOLLOW; if (effective_ids) flags |= AT_EACCESS; @@ -2599,7 +2599,7 @@ PyDoc_STRVAR(posix_chmod__doc__, -"chmod(path, mode, *, dir_fd=None, follow_symlinks=True)\n\n\ +"chmod(path, mode, *, dir_fd=None, followlinks=True)\n\n\ Change the access permissions of a file.\n\ \n\ path may always be specified as a string.\n\ @@ -2607,12 +2607,12 @@ If this functionality is unavailable, using it raises an exception.\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\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, chmod will modify the symbolic link itself instead of the file the\n\ link points to.\n\ -It is an error to use dir_fd or follow_symlinks when specifying path as\n\ +It is an error to use dir_fd or followlinks when specifying path as\n\ an open file descriptor.\n\ -dir_fd and follow_symlinks may not be implemented on your platform.\n\ +dir_fd and followlinks may not be implemented on your platform.\n\ If they are unavailable, using them will raise a NotImplementedError."); static PyObject * @@ -2621,11 +2621,11 @@ path_t path; int mode; int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; + int followlinks = 1; int result; PyObject *return_value = NULL; static char *keywords[] = {"path", "mode", "dir_fd", - "follow_symlinks", NULL}; + "followlinks", NULL}; #ifdef MS_WINDOWS DWORD attr; @@ -2647,11 +2647,11 @@ #else dir_fd_unavailable, &dir_fd, #endif - &follow_symlinks)) + &followlinks)) return NULL; #if !(defined(HAVE_FCHMODAT) || defined(HAVE_LCHMOD)) - if (follow_symlinks_specified("chmod", follow_symlinks)) + if (followlinks_specified("chmod", followlinks)) goto exit; #endif @@ -2687,12 +2687,12 @@ else #endif #ifdef HAVE_LCHMOD - if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD)) + if ((!followlinks) && (dir_fd == DEFAULT_DIR_FD)) result = lchmod(path.narrow, mode); else #endif #ifdef HAVE_FCHMODAT - if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks) { + if ((dir_fd != DEFAULT_DIR_FD) || !followlinks) { /* * fchmodat() doesn't currently support AT_SYMLINK_NOFOLLOW! * The documentation specifically shows how to use it, @@ -2700,11 +2700,11 @@ * (true on linux with glibc 2.15, and openindiana 3.x) * * Once it is supported, os.chmod will automatically - * support dir_fd and follow_symlinks=False. (Hopefully.) + * support dir_fd and followlinks=False. (Hopefully.) * Until then, we need to be careful what exception we raise. */ result = fchmodat(dir_fd, path.narrow, mode, - follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW); + followlinks ? 0 : AT_SYMLINK_NOFOLLOW); /* * But wait! We can't throw the exception without allowing threads, * and we can't do that in this nested scope. (Macro trickery, sigh.) @@ -2712,7 +2712,7 @@ fchmodat_nofollow_unsupported = result && ((errno == ENOTSUP) || (errno == EOPNOTSUPP)) && - !follow_symlinks; + !followlinks; } else #endif @@ -2723,10 +2723,10 @@ #ifdef HAVE_FCHMODAT if (fchmodat_nofollow_unsupported) { if (dir_fd != DEFAULT_DIR_FD) - dir_fd_and_follow_symlinks_invalid("chmod", - dir_fd, follow_symlinks); + dir_fd_and_followlinks_invalid("chmod", + dir_fd, followlinks); else - follow_symlinks_specified("chmod", follow_symlinks); + followlinks_specified("chmod", followlinks); } else #endif @@ -2767,9 +2767,9 @@ #ifdef HAVE_LCHMOD PyDoc_STRVAR(posix_lchmod__doc__, "lchmod(path, mode)\n\n\ -Change the access permissions of a file. If path is a symlink, this\n\ -affects the link itself rather than the target.\n\ -Equivalent to chmod(path, mode, follow_symlinks=False)."); +Change the access permissions of a file. If path is a symbolic link,\n\ +this affects the link itself rather than the target.\n\ +Equivalent to chmod(path, mode, followlinks=False)."); static PyObject * posix_lchmod(PyObject *self, PyObject *args) @@ -2795,13 +2795,13 @@ #ifdef HAVE_CHFLAGS PyDoc_STRVAR(posix_chflags__doc__, -"chflags(path, flags, *, follow_symlinks=True)\n\n\ +"chflags(path, flags, *, followlinks=True)\n\n\ Set file flags.\n\ \n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, chflags will change flags on the symbolic link itself instead of the\n\ file the link points to.\n\ -follow_symlinks may not be implemented on your platform. If it is\n\ +followlinks may not be implemented on your platform. If it is\n\ unavailable, using it will raise a NotImplementedError."); static PyObject * @@ -2809,25 +2809,25 @@ { path_t path; unsigned long flags; - int follow_symlinks = 1; + int followlinks = 1; int result; PyObject *return_value; - static char *keywords[] = {"path", "flags", "follow_symlinks", NULL}; + static char *keywords[] = {"path", "flags", "followlinks", NULL}; memset(&path, 0, sizeof(path)); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&k|$i:chflags", keywords, path_converter, &path, - &flags, &follow_symlinks)) + &flags, &followlinks)) return NULL; #ifndef HAVE_LCHFLAGS - if (follow_symlinks_specified("chflags", follow_symlinks)) + if (followlinks_specified("chflags", followlinks)) goto exit; #endif Py_BEGIN_ALLOW_THREADS #ifdef HAVE_LCHFLAGS - if (!follow_symlinks) + if (!followlinks) result = lchflags(path.narrow, flags); else #endif @@ -2853,7 +2853,7 @@ "lchflags(path, flags)\n\n\ Set file flags.\n\ This function will not follow symbolic links.\n\ -Equivalent to chflags(path, flags, follow_symlinks=False)."); +Equivalent to chflags(path, flags, followlinks=False)."); static PyObject * posix_lchflags(PyObject *self, PyObject *args) @@ -2937,7 +2937,7 @@ #ifdef HAVE_CHOWN PyDoc_STRVAR(posix_chown__doc__, -"chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n\n\ +"chown(path, uid, gid, *, dir_fd=None, followlinks=True)\n\n\ Change the owner and group id of path to the numeric uid and gid.\n\ \n\ path may always be specified as a string.\n\ @@ -2945,12 +2945,12 @@ If this functionality is unavailable, using it raises an exception.\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\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, chown will modify the symbolic link itself instead of the file the\n\ link points to.\n\ -It is an error to use dir_fd or follow_symlinks when specifying path as\n\ +It is an error to use dir_fd or followlinks when specifying path as\n\ an open file descriptor.\n\ -dir_fd and follow_symlinks may not be implemented on your platform.\n\ +dir_fd and followlinks may not be implemented on your platform.\n\ If they are unavailable, using them will raise a NotImplementedError."); static PyObject * @@ -2961,11 +2961,11 @@ uid_t uid; gid_t gid; int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; + int followlinks = 1; int result; PyObject *return_value = NULL; static char *keywords[] = {"path", "uid", "gid", "dir_fd", - "follow_symlinks", NULL}; + "followlinks", NULL}; memset(&path, 0, sizeof(path)); #ifdef HAVE_FCHOWN @@ -2979,15 +2979,15 @@ #else dir_fd_unavailable, &dir_fd, #endif - &follow_symlinks)) + &followlinks)) return NULL; #if !(defined(HAVE_LCHOWN) || defined(HAVE_FCHOWNAT)) - if (follow_symlinks_specified("chown", follow_symlinks)) + if (followlinks_specified("chown", followlinks)) goto exit; #endif if (dir_fd_and_fd_invalid("chown", dir_fd, path.fd) || - fd_and_follow_symlinks_invalid("chown", path.fd, follow_symlinks)) + fd_and_followlinks_invalid("chown", path.fd, followlinks)) goto exit; #ifdef __APPLE__ @@ -2997,8 +2997,8 @@ * It doesn't have fchownat either. So there's no possibility * of a graceful failover. */ - if ((!follow_symlinks) && (lchown == NULL)) { - follow_symlinks_specified("chown", follow_symlinks); + if ((!followlinks) && (lchown == NULL)) { + followlinks_specified("chown", followlinks); goto exit; } #endif @@ -3012,14 +3012,14 @@ else #endif #ifdef HAVE_LCHOWN - if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD)) + if ((!followlinks) && (dir_fd == DEFAULT_DIR_FD)) result = lchown(path.narrow, uid, gid); else #endif #ifdef HAVE_FCHOWNAT - if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) + if ((dir_fd != DEFAULT_DIR_FD) || (!followlinks)) result = fchownat(dir_fd, path.narrow, uid, gid, - follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW); + followlinks ? 0 : AT_SYMLINK_NOFOLLOW); else #endif result = chown(path.narrow, uid, gid); @@ -3067,7 +3067,7 @@ "lchown(path, uid, gid)\n\n\ Change the owner and group id of path to the numeric uid and gid.\n\ This function will not follow symbolic links.\n\ -Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); +Equivalent to os.chown(path, uid, gid, followlinks=False)."); static PyObject * posix_lchown(PyObject *self, PyObject *args) @@ -3175,16 +3175,16 @@ #ifdef HAVE_LINK PyDoc_STRVAR(posix_link__doc__, -"link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)\n\n\ +"link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, followlinks=True)\n\n\ Create a hard link to a file.\n\ \n\ If either src_dir_fd or dst_dir_fd is not None, it should be a file\n\ descriptor open to a directory, and the respective path string (src or dst)\n\ should be relative; the path will then be relative to that directory.\n\ -If follow_symlinks is False, and the last element of src is a symbolic\n\ +If followlinks is False, and the last element of src is a symbolic\n\ link, link will create a link to the symbolic link itself instead of the\n\ file the link points to.\n\ -src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n\ +src_dir_fd, dst_dir_fd, and followlinks may not be implemented on your\n\ platform. If they are unavailable, using them will raise a\n\ NotImplementedError."); @@ -3194,10 +3194,10 @@ path_t src, dst; int src_dir_fd = DEFAULT_DIR_FD; int dst_dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; + int followlinks = 1; PyObject *return_value = NULL; static char *keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", - "follow_symlinks", NULL}; + "followlinks", NULL}; #ifdef MS_WINDOWS BOOL result; #else @@ -3211,7 +3211,7 @@ path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, - &follow_symlinks)) + &followlinks)) return NULL; #ifndef HAVE_LINKAT @@ -3244,10 +3244,10 @@ #ifdef HAVE_LINKAT if ((src_dir_fd != DEFAULT_DIR_FD) || (dst_dir_fd != DEFAULT_DIR_FD) || - (!follow_symlinks)) + (!followlinks)) result = linkat(src_dir_fd, src.narrow, dst_dir_fd, dst.narrow, - follow_symlinks ? AT_SYMLINK_FOLLOW : 0); + followlinks ? AT_SYMLINK_FOLLOW : 0); else #endif result = link(src.narrow, dst.narrow); @@ -4383,7 +4383,7 @@ PyDoc_STRVAR(posix_utime__doc__, -"utime(path, times=None, *, ns=None, dir_fd=None, follow_symlinks=True)\n\ +"utime(path, times=None, *, ns=None, dir_fd=None, followlinks=True)\n\ Set the access and modified time of path.\n\ \n\ path may always be specified as a string.\n\ @@ -4400,12 +4400,12 @@ \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\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, utime will modify the symbolic link itself instead of the file the\n\ link points to.\n\ -It is an error to use dir_fd or follow_symlinks when specifying path\n\ +It is an error to use dir_fd or followlinks when specifying path\n\ as an open file descriptor.\n\ -dir_fd and follow_symlinks may not be available on your platform.\n\ +dir_fd and followlinks may not be available on your platform.\n\ If they are unavailable, using them will raise a NotImplementedError."); typedef struct { @@ -4474,20 +4474,20 @@ #if UTIME_HAVE_DIR_FD static int -utime_dir_fd(utime_t *utime, int dir_fd, char *path, int follow_symlinks) +utime_dir_fd(utime_t *utime, int dir_fd, char *path, int followlinks) { #ifdef HAVE_UTIMENSAT - int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW; + int flags = followlinks ? 0 : AT_SYMLINK_NOFOLLOW; UTIME_TO_TIMESPEC; return utimensat(dir_fd, path, time, flags); #elif defined(HAVE_FUTIMESAT) UTIME_TO_TIMEVAL; /* - * follow_symlinks will never be false here; - * we only allow !follow_symlinks and dir_fd together + * followlinks will never be false here; + * we only allow !followlinks and dir_fd together * if we have utimensat() */ - assert(follow_symlinks); + assert(followlinks); return futimesat(dir_fd, path, time); #endif } @@ -4519,7 +4519,7 @@ #if UTIME_HAVE_NOFOLLOW_SYMLINKS static int -utime_nofollow_symlinks(utime_t *utime, char *path) +utime_nofollowlinks(utime_t *utime, char *path) { #ifdef HAVE_UTIMENSAT UTIME_TO_TIMESPEC; @@ -4582,9 +4582,9 @@ PyObject *times = NULL; PyObject *ns = NULL; int dir_fd = DEFAULT_DIR_FD; - int follow_symlinks = 1; + int followlinks = 1; char *keywords[] = {"path", "times", "ns", "dir_fd", - "follow_symlinks", NULL}; + "followlinks", NULL}; utime_t utime; @@ -4610,7 +4610,7 @@ #else dir_fd_unavailable, &dir_fd, #endif - &follow_symlinks + &followlinks )) return NULL; @@ -4656,19 +4656,19 @@ } #if !UTIME_HAVE_NOFOLLOW_SYMLINKS - if (follow_symlinks_specified("utime", follow_symlinks)) + if (followlinks_specified("utime", followlinks)) goto exit; #endif if (path_and_dir_fd_invalid("utime", &path, dir_fd) || dir_fd_and_fd_invalid("utime", dir_fd, path.fd) || - fd_and_follow_symlinks_invalid("utime", path.fd, follow_symlinks)) + fd_and_followlinks_invalid("utime", path.fd, followlinks)) goto exit; #if !defined(HAVE_UTIMENSAT) - if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) { + if ((dir_fd != DEFAULT_DIR_FD) && (!followlinks)) { PyErr_SetString(PyExc_ValueError, - "utime: cannot use dir_fd and follow_symlinks " + "utime: cannot use dir_fd and followlinks " "together on this platform"); goto exit; } @@ -4715,14 +4715,14 @@ Py_BEGIN_ALLOW_THREADS #if UTIME_HAVE_NOFOLLOW_SYMLINKS - if ((!follow_symlinks) && (dir_fd == DEFAULT_DIR_FD)) - result = utime_nofollow_symlinks(&utime, path.narrow); + if ((!followlinks) && (dir_fd == DEFAULT_DIR_FD)) + result = utime_nofollowlinks(&utime, path.narrow); else #endif #if UTIME_HAVE_DIR_FD - if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) - result = utime_dir_fd(&utime, dir_fd, path.narrow, follow_symlinks); + if ((dir_fd != DEFAULT_DIR_FD) || (!followlinks)) + result = utime_dir_fd(&utime, dir_fd, path.narrow, followlinks); else #endif @@ -7219,7 +7219,7 @@ "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\ + interpreted as a directory. (On Windows, symbolic link requires\n\ Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n\ target_is_directory is ignored on non-Windows platforms.\n\ \n\ @@ -10459,11 +10459,11 @@ #ifdef USE_XATTRS PyDoc_STRVAR(posix_getxattr__doc__, -"getxattr(path, attribute, *, follow_symlinks=True) -> value\n\n\ +"getxattr(path, attribute, *, followlinks=True) -> value\n\n\ Return the value of extended attribute attribute on path.\n\ \n\ path may be either a string or an open file descriptor.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, getxattr will examine the symbolic link itself instead of the file\n\ the link points to."); @@ -10472,10 +10472,10 @@ { path_t path; path_t attribute; - int follow_symlinks = 1; + int followlinks = 1; PyObject *buffer = NULL; int i; - static char *keywords[] = {"path", "attribute", "follow_symlinks", NULL}; + static char *keywords[] = {"path", "attribute", "followlinks", NULL}; memset(&path, 0, sizeof(path)); memset(&attribute, 0, sizeof(attribute)); @@ -10483,10 +10483,10 @@ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O&|$p:getxattr", keywords, path_converter, &path, path_converter, &attribute, - &follow_symlinks)) - return NULL; - - if (fd_and_follow_symlinks_invalid("getxattr", path.fd, follow_symlinks)) + &followlinks)) + return NULL; + + if (fd_and_followlinks_invalid("getxattr", path.fd, followlinks)) goto exit; for (i = 0; ; i++) { @@ -10506,7 +10506,7 @@ Py_BEGIN_ALLOW_THREADS; if (path.fd >= 0) result = fgetxattr(path.fd, attribute.narrow, ptr, buffer_size); - else if (follow_symlinks) + else if (followlinks) result = getxattr(path.narrow, attribute.narrow, ptr, buffer_size); else result = lgetxattr(path.narrow, attribute.narrow, ptr, buffer_size); @@ -10535,10 +10535,10 @@ } PyDoc_STRVAR(posix_setxattr__doc__, -"setxattr(path, attribute, value, flags=0, *, follow_symlinks=True)\n\n\ +"setxattr(path, attribute, value, flags=0, *, followlinks=True)\n\n\ Set extended attribute attribute on path to value.\n\ path may be either a string or an open file descriptor.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, setxattr will modify the symbolic link itself instead of the file\n\ the link points to."); @@ -10549,11 +10549,11 @@ path_t attribute; Py_buffer value; int flags = 0; - int follow_symlinks = 1; + int followlinks = 1; int result; PyObject *return_value = NULL; static char *keywords[] = {"path", "attribute", "value", - "flags", "follow_symlinks", NULL}; + "flags", "followlinks", NULL}; memset(&path, 0, sizeof(path)); path.allow_fd = 1; @@ -10564,17 +10564,17 @@ path_converter, &path, path_converter, &attribute, &value, &flags, - &follow_symlinks)) - return NULL; - - if (fd_and_follow_symlinks_invalid("setxattr", path.fd, follow_symlinks)) + &followlinks)) + return NULL; + + if (fd_and_followlinks_invalid("setxattr", path.fd, followlinks)) goto exit; Py_BEGIN_ALLOW_THREADS; if (path.fd > -1) result = fsetxattr(path.fd, attribute.narrow, value.buf, value.len, flags); - else if (follow_symlinks) + else if (followlinks) result = setxattr(path.narrow, attribute.narrow, value.buf, value.len, flags); else @@ -10599,10 +10599,10 @@ } PyDoc_STRVAR(posix_removexattr__doc__, -"removexattr(path, attribute, *, follow_symlinks=True)\n\n\ +"removexattr(path, attribute, *, followlinks=True)\n\n\ Remove extended attribute attribute on path.\n\ path may be either a string or an open file descriptor.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, removexattr will modify the symbolic link itself instead of the file\n\ the link points to."); @@ -10611,10 +10611,10 @@ { path_t path; path_t attribute; - int follow_symlinks = 1; + int followlinks = 1; int result; PyObject *return_value = NULL; - static char *keywords[] = {"path", "attribute", "follow_symlinks", NULL}; + static char *keywords[] = {"path", "attribute", "followlinks", NULL}; memset(&path, 0, sizeof(path)); memset(&attribute, 0, sizeof(attribute)); @@ -10623,16 +10623,16 @@ keywords, path_converter, &path, path_converter, &attribute, - &follow_symlinks)) - return NULL; - - if (fd_and_follow_symlinks_invalid("removexattr", path.fd, follow_symlinks)) + &followlinks)) + return NULL; + + if (fd_and_followlinks_invalid("removexattr", path.fd, followlinks)) goto exit; Py_BEGIN_ALLOW_THREADS; if (path.fd > -1) result = fremovexattr(path.fd, attribute.narrow); - else if (follow_symlinks) + else if (followlinks) result = removexattr(path.narrow, attribute.narrow); else result = lremovexattr(path.narrow, attribute.narrow); @@ -10654,12 +10654,12 @@ } PyDoc_STRVAR(posix_listxattr__doc__, -"listxattr(path='.', *, follow_symlinks=True)\n\n\ +"listxattr(path='.', *, followlinks=True)\n\n\ Return a list of extended attributes on path.\n\ \n\ path may be either None, a string, or an open file descriptor.\n\ if path is None, listxattr will examine the current directory.\n\ -If follow_symlinks is False, and the last element of the path is a symbolic\n\ +If followlinks is False, and the last element of the path is a symbolic\n\ link, listxattr will examine the symbolic link itself instead of the file\n\ the link points to."); @@ -10667,22 +10667,22 @@ posix_listxattr(PyObject *self, PyObject *args, PyObject *kwargs) { path_t path; - int follow_symlinks = 1; + int followlinks = 1; Py_ssize_t i; PyObject *result = NULL; char *buffer = NULL; char *name; - static char *keywords[] = {"path", "follow_symlinks", NULL}; + static char *keywords[] = {"path", "followlinks", NULL}; memset(&path, 0, sizeof(path)); path.allow_fd = 1; path.fd = -1; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&$p:listxattr", keywords, path_converter, &path, - &follow_symlinks)) - return NULL; - - if (fd_and_follow_symlinks_invalid("listxattr", path.fd, follow_symlinks)) + &followlinks)) + return NULL; + + if (fd_and_followlinks_invalid("listxattr", path.fd, followlinks)) goto exit; name = path.narrow ? path.narrow : "."; @@ -10705,7 +10705,7 @@ Py_BEGIN_ALLOW_THREADS; if (path.fd > -1) length = flistxattr(path.fd, buffer, buffer_size); - else if (follow_symlinks) + else if (followlinks) length = listxattr(name, buffer, buffer_size); else length = llistxattr(name, buffer, buffer_size); @@ -12136,8 +12136,8 @@ { int ignored; fd_specified("", -1); - follow_symlinks_specified("", 1); - dir_fd_and_follow_symlinks_invalid("chmod", DEFAULT_DIR_FD, 1); + followlinks_specified("", 1); + dir_fd_and_followlinks_invalid("chmod", DEFAULT_DIR_FD, 1); dir_fd_converter(Py_None, &ignored); dir_fd_unavailable(Py_None, &ignored); }