summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-05-26 13:48:34 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-05-26 13:48:34 (GMT)
commita37cfc649a0a6ed3ec963748886e85428eb7edd9 (patch)
tree055d611fbe978494f750aa17106215631bb5e51a /Lib
parent2c9c7a5f33d502fa468e38537d57834c7e33aa4d (diff)
downloadcpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.zip
cpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.tar.gz
cpython-a37cfc649a0a6ed3ec963748886e85428eb7edd9.tar.bz2
Merged revisions 63402,63405,63411,63457,63467-63468,63480,63507-63508,63516,63534,63541 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r63402 | raymond.hettinger | 2008-05-16 23:13:36 -0500 (Fri, 16 May 2008) | 1 line Fix-up docstring ........ r63405 | gregory.p.smith | 2008-05-17 02:17:34 -0500 (Sat, 17 May 2008) | 3 lines fix issue2381: test_subprocess fails if your sys.executable is on a path with a space in it. ........ r63411 | lars.gustaebel | 2008-05-17 11:50:22 -0500 (Sat, 17 May 2008) | 8 lines Replace signatures with optional arguments in square brackets with keyword arguments and the actual default values. Fix references that point nowhere or to the wrong place. Add description of the ENCODING module-level variable. Fix the URL pointing to the GNU tar manual. Remove two obsolete examples. Add an example on how to use a generator with TarFile.extractall(). ........ r63457 | ronald.oussoren | 2008-05-18 15:09:54 -0500 (Sun, 18 May 2008) | 9 lines MacOSX: ctypes annotation in implementation of getproxies_macosx_sysconf getproxies_macosx_sysconf uses ctypes to call SystemConfiguration APIs. This checkin adds ctypes annotation to specify the right argument types for the API's that are used. This is needed to be able to use urllib on a 64-bit system, without annotations you'd get a hard crash. ........ r63467 | andrew.kuchling | 2008-05-18 22:03:46 -0500 (Sun, 18 May 2008) | 1 line Re-organize the increasingly long list of deprecated modules ........ r63468 | benjamin.peterson | 2008-05-19 06:55:54 -0500 (Mon, 19 May 2008) | 2 lines just MacOS (instead of MacOS 9) ........ r63480 | neal.norwitz | 2008-05-20 00:21:57 -0500 (Tue, 20 May 2008) | 1 line Add html package so it gets installed and more tests work (from installed copy) ........ r63507 | vinay.sajip | 2008-05-20 10:34:36 -0500 (Tue, 20 May 2008) | 1 line Fixed: #2914 (RFE for UTC support in TimedRotatingFileHandler) and #2929 (wrong filename used to delete old log files). ........ r63508 | vinay.sajip | 2008-05-20 10:37:22 -0500 (Tue, 20 May 2008) | 1 line Updated with fixes for #2914 and #2929. ........ r63516 | martin.v.loewis | 2008-05-21 02:31:31 -0500 (Wed, 21 May 2008) | 2 lines Add Robert Schuppenies. ........ r63534 | brett.cannon | 2008-05-21 22:18:35 -0500 (Wed, 21 May 2008) | 1 line Add Quentin Gallet-Gilles for (at least) a fixer for markupbase. ........ r63541 | raymond.hettinger | 2008-05-22 19:49:27 -0500 (Thu, 22 May 2008) | 1 line Docs for Issue 2819. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/handlers.py32
-rw-r--r--Lib/poplib.py2
-rw-r--r--Lib/test/test_subprocess.py4
-rw-r--r--Lib/urllib.py23
4 files changed, 45 insertions, 16 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 9cb0e09..c871ed0 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -153,10 +153,11 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
If backupCount is > 0, when rollover is done, no more than backupCount
files are kept - the oldest ones are deleted.
"""
- def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0):
+ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None, delay=0, utc=0):
BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
self.when = when.upper()
self.backupCount = backupCount
+ self.utc = utc
# Calculate the real rollover interval, which is just the number of
# seconds between rollovers. Also set the filename suffix used when
# a rollover occurs. Current 'when' events supported:
@@ -211,7 +212,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
# the rest. Note that this code doesn't care about leap seconds. :)
if self.when == 'MIDNIGHT' or self.when.startswith('W'):
# This could be done with less code, but I wanted it to be clear
- t = time.localtime(currentTime)
+ if utc:
+ t = time.gmtime(currentTime)
+ else:
+ t = time.localtime(currentTime)
currentHour = t[3]
currentMinute = t[4]
currentSecond = t[5]
@@ -242,13 +246,14 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else:
daysToWait = 6 - day + self.dayOfWeek + 1
newRolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
- dstNow = t[-1]
- dstAtRollover = time.localtime(newRolloverAt)[-1]
- if dstNow != dstAtRollover:
- if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
- newRolloverAt = newRolloverAt - 3600
- else: # DST bows out before next rollover, so we need to add an hour
- newRolloverAt = newRolloverAt + 3600
+ if not utc:
+ dstNow = t[-1]
+ dstAtRollover = time.localtime(newRolloverAt)[-1]
+ if dstNow != dstAtRollover:
+ if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
+ newRolloverAt = newRolloverAt - 3600
+ else: # DST bows out before next rollover, so we need to add an hour
+ newRolloverAt = newRolloverAt + 3600
self.rolloverAt = newRolloverAt
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
@@ -281,7 +286,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
if fileName[:plen] == prefix:
suffix = fileName[plen:]
if self.extMatch.match(suffix):
- result.append(fileName)
+ result.append(os.path.join(dirName, fileName))
result.sort()
if len(result) < self.backupCount:
result = []
@@ -300,7 +305,10 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
self.stream.close()
# get the time that this sequence started at and make it a TimeTuple
t = self.rolloverAt - self.interval
- timeTuple = time.localtime(t)
+ if self.utc:
+ timeTuple = time.gmtime(t)
+ else:
+ timeTuple = time.localtime(t)
dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
if os.path.exists(dfn):
os.remove(dfn)
@@ -321,7 +329,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
while newRolloverAt <= currentTime:
newRolloverAt = newRolloverAt + self.interval
#If DST changes and midnight or weekly rollover, adjust for this.
- if self.when == 'MIDNIGHT' or self.when.startswith('W'):
+ if (self.when == 'MIDNIGHT' or self.when.startswith('W')) and not self.utc:
dstNow = time.localtime(currentTime)[-1]
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover:
diff --git a/Lib/poplib.py b/Lib/poplib.py
index be78b3e..aa4600c 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -240,7 +240,7 @@ class POP3:
def rset(self):
- """Not sure what this does."""
+ """Unmark all messages marked for deletion."""
return self._shortcmd('RSET')
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 5a325ce..3f877f2 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -534,7 +534,7 @@ class ProcessTestCase(unittest.TestCase):
# args is a string
f, fname = self.mkstemp()
os.write(f, "#!/bin/sh\n")
- os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
+ os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)
os.close(f)
os.chmod(fname, 0o700)
@@ -576,7 +576,7 @@ class ProcessTestCase(unittest.TestCase):
# call() function with string argument on UNIX
f, fname = self.mkstemp()
os.write(f, "#!/bin/sh\n")
- os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
+ os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" %
sys.executable)
os.close(f)
os.chmod(fname, 0o700)
diff --git a/Lib/urllib.py b/Lib/urllib.py
index a5171ef..500bf06 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -1271,6 +1271,24 @@ def proxy_bypass_environment(host):
if sys.platform == 'darwin':
+
+ def _CFSetup(sc):
+ from ctypes import c_int32, c_void_p, c_char_p, c_int
+ sc.CFStringCreateWithCString.argtypes = [ c_void_p, c_char_p, c_int32 ]
+ sc.CFStringCreateWithCString.restype = c_void_p
+ sc.SCDynamicStoreCopyProxies.argtypes = [ c_void_p ]
+ sc.SCDynamicStoreCopyProxies.restype = c_void_p
+ sc.CFDictionaryGetValue.argtypes = [ c_void_p, c_void_p ]
+ sc.CFDictionaryGetValue.restype = c_void_p
+ sc.CFStringGetLength.argtypes = [ c_void_p ]
+ sc.CFStringGetLength.restype = c_int32
+ sc.CFStringGetCString.argtypes = [ c_void_p, c_char_p, c_int32, c_int32 ]
+ sc.CFStringGetCString.restype = c_int32
+ sc.CFNumberGetValue.argtypes = [ c_void_p, c_int, c_void_p ]
+ sc.CFNumberGetValue.restype = c_int32
+ sc.CFRelease.argtypes = [ c_void_p ]
+ sc.CFRelease.restype = None
+
def _CStringFromCFString(sc, value):
from ctypes import create_string_buffer
length = sc.CFStringGetLength(value) + 1
@@ -1307,6 +1325,7 @@ if sys.platform == 'darwin':
return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3]
sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
+ _CFSetup(sc)
hostIP = None
@@ -1319,6 +1338,8 @@ if sys.platform == 'darwin':
proxyDict = sc.SCDynamicStoreCopyProxies(None)
+ if proxyDict is None:
+ return False
try:
# Check for simple host names:
@@ -1372,11 +1393,11 @@ if sys.platform == 'darwin':
from ctypes.util import find_library
sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
+ _CFSetup(sc)
if not sc:
return {}
-
kSCPropNetProxiesHTTPEnable = sc.CFStringCreateWithCString(0, b"HTTPEnable", 0)
kSCPropNetProxiesHTTPProxy = sc.CFStringCreateWithCString(0, b"HTTPProxy", 0)
kSCPropNetProxiesHTTPPort = sc.CFStringCreateWithCString(0, b"HTTPPort", 0)