benjamin.peterson
2008-08-17 20:23:47 UTC
Author: benjamin.peterson
Date: Sun Aug 17 22:23:46 2008
New Revision: 65781
Log:
Merged revisions 65659,65693,65700,65702,65706-65707,65761 via svnmerge from
svn+ssh://pythondev at svn.python.org/python/trunk
........
r65659 | martin.v.loewis | 2008-08-12 15:45:21 -0500 (Tue, 12 Aug 2008) | 2 lines
Add Hirokazu Yamamoto.
........
r65693 | georg.brandl | 2008-08-15 13:35:09 -0500 (Fri, 15 Aug 2008) | 2 lines
#3558: Attribute reference binds more tightly than subscription and call.
........
r65700 | antoine.pitrou | 2008-08-15 16:03:21 -0500 (Fri, 15 Aug 2008) | 3 lines
#2676: email/message.py [Message.get_content_type]: Trivial regex hangs on pathological input
........
r65702 | gregory.p.smith | 2008-08-15 18:14:00 -0500 (Fri, 15 Aug 2008) | 2 lines
document that waitpid raises OSError
........
r65706 | benjamin.peterson | 2008-08-15 22:02:41 -0500 (Fri, 15 Aug 2008) | 1 line
fix markup
........
r65707 | benjamin.peterson | 2008-08-15 22:13:07 -0500 (Fri, 15 Aug 2008) | 1 line
note how os.utime should be used for emulating touch
........
r65761 | antoine.pitrou | 2008-08-17 08:06:29 -0500 (Sun, 17 Aug 2008) | 3 lines
fix ZipFile.testzip() to work with very large embedded files
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/library/os.rst
python/branches/py3k/Doc/reference/expressions.rst
python/branches/py3k/Lib/email/message.py
python/branches/py3k/Lib/zipfile.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Misc/developers.txt
Modified: python/branches/py3k/Doc/library/os.rst
==============================================================================
--- python/branches/py3k/Doc/library/os.rst (original)
+++ python/branches/py3k/Doc/library/os.rst Sun Aug 17 22:23:46 2008
@@ -1076,15 +1076,16 @@
.. function:: utime(path, times)
- Set the access and modified times of the file specified by *path*. If *times* is
- ``None``, then the file's access and modified times are set to the current time.
- Otherwise, *times* must be a 2-tuple of numbers, of the form ``(atime, mtime)``
- which is used to set the access and modified times, respectively. Whether a
- directory can be given for *path* depends on whether the operating system
- implements directories as files (for example, Windows does not). Note that the
- exact times you set here may not be returned by a subsequent :func:`stat` call,
- depending on the resolution with which your operating system records access and
- modification times; see :func:`stat`.
+ Set the access and modified times of the file specified by *path*. If *times*
+ is ``None``, then the file's access and modified times are set to the current
+ time. (The effect is similar to running the Unix program :program:`touch` on
+ the path.) Otherwise, *times* must be a 2-tuple of numbers, of the form
+ ``(atime, mtime)`` which is used to set the access and modified times,
+ respectively. Whether a directory can be given for *path* depends on whether
+ the operating system implements directories as files (for example, Windows
+ does not). Note that the exact times you set here may not be returned by a
+ subsequent :func:`stat` call, depending on the resolution with which your
+ operating system records access and modification times; see :func:`stat`.
Availability: Macintosh, Unix, Windows.
@@ -1596,6 +1597,9 @@
``-1``, status is requested for any process in the process group ``-pid`` (the
absolute value of *pid*).
+ An :exc:`OSError` is raised with the value of errno when the syscall
+ returns -1.
+
On Windows: Wait for completion of a process given by process handle *pid*, and
return a tuple containing *pid*, and its exit status shifted left by 8 bits
(shifting makes cross-platform use of the function easier). A *pid* less than or
Modified: python/branches/py3k/Doc/reference/expressions.rst
==============================================================================
--- python/branches/py3k/Doc/reference/expressions.rst (original)
+++ python/branches/py3k/Doc/reference/expressions.rst Sun Aug 17 22:23:46 2008
@@ -1266,13 +1266,13 @@
+----------------------------------------------+-------------------------------------+
| ``**`` | Exponentiation |
+----------------------------------------------+-------------------------------------+
-| ``x.attribute`` | Attribute reference |
-+----------------------------------------------+-------------------------------------+
| ``x[index]`` | Subscription |
+----------------------------------------------+-------------------------------------+
| ``x[index:index]`` | Slicing |
+----------------------------------------------+-------------------------------------+
-| ``f(arguments...)`` | Function call |
+| ``x(arguments...)`` | Call |
++----------------------------------------------|-------------------------------------+
+| ``x.attribute`` | Attribute reference |
+----------------------------------------------+-------------------------------------+
| ``(expressions...)`` | Binding, tuple display, generator |
| | expressions |
Modified: python/branches/py3k/Lib/email/message.py
==============================================================================
--- python/branches/py3k/Lib/email/message.py (original)
+++ python/branches/py3k/Lib/email/message.py Sun Aug 17 22:23:46 2008
@@ -20,18 +20,22 @@
SEMISPACE = '; '
-# Regular expression used to split header parameters. BAW: this may be too
-# simple. It isn't strictly RFC 2045 (section 5.1) compliant, but it catches
-# most headers found in the wild. We may eventually need a full fledged
-# parser eventually.
-paramre = re.compile(r'\s*;\s*')
# Regular expression that matches `special' characters in parameters, the
# existance of which force quoting of the parameter value.
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
-
# Helper functions
+def _splitparam(param):
+ # Split header parameters. BAW: this may be too simple. It isn't
+ # strictly RFC 2045 (section 5.1) compliant, but it catches most headers
+ # found in the wild. We may eventually need a full fledged parser
+ # eventually.
+ a, sep, b = param.partition(';')
+ if not sep:
+ return a.strip(), None
+ return a.strip(), b.strip()
+
def _formatparam(param, value=None, quote=True):
"""Convenience function to format and return a key=value pair.
@@ -443,7 +447,7 @@
if value is missing:
# This should have no parameters
return self.get_default_type()
- ctype = paramre.split(value)[0].lower().strip()
+ ctype = _splitparam(value)[0].lower()
# RFC 2045, section 5.2 says if its invalid, use text/plain
if ctype.count('/') != 1:
return 'text/plain'
Modified: python/branches/py3k/Lib/zipfile.py
==============================================================================
--- python/branches/py3k/Lib/zipfile.py (original)
+++ python/branches/py3k/Lib/zipfile.py Sun Aug 17 22:23:46 2008
@@ -813,9 +813,14 @@
def testzip(self):
"""Read all the files and check the CRC."""
+ chunk_size = 2 ** 20
for zinfo in self.filelist:
try:
- self.read(zinfo.filename) # Check CRC-32
+ # Read by chunks, to avoid an OverflowError or a
+ # MemoryError with very large embedded files.
+ f = self.open(zinfo.filename, "r")
+ while f.read(chunk_size): # Check CRC-32
+ pass
except BadZipfile:
return zinfo.filename
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sun Aug 17 22:23:46 2008
@@ -30,6 +30,10 @@
Library
-------
+- Issue #2676: in the email package, content-type parsing was hanging on
+ pathological input because of quadratic or exponential behaviour of a
+ regular expression.
+
- Issue #3476: binary buffered reading through the new "io" library is now
thread-safe.
Modified: python/branches/py3k/Misc/developers.txt
==============================================================================
--- python/branches/py3k/Misc/developers.txt (original)
+++ python/branches/py3k/Misc/developers.txt Sun Aug 17 22:23:46 2008
@@ -17,6 +17,9 @@
Permissions History
-------------------
+- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
+ for contributions to the Windows build.
+
- Antoine Pitrou was given SVN access on July 16 2008, by recommendation
from GvR, for general contributions to Python.
Date: Sun Aug 17 22:23:46 2008
New Revision: 65781
Log:
Merged revisions 65659,65693,65700,65702,65706-65707,65761 via svnmerge from
svn+ssh://pythondev at svn.python.org/python/trunk
........
r65659 | martin.v.loewis | 2008-08-12 15:45:21 -0500 (Tue, 12 Aug 2008) | 2 lines
Add Hirokazu Yamamoto.
........
r65693 | georg.brandl | 2008-08-15 13:35:09 -0500 (Fri, 15 Aug 2008) | 2 lines
#3558: Attribute reference binds more tightly than subscription and call.
........
r65700 | antoine.pitrou | 2008-08-15 16:03:21 -0500 (Fri, 15 Aug 2008) | 3 lines
#2676: email/message.py [Message.get_content_type]: Trivial regex hangs on pathological input
........
r65702 | gregory.p.smith | 2008-08-15 18:14:00 -0500 (Fri, 15 Aug 2008) | 2 lines
document that waitpid raises OSError
........
r65706 | benjamin.peterson | 2008-08-15 22:02:41 -0500 (Fri, 15 Aug 2008) | 1 line
fix markup
........
r65707 | benjamin.peterson | 2008-08-15 22:13:07 -0500 (Fri, 15 Aug 2008) | 1 line
note how os.utime should be used for emulating touch
........
r65761 | antoine.pitrou | 2008-08-17 08:06:29 -0500 (Sun, 17 Aug 2008) | 3 lines
fix ZipFile.testzip() to work with very large embedded files
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/library/os.rst
python/branches/py3k/Doc/reference/expressions.rst
python/branches/py3k/Lib/email/message.py
python/branches/py3k/Lib/zipfile.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Misc/developers.txt
Modified: python/branches/py3k/Doc/library/os.rst
==============================================================================
--- python/branches/py3k/Doc/library/os.rst (original)
+++ python/branches/py3k/Doc/library/os.rst Sun Aug 17 22:23:46 2008
@@ -1076,15 +1076,16 @@
.. function:: utime(path, times)
- Set the access and modified times of the file specified by *path*. If *times* is
- ``None``, then the file's access and modified times are set to the current time.
- Otherwise, *times* must be a 2-tuple of numbers, of the form ``(atime, mtime)``
- which is used to set the access and modified times, respectively. Whether a
- directory can be given for *path* depends on whether the operating system
- implements directories as files (for example, Windows does not). Note that the
- exact times you set here may not be returned by a subsequent :func:`stat` call,
- depending on the resolution with which your operating system records access and
- modification times; see :func:`stat`.
+ Set the access and modified times of the file specified by *path*. If *times*
+ is ``None``, then the file's access and modified times are set to the current
+ time. (The effect is similar to running the Unix program :program:`touch` on
+ the path.) Otherwise, *times* must be a 2-tuple of numbers, of the form
+ ``(atime, mtime)`` which is used to set the access and modified times,
+ respectively. Whether a directory can be given for *path* depends on whether
+ the operating system implements directories as files (for example, Windows
+ does not). Note that the exact times you set here may not be returned by a
+ subsequent :func:`stat` call, depending on the resolution with which your
+ operating system records access and modification times; see :func:`stat`.
Availability: Macintosh, Unix, Windows.
@@ -1596,6 +1597,9 @@
``-1``, status is requested for any process in the process group ``-pid`` (the
absolute value of *pid*).
+ An :exc:`OSError` is raised with the value of errno when the syscall
+ returns -1.
+
On Windows: Wait for completion of a process given by process handle *pid*, and
return a tuple containing *pid*, and its exit status shifted left by 8 bits
(shifting makes cross-platform use of the function easier). A *pid* less than or
Modified: python/branches/py3k/Doc/reference/expressions.rst
==============================================================================
--- python/branches/py3k/Doc/reference/expressions.rst (original)
+++ python/branches/py3k/Doc/reference/expressions.rst Sun Aug 17 22:23:46 2008
@@ -1266,13 +1266,13 @@
+----------------------------------------------+-------------------------------------+
| ``**`` | Exponentiation |
+----------------------------------------------+-------------------------------------+
-| ``x.attribute`` | Attribute reference |
-+----------------------------------------------+-------------------------------------+
| ``x[index]`` | Subscription |
+----------------------------------------------+-------------------------------------+
| ``x[index:index]`` | Slicing |
+----------------------------------------------+-------------------------------------+
-| ``f(arguments...)`` | Function call |
+| ``x(arguments...)`` | Call |
++----------------------------------------------|-------------------------------------+
+| ``x.attribute`` | Attribute reference |
+----------------------------------------------+-------------------------------------+
| ``(expressions...)`` | Binding, tuple display, generator |
| | expressions |
Modified: python/branches/py3k/Lib/email/message.py
==============================================================================
--- python/branches/py3k/Lib/email/message.py (original)
+++ python/branches/py3k/Lib/email/message.py Sun Aug 17 22:23:46 2008
@@ -20,18 +20,22 @@
SEMISPACE = '; '
-# Regular expression used to split header parameters. BAW: this may be too
-# simple. It isn't strictly RFC 2045 (section 5.1) compliant, but it catches
-# most headers found in the wild. We may eventually need a full fledged
-# parser eventually.
-paramre = re.compile(r'\s*;\s*')
# Regular expression that matches `special' characters in parameters, the
# existance of which force quoting of the parameter value.
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
-
# Helper functions
+def _splitparam(param):
+ # Split header parameters. BAW: this may be too simple. It isn't
+ # strictly RFC 2045 (section 5.1) compliant, but it catches most headers
+ # found in the wild. We may eventually need a full fledged parser
+ # eventually.
+ a, sep, b = param.partition(';')
+ if not sep:
+ return a.strip(), None
+ return a.strip(), b.strip()
+
def _formatparam(param, value=None, quote=True):
"""Convenience function to format and return a key=value pair.
@@ -443,7 +447,7 @@
if value is missing:
# This should have no parameters
return self.get_default_type()
- ctype = paramre.split(value)[0].lower().strip()
+ ctype = _splitparam(value)[0].lower()
# RFC 2045, section 5.2 says if its invalid, use text/plain
if ctype.count('/') != 1:
return 'text/plain'
Modified: python/branches/py3k/Lib/zipfile.py
==============================================================================
--- python/branches/py3k/Lib/zipfile.py (original)
+++ python/branches/py3k/Lib/zipfile.py Sun Aug 17 22:23:46 2008
@@ -813,9 +813,14 @@
def testzip(self):
"""Read all the files and check the CRC."""
+ chunk_size = 2 ** 20
for zinfo in self.filelist:
try:
- self.read(zinfo.filename) # Check CRC-32
+ # Read by chunks, to avoid an OverflowError or a
+ # MemoryError with very large embedded files.
+ f = self.open(zinfo.filename, "r")
+ while f.read(chunk_size): # Check CRC-32
+ pass
except BadZipfile:
return zinfo.filename
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sun Aug 17 22:23:46 2008
@@ -30,6 +30,10 @@
Library
-------
+- Issue #2676: in the email package, content-type parsing was hanging on
+ pathological input because of quadratic or exponential behaviour of a
+ regular expression.
+
- Issue #3476: binary buffered reading through the new "io" library is now
thread-safe.
Modified: python/branches/py3k/Misc/developers.txt
==============================================================================
--- python/branches/py3k/Misc/developers.txt (original)
+++ python/branches/py3k/Misc/developers.txt Sun Aug 17 22:23:46 2008
@@ -17,6 +17,9 @@
Permissions History
-------------------
+- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
+ for contributions to the Windows build.
+
- Antoine Pitrou was given SVN access on July 16 2008, by recommendation
from GvR, for general contributions to Python.