Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision 23cafd27cfd45f143c21a61319d230acc5ecf0ea authored by Benjamin Peterson on 04 April 2009, 15:38:19 UTC, committed by Benjamin Peterson on 04 April 2009, 15:38:19 UTC
........ r70711 | r.david.murray | 2009-03-30 10:14:01 -0500 (Mon, 30 Mar 2009) | 2 lines Convert import try/except to use test_support.import_module(). ........ r70713 | ronald.oussoren | 2009-03-30 10:20:46 -0500 (Mon, 30 Mar 2009) | 2 lines This patch fixes issue 1254695 (wrong argument type conversion in Carbon.Qt) ........ r70716 | r.david.murray | 2009-03-30 10:30:34 -0500 (Mon, 30 Mar 2009) | 2 lines Revert incorrect change. ........ r70719 | ronald.oussoren | 2009-03-30 11:01:51 -0500 (Mon, 30 Mar 2009) | 2 lines Fix for issue 896199 (some Carbon modules aren't present in the documentation) ........ r70747 | r.david.murray | 2009-03-30 15:04:06 -0500 (Mon, 30 Mar 2009) | 3 lines Remove references to test_socket_ssl which was deleted in trunk in r64392 and py3k in r59038. ........ r70772 | barry.warsaw | 2009-03-30 17:42:17 -0500 (Mon, 30 Mar 2009) | 5 lines A fix for issue 1974, inspired by the patch from Andi Albrecht (aalbrecht), though with some changes by me. This patch should not be back ported or forward ported. It's a bit too risky for 2.6 and 3.x does things fairly differently. ........ r70821 | jeremy.hylton | 2009-03-31 10:04:15 -0500 (Tue, 31 Mar 2009) | 2 lines Add check for PyDict_Update() error. ........ r70830 | georg.brandl | 2009-03-31 11:11:45 -0500 (Tue, 31 Mar 2009) | 1 line #5529: backport new docs of import semantics written by Brett to 2.x. ........ r70844 | raymond.hettinger | 2009-03-31 12:47:06 -0500 (Tue, 31 Mar 2009) | 1 line Per the language summit, the optional fastpath imports should use from-import-star. ........ r70873 | josiah.carlson | 2009-03-31 14:32:34 -0500 (Tue, 31 Mar 2009) | 2 lines This resolves issue 1161031. Tests pass. ........ r70901 | georg.brandl | 2009-03-31 16:40:24 -0500 (Tue, 31 Mar 2009) | 2 lines Remove warning about pending Win9x support removal. ........ r70902 | georg.brandl | 2009-03-31 16:43:03 -0500 (Tue, 31 Mar 2009) | 1 line #1675026: add a note about a strange Windows problem, and remove notes about AtheOS. ........ r70904 | josiah.carlson | 2009-03-31 16:49:36 -0500 (Tue, 31 Mar 2009) | 3 lines Made handle_expt_event() be called last, so that we don't accidentally read after closing the socket. ........ r70918 | raymond.hettinger | 2009-03-31 17:43:03 -0500 (Tue, 31 Mar 2009) | 1 line Improve examples for collections.deque() ........ r70934 | josiah.carlson | 2009-03-31 20:28:11 -0500 (Tue, 31 Mar 2009) | 2 lines Fix for failing asyncore tests. ........ r70969 | raymond.hettinger | 2009-04-01 13:50:56 -0500 (Wed, 01 Apr 2009) | 1 line Issue #5647: MutableSet.__iand__() no longer mutates self during iteration. ........ r71026 | benjamin.peterson | 2009-04-01 21:52:46 -0500 (Wed, 01 Apr 2009) | 1 line fix error handling ........ r71073 | raymond.hettinger | 2009-04-02 17:25:40 -0500 (Thu, 02 Apr 2009) | 4 lines Have namedtuple's field renamer assign names that are consistent with the corresponding tuple index. ........ r71075 | raymond.hettinger | 2009-04-02 17:34:17 -0500 (Thu, 02 Apr 2009) | 1 line Update docs for namedtuple's renaming change. ........ r71078 | raymond.hettinger | 2009-04-02 21:43:54 -0500 (Thu, 02 Apr 2009) | 4 lines Localize the function lookup in timeit. ........
1 parent 85b3098
Tip revision: 23cafd27cfd45f143c21a61319d230acc5ecf0ea authored by Benjamin Peterson on 04 April 2009, 15:38:19 UTC
Blocked revisions 70711,70713,70716,70719,70747,70772,70821,70830,70844,70873,70901-70902,70904,70918,70934,70969,71026,71073,71075,71078 via svnmerge
Blocked revisions 70711,70713,70716,70719,70747,70772,70821,70830,70844,70873,70901-70902,70904,70918,70934,70969,71026,71073,71075,71078 via svnmerge
Tip revision: 23cafd2
macpath.py
"""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 <s>.lower() here.
def normcase(path):
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):
colon = _get_colon(s)
path = s
for t in p:
if (not s) 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
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 os.error:
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):
path = join(os.getcwd(), 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)
path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname()
return path
supports_unicode_filenames = False
Computing file changes ...