# HG changeset patch # User Yen Chi Hsuan # Date 1475417820 -28800 # Sun Oct 02 22:17:00 2016 +0800 # Node ID 22169fe699b6d4b4236cfa6a951e85ec1f75c1c2 # Parent b244bf74b638624ae1f9dff78cf904d4ac1a8879 Remove macpath module and references to it diff --git a/Doc/library/filesys.rst b/Doc/library/filesys.rst --- a/Doc/library/filesys.rst +++ b/Doc/library/filesys.rst @@ -17,17 +17,16 @@ in this chapter is: fileinput.rst stat.rst filecmp.rst tempfile.rst glob.rst fnmatch.rst linecache.rst shutil.rst - macpath.rst .. seealso:: Module :mod:`os` Operating system interfaces, including functions to work with files at a lower level than Python :term:`file objects `. diff --git a/Doc/library/macpath.rst b/Doc/library/macpath.rst deleted file mode 100644 --- a/Doc/library/macpath.rst +++ /dev/null @@ -1,19 +0,0 @@ -:mod:`macpath` --- Mac OS 9 path manipulation functions -======================================================= - -.. module:: macpath - :synopsis: Mac OS 9 path manipulation functions. - -**Source code:** :source:`Lib/macpath.py` - --------------- - -This module is the Mac OS 9 (and earlier) implementation of the :mod:`os.path` -module. It can be used to manipulate old-style Macintosh pathnames on Mac OS X -(or any other platform). - -The following functions are available in this module: :func:`normcase`, -:func:`normpath`, :func:`isabs`, :func:`join`, :func:`split`, :func:`isdir`, -:func:`isfile`, :func:`walk`, :func:`exists`. For other functions available in -:mod:`os.path` dummy counterparts are available. - diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -1,17 +1,16 @@ :mod:`os.path` --- Common pathname manipulations ================================================ .. module:: os.path :synopsis: Operations on pathnames. -**Source code:** :source:`Lib/posixpath.py` (for POSIX), -:source:`Lib/ntpath.py` (for Windows NT), -and :source:`Lib/macpath.py` (for Macintosh) +**Source code:** :source:`Lib/posixpath.py` (for POSIX) +and :source:`Lib/ntpath.py` (for Windows NT) .. index:: single: path; operations -------------- This module implements some useful functions on pathnames. To read or write files see :func:`open`, and for accessing the filesystem see the :mod:`os` module. The path parameters can be passed as either strings, @@ -47,17 +46,16 @@ the :mod:`glob` module.) :mod:`os.path` module is always the path module suitable for the operating system Python is running on, and therefore usable for local paths. However, you can also import and use the individual modules if you want to manipulate a path that is *always* in one of the different formats. They all have the same interface: * :mod:`posixpath` for UNIX-style paths * :mod:`ntpath` for Windows paths - * :mod:`macpath` for old-style MacOS paths .. function:: abspath(path) Return a normalized absolutized version of the pathname *path*. On most platforms, this is equivalent to calling the function :func:`normpath` as follows: ``normpath(join(os.getcwd(), path))``. diff --git a/Lib/macpath.py b/Lib/macpath.py deleted file mode 100644 --- a/Lib/macpath.py +++ /dev/null @@ -1,211 +0,0 @@ -"""Pathname and path-related operations for the Macintosh.""" - -import os -from stat import * -import genericpath -from genericpath import * - -__all__ = ["normcase","isabs","join","splitdrive","split","splitext", - "basename","dirname","commonprefix","getsize","getmtime", - "getatime","getctime", "islink","exists","lexists","isdir","isfile", - "expanduser","expandvars","normpath","abspath", - "curdir","pardir","sep","pathsep","defpath","altsep","extsep", - "devnull","realpath","supports_unicode_filenames"] - -# strings representing various path-related bits and pieces -# These are primarily for export; internally, they are hardcoded. -curdir = ':' -pardir = '::' -extsep = '.' -sep = ':' -pathsep = '\n' -defpath = ':' -altsep = None -devnull = 'Dev:Null' - -def _get_colon(path): - if isinstance(path, bytes): - return b':' - else: - return ':' - -# Normalize the case of a pathname. Dummy in Posix, but .lower() here. - -def normcase(path): - if not isinstance(path, (bytes, str)): - raise TypeError("normcase() argument must be str or bytes, " - "not '{}'".format(path.__class__.__name__)) - return path.lower() - - -def isabs(s): - """Return true if a path is absolute. - On the Mac, relative paths begin with a colon, - but as a special case, paths with no colons at all are also relative. - Anything else is absolute (the string up to the first colon is the - volume name).""" - - colon = _get_colon(s) - return colon in s and s[:1] != colon - - -def join(s, *p): - try: - colon = _get_colon(s) - path = s - if not p: - path[:0] + colon #23780: Ensure compatible data type even if p is null. - for t in p: - if (not path) or isabs(t): - path = t - continue - if t[:1] == colon: - t = t[1:] - if colon not in path: - path = colon + path - if path[-1:] != colon: - path = path + colon - path = path + t - return path - except (TypeError, AttributeError, BytesWarning): - genericpath._check_arg_types('join', s, *p) - raise - - -def split(s): - """Split a pathname into two parts: the directory leading up to the final - bit, and the basename (the filename, without colons, in that directory). - The result (s, t) is such that join(s, t) yields the original argument.""" - - colon = _get_colon(s) - if colon not in s: return s[:0], s - col = 0 - for i in range(len(s)): - if s[i:i+1] == colon: col = i + 1 - path, file = s[:col-1], s[col:] - if path and not colon in path: - path = path + colon - return path, file - - -def splitext(p): - if isinstance(p, bytes): - return genericpath._splitext(p, b':', altsep, b'.') - else: - return genericpath._splitext(p, sep, altsep, extsep) -splitext.__doc__ = genericpath._splitext.__doc__ - -def splitdrive(p): - """Split a pathname into a drive specification and the rest of the - path. Useful on DOS/Windows/NT; on the Mac, the drive is always - empty (don't use the volume name -- it doesn't have the same - syntactic and semantic oddities as DOS drive letters, such as there - being a separate current directory per drive).""" - - return p[:0], p - - -# Short interfaces to split() - -def dirname(s): return split(s)[0] -def basename(s): return split(s)[1] - -def ismount(s): - if not isabs(s): - return False - components = split(s) - return len(components) == 2 and not components[1] - -def islink(s): - """Return true if the pathname refers to a symbolic link.""" - - try: - import Carbon.File - return Carbon.File.ResolveAliasFile(s, 0)[2] - except: - return False - -# Is `stat`/`lstat` a meaningful difference on the Mac? This is safe in any -# case. - -def lexists(path): - """Test whether a path exists. Returns True for broken symbolic links""" - - try: - st = os.lstat(path) - except OSError: - return False - return True - -def expandvars(path): - """Dummy to retain interface-compatibility with other operating systems.""" - return path - - -def expanduser(path): - """Dummy to retain interface-compatibility with other operating systems.""" - return path - -class norm_error(Exception): - """Path cannot be normalized""" - -def normpath(s): - """Normalize a pathname. Will return the same result for - equivalent paths.""" - - colon = _get_colon(s) - - if colon not in s: - return colon + s - - comps = s.split(colon) - i = 1 - while i < len(comps)-1: - if not comps[i] and comps[i-1]: - if i > 1: - del comps[i-1:i+1] - i = i - 1 - else: - # best way to handle this is to raise an exception - raise norm_error('Cannot use :: immediately after volume name') - else: - i = i + 1 - - s = colon.join(comps) - - # remove trailing ":" except for ":" and "Volume:" - if s[-1:] == colon and len(comps) > 2 and s != colon*len(s): - s = s[:-1] - return s - -def abspath(path): - """Return an absolute path.""" - if not isabs(path): - if isinstance(path, bytes): - cwd = os.getcwdb() - else: - cwd = os.getcwd() - path = join(cwd, path) - return normpath(path) - -# realpath is a no-op on systems without islink support -def realpath(path): - path = abspath(path) - try: - import Carbon.File - except ImportError: - return path - if not path: - return path - colon = _get_colon(path) - components = path.split(colon) - path = components[0] + colon - for c in components[1:]: - path = join(path, c) - try: - path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname() - except Carbon.File.Error: - pass - return path - -supports_unicode_filenames = True diff --git a/Lib/posixpath.py b/Lib/posixpath.py --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -1,15 +1,15 @@ """Common operations on Posix pathnames. Instead of importing this module directly, import os and refer to this module as os.path. The "os.path" name is an alias for this -module on Posix systems; on other systems (e.g. Mac, Windows), +module on Posix systems; on other systems (e.g. Windows), os.path provides the same operations in a manner specific to that -platform, and is an alias to another module (e.g. macpath, ntpath). +platform, and is an alias to another module (e.g. ntpath). Some of this can actually be useful on non-Posix systems too, e.g. for manipulation of the pathname component of URLs. """ import os import sys import stat diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py --- a/Tools/freeze/freeze.py +++ b/Tools/freeze/freeze.py @@ -119,17 +119,17 @@ def main(): debug = 1 odir = '' win = sys.platform[:3] == 'win' replace_paths = [] # settable with -r option error_if_any_missing = 0 # default the exclude list for each platform if win: exclude = exclude + [ - 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', ] + 'dos', 'dospath', 'mac', 'macfs', 'MACFS', 'posix', ] fail_import = exclude[:] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile'