From: Benjamin Peterson Date: Tue, 1 Apr 2014 23:17:57 +0000 (-0400) Subject: merge 3.2 (#21082) X-Git-Tag: v3.4.1rc1~140^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4717e2112b80eae8466bf06e2523042537d54000;p=python merge 3.2 (#21082) --- 4717e2112b80eae8466bf06e2523042537d54000 diff --cc Doc/library/os.rst index 72693f14b0,d1689631aa..d7b98292ad --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@@ -1527,111 -1119,94 +1527,115 @@@ features .. versionchanged:: 3.2 Added support for Windows 6.0 (Vista) symbolic links. + .. versionchanged:: 3.3 + Added the *dir_fd* parameter. -.. function:: mkfifo(path[, mode]) - Create a FIFO (a named pipe) named *path* with numeric mode *mode*. The - default *mode* is ``0o666`` (octal). The current umask value is first masked - out from the mode. +.. function:: mkdir(path, mode=0o777, *, dir_fd=None) - FIFOs are pipes that can be accessed like regular files. FIFOs exist until they - are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as - rendezvous between "client" and "server" type processes: the server opens the - FIFO for reading, and the client opens it for writing. Note that :func:`mkfifo` - doesn't open the FIFO --- it just creates the rendezvous point. + Create a directory named *path* with numeric mode *mode*. - Availability: Unix. + On some systems, *mode* is ignored. Where it is used, the current umask + value is first masked out. If the directory already exists, :exc:`OSError` + is raised. + This function can also support :ref:`paths relative to directory descriptors + `. -.. function:: mknod(filename[, mode=0o600[, device=0]]) + It is also possible to create temporary directories; see the + :mod:`tempfile` module's :func:`tempfile.mkdtemp` function. - Create a filesystem node (file, device special file or named pipe) named - *filename*. *mode* specifies both the permissions to use and the type of node - to be created, being combined (bitwise OR) with one of ``stat.S_IFREG``, - ``stat.S_IFCHR``, ``stat.S_IFBLK``, and ``stat.S_IFIFO`` (those constants are - available in :mod:`stat`). For ``stat.S_IFCHR`` and ``stat.S_IFBLK``, - *device* defines the newly created device special file (probably using - :func:`os.makedev`), otherwise it is ignored. + Availability: Unix, Windows. + .. versionadded:: 3.3 + The *dir_fd* argument. -.. function:: major(device) - Extract the device major number from a raw device number (usually the - :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). +.. function:: makedirs(path, mode=0o777, exist_ok=False) + .. index:: + single: directory; creating + single: UNC paths; and os.makedirs() -.. function:: minor(device) + Recursive directory creation function. Like :func:`mkdir`, but makes all + intermediate-level directories needed to contain the leaf directory. - Extract the device minor number from a raw device number (usually the - :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). + The default *mode* is ``0o777`` (octal). On some systems, *mode* is + ignored. Where it is used, the current umask value is first masked out. - If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if - the target directory already exists. If *exist_ok* is ``True`` an - :exc:`OSError` is still raised if the umask-masked *mode* is different from - the existing mode, on systems where the mode is used. :exc:`OSError` will - also be raised if the directory creation fails. ++ If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if the ++ target directory already exists. -.. function:: makedev(major, minor) + .. note:: - Compose a raw device number from the major and minor device numbers. + :func:`makedirs` will become confused if the path elements to create + include :data:`pardir` (eg. ".." on UNIX systems). + This function handles UNC paths correctly. -.. function:: mkdir(path[, mode]) + .. versionadded:: 3.2 + The *exist_ok* parameter. - Create a directory named *path* with numeric mode *mode*. The default *mode* - is ``0o777`` (octal). On some systems, *mode* is ignored. Where it is used, - the current umask value is first masked out. If the directory already - exists, :exc:`OSError` is raised. ++ .. versionchanged:: 3.3.6 + - It is also possible to create temporary directories; see the - :mod:`tempfile` module's :func:`tempfile.mkdtemp` function. ++ Before Python 3.3.6, if *exist_ok* was ``True`` and the directory existed, ++ :func:`makedirs` would still raise an error if *mode* did not match the ++ mode of the existing directory. Since this behavior was impossible to ++ implement safely, it was removed in Python 3.3.6. See :issue:`21082`. + - Availability: Unix, Windows. +.. function:: mkfifo(path, mode=0o666, *, dir_fd=None) -.. function:: makedirs(path, mode=0o777, exist_ok=False) + Create a FIFO (a named pipe) named *path* with numeric mode *mode*. + The current umask value is first masked out from the mode. - .. index:: - single: directory; creating - single: UNC paths; and os.makedirs() + This function can also support :ref:`paths relative to directory descriptors + `. - Recursive directory creation function. Like :func:`mkdir`, but makes all - intermediate-level directories needed to contain the leaf directory. + FIFOs are pipes that can be accessed like regular files. FIFOs exist until they + are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as + rendezvous between "client" and "server" type processes: the server opens the + FIFO for reading, and the client opens it for writing. Note that :func:`mkfifo` + doesn't open the FIFO --- it just creates the rendezvous point. + + Availability: Unix. + + .. versionadded:: 3.3 + The *dir_fd* argument. + + +.. function:: mknod(filename, mode=0o600, device=0, *, dir_fd=None) + + Create a filesystem node (file, device special file or named pipe) named + *filename*. *mode* specifies both the permissions to use and the type of node + to be created, being combined (bitwise OR) with one of ``stat.S_IFREG``, + ``stat.S_IFCHR``, ``stat.S_IFBLK``, and ``stat.S_IFIFO`` (those constants are + available in :mod:`stat`). For ``stat.S_IFCHR`` and ``stat.S_IFBLK``, + *device* defines the newly created device special file (probably using + :func:`os.makedev`), otherwise it is ignored. + + This function can also support :ref:`paths relative to directory descriptors + `. + + .. versionadded:: 3.3 + The *dir_fd* argument. - The default *mode* is ``0o777`` (octal). On some systems, *mode* is - ignored. Where it is used, the current umask value is first masked out. - If *exist_ok* is ``False`` (the default), an :exc:`OSError` is raised if the - target directory already exists. +.. function:: major(device) - .. note:: + Extract the device major number from a raw device number (usually the + :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). - :func:`makedirs` will become confused if the path elements to create - include :data:`pardir` (eg. ".." on UNIX systems). - This function handles UNC paths correctly. +.. function:: minor(device) - .. versionadded:: 3.2 - The *exist_ok* parameter. + Extract the device minor number from a raw device number (usually the + :attr:`st_dev` or :attr:`st_rdev` field from :c:type:`stat`). - .. versionchanged:: 3.2.5 - Before Python 3.2.5, if *exist_ok* was ``True`` and the directory existed, - :func:`makedirs` would still raise an error if *mode* did not match the - mode of the existing directory. Since this behavior was impossible to - implement safely, it was removed in Python 3.2.6. See :issue:`21082`. +.. function:: makedev(major, minor) + + Compose a raw device number from the major and minor device numbers. .. function:: pathconf(path, name) diff --cc Lib/os.py index 87689cc269,34cbdc9311..b42ccbab38 --- a/Lib/os.py +++ b/Lib/os.py @@@ -230,12 -114,8 +230,6 @@@ SEEK_SET = SEEK_CUR = 1 SEEK_END = 2 - - def _get_masked_mode(mode): - mask = umask(0) - umask(mask) - return mode & ~mask -#' -- # Super directory utilities. # (Inspired by Eric Raymond; the doc strings are mostly his) diff --cc Lib/test/test_os.py index d70a0aeaf8,a08edd6974..56309bf247 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@@ -869,12 -575,14 +869,12 @@@ class MakedirTests(unittest.TestCase) path = os.path.join(support.TESTFN, 'dir1') mode = 0o777 old_mask = os.umask(0o022) - try: - os.makedirs(path, mode) - self.assertRaises(OSError, os.makedirs, path, mode) - self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False) - os.makedirs(path, 0o776, exist_ok=True) - os.makedirs(path, mode=mode, exist_ok=True) - finally: - os.umask(old_mask) + os.makedirs(path, mode) + self.assertRaises(OSError, os.makedirs, path, mode) + self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False) - self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True) ++ os.makedirs(path, 0o776, exist_ok=True) + os.makedirs(path, mode=mode, exist_ok=True) + os.umask(old_mask) def test_exist_ok_s_isgid_directory(self): path = os.path.join(support.TESTFN, 'dir1') diff --cc Misc/NEWS index 187d4b2ba6,3913f94956..cd9154683d --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -13,90 -10,79 +13,93 @@@ Core and Builtin Library ------- +- Issue #20633: Replace relative import by absolute import. + + - Issue #21082: In os.makedirs, do not set the process-wide umask. Note this + changes behavior of makedirs when exist_ok=True. + -- Issue #20246: Fix buffer overflow in socket.recvfrom_into. +- Issue #20875: Prevent possible gzip "'read' is not defined" NameError. + Patch by Claudiu Popa. -- Issue #12226: HTTPS is now used by default when connecting to PyPI. +- Issue #11599: When an external command (e.g. compiler) fails, distutils now + prints out the whole command line (instead of just the command name) if the + environment variable DISTUTILS_DEBUG is set. -- Issue #19435: Fix directory traversal attack on CGIHttpRequestHandler. +- Issue #4931: distutils should not produce unhelpful "error: None" messages + anymore. distutils.util.grok_environment_error is kept but doc-deprecated. -- Issue #14984: On POSIX systems, when netrc is called without a filename - argument (and therefore is reading the user's $HOME/.netrc file), it now - enforces the same security rules as typical ftp clients: the .netrc file must - be owned by the user that owns the process and must not be readable by any - other user. +- Issue #20283: RE pattern methods now accept the string keyword parameters + as documented. The pattern and source keyword parameters are left as + deprecated aliases. + +Tests +----- -- Fix tkinter regression introduced by the security fix in issue #16248. +- Issue #20946: Correct alignment assumptions of some ctypes tests. -- Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of - service using certificates with many wildcards (CVE-2013-2099). +- Issue #20939: Fix test_geturl failure in test_urllibnet due to + new redirect of http://www.python.org/ to https://www.python.org. -What's New in Python 3.2.5? +What's New in Python 3.3.5? =========================== -*Release date: 13-May-2013* +*Release date: 09-Mar-2014* -Library -------- +No changes from release candidate 2. -- Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of - service using certificates with many wildcards (CVE-2013-2099). -- Issue #17192: Restore the patch for Issue #11729 and Issue #10309 - which were omitted in 3.2.4 when updating the bundled version of - libffi used by ctypes. +What's New in Python 3.3.5 release candidate 2? +=============================================== -- Issue #15535: Fix namedtuple pickles which were picking up the OrderedDict - instead of just the underlying tuple. +*Release date: 02-Mar-2014* -- Issue #1159051: Back out a fix for handling corrupted gzip files that - broke backwards compatibility. +Core and Builtins +----------------- -- Issue #17915: Fix interoperability of xml.sax with file objects returned by - codecs.open(). +- Issue #20731: Properly position in source code files even if they + are opened in text mode. Patch by Serhiy Storchaka. -Build ------ +- Issue #19619: str.encode, bytes.decode and bytearray.decode now use an + internal API to throw LookupError for known non-text encodings, rather + than attempting the encoding or decoding operation and then throwing a + TypeError for an unexpected output type. (The latter mechanism remains + in place for third party non-text encodings) -- Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3, - such as was shipped with Centos 5 and Mac OS X 10.4. +Library +------- -Tests ------ +- Issue #20778: Fix modulefinder to work with bytecode-only modules. -- Issue #17843: Removed bz2 test data file that was triggering false-positive - virus warnings with certain antivirus software. +- Issue #20791: copy.copy() now doesn't make a copy when the input is + a bytes object. Initial patch by Peter Otten. +- Issue #20621: Fixes a zipimport bug introduced in 3.3.4 that could cause + spurious crashes or SystemErrors when importing modules or packages from a + zip file. The change causing the problem was reverted. -What's New in Python 3.2.4? -=========================== +- Issue #20404: io.TextIOWrapper (and hence the open() builtin) now uses the + internal codec marking system added for issue #19619 to throw LookupError + for known non-text encodings at stream construction time. The existing + output type checks remain in place to deal with unmarked third party + codecs. -*Release date: 07-Apr-2013* +Tests +----- -Library -------- +- Issue #20743: Fix a reference leak in test_tcl. -- Issue #17625: In IDLE, close the replace dialog after it is used. +Tools/Demos +----------- + +- Issue #20535: PYTHONWARNING no longer affects the run_tests.py script. + Patch by Arfrever Frehtes Taifersar Arahesis. -What's New in Python 3.2.4 release candidate 1? +What's New in Python 3.3.5 release candidate 1? =============================================== -*Release date: 24-Mar-2013* +*Release date: 23-Feb-2014* Core and Builtins -----------------