[Python-checkins] r85390 - in python/branches/release27-maint: Lib/site.py Lib/sysconfig.py Misc/ACKS Misc/NEWS
victor.stinner
python-checkins at python.org
Wed Oct 13 00:53:52 CEST 2010
Author: victor.stinner
Date: Wed Oct 13 00:53:51 2010
New Revision: 85390
Log:
Merged revisions 85386-85387,85389 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85386 | victor.stinner | 2010-10-13 00:23:23 +0200 (mer., 13 oct. 2010) | 3 lines
Issue #6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the
current directory was deleted.
........
r85387 | victor.stinner | 2010-10-13 00:26:08 +0200 (mer., 13 oct. 2010) | 2 lines
#6612: add the author of the patch (W. Trevor King)
........
r85389 | victor.stinner | 2010-10-13 00:42:37 +0200 (mer., 13 oct. 2010) | 2 lines
NEWS: Move #6612 to Library section
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Lib/site.py
python/branches/release27-maint/Lib/sysconfig.py
python/branches/release27-maint/Misc/ACKS
python/branches/release27-maint/Misc/NEWS
Modified: python/branches/release27-maint/Lib/site.py
==============================================================================
--- python/branches/release27-maint/Lib/site.py (original)
+++ python/branches/release27-maint/Lib/site.py Wed Oct 13 00:53:51 2010
@@ -76,7 +76,11 @@
def makepath(*paths):
- dir = os.path.abspath(os.path.join(*paths))
+ dir = os.path.join(*paths)
+ try:
+ dir = os.path.abspath(dir)
+ except OSError:
+ pass
return dir, os.path.normcase(dir)
@@ -87,8 +91,8 @@
continue # don't mess with a PEP 302-supplied __file__
try:
m.__file__ = os.path.abspath(m.__file__)
- except AttributeError:
- continue
+ except (AttributeError, OSError):
+ pass
def removeduppaths():
Modified: python/branches/release27-maint/Lib/sysconfig.py
==============================================================================
--- python/branches/release27-maint/Lib/sysconfig.py (original)
+++ python/branches/release27-maint/Lib/sysconfig.py Wed Oct 13 00:53:51 2010
@@ -93,21 +93,28 @@
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
_CONFIG_VARS = None
_USER_BASE = None
+
+def _safe_realpath(path):
+ try:
+ return realpath(path)
+ except OSError:
+ return path
+
if sys.executable:
- _PROJECT_BASE = os.path.dirname(realpath(sys.executable))
+ _PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
else:
# sys.executable can be empty if argv[0] has been changed and Python is
# unable to retrieve the real program name
- _PROJECT_BASE = realpath(os.getcwd())
+ _PROJECT_BASE = _safe_realpath(os.getcwd())
if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
- _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir))
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir))
# PC/VS7.1
if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
- _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
# PC/AMD64
if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
- _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
+ _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
def is_python_build():
for fn in ("Setup.dist", "Setup.local"):
@@ -319,7 +326,7 @@
vars['SO'] = '.pyd'
vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
- vars['BINDIR'] = os.path.dirname(realpath(sys.executable))
+ vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
#
# public APIs
@@ -439,8 +446,12 @@
# from a different directory.
if _PYTHON_BUILD and os.name == "posix":
base = _PROJECT_BASE
+ try:
+ cwd = os.getcwd()
+ except OSError:
+ cwd = None
if (not os.path.isabs(_CONFIG_VARS['srcdir']) and
- base != os.getcwd()):
+ base != cwd):
# srcdir is relative and we are not in the same directory
# as the executable. Assume executable is in the build
# directory and make srcdir absolute.
Modified: python/branches/release27-maint/Misc/ACKS
==============================================================================
--- python/branches/release27-maint/Misc/ACKS (original)
+++ python/branches/release27-maint/Misc/ACKS Wed Oct 13 00:53:51 2010
@@ -418,6 +418,7 @@
Akira Kitada
Mads Kiilerich
Taek Joo Kim
+W. Trevor King
Paul Kippes
Steve Kirsch
Sebastian Kirsche
Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS (original)
+++ python/branches/release27-maint/Misc/NEWS Wed Oct 13 00:53:51 2010
@@ -48,6 +48,9 @@
Library
-------
+- Issue #6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the
+ current directory was deleted. Patch written by W. Trevor King.
+
- Issue #10045: Improved performance when writing after seeking past the
end of the "file" in cStringIO.
@@ -108,7 +111,7 @@
to zero.
- Issue #9816: random.Random.jumpahead(n) did not produce a sufficiently
- different internal state for small values of n. Fixed by salting the
+ different internal state for small values of n. Fixed by salting the
value.
- Issue #9792: In case of connection failure, socket.create_connection()
@@ -319,7 +322,7 @@
-----------------
- Issue #10003: Allow handling of SIGBREAK on Windows. Fixes a regression
- introduced by issue #9324.
+ introduced by issue #9324.
- Issue #8734: Avoid crash in msvcrt.get_osfhandle() when an invalid file
descriptor is provided. Patch by Pascal Chambon.
More information about the Python-checkins
mailing list