Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cd6a95

Browse files
committed
Merged revisions 65659,65693,65700,65702,65706-65707,65761 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent 9209138 commit 4cd6a95

6 files changed

Lines changed: 40 additions & 20 deletions

File tree

Doc/library/os.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,15 +1076,16 @@ Files and Directories
10761076

10771077
.. function:: utime(path, times)
10781078

1079-
Set the access and modified times of the file specified by *path*. If *times* is
1080-
``None``, then the file's access and modified times are set to the current time.
1081-
Otherwise, *times* must be a 2-tuple of numbers, of the form ``(atime, mtime)``
1082-
which is used to set the access and modified times, respectively. Whether a
1083-
directory can be given for *path* depends on whether the operating system
1084-
implements directories as files (for example, Windows does not). Note that the
1085-
exact times you set here may not be returned by a subsequent :func:`stat` call,
1086-
depending on the resolution with which your operating system records access and
1087-
modification times; see :func:`stat`.
1079+
Set the access and modified times of the file specified by *path*. If *times*
1080+
is ``None``, then the file's access and modified times are set to the current
1081+
time. (The effect is similar to running the Unix program :program:`touch` on
1082+
the path.) Otherwise, *times* must be a 2-tuple of numbers, of the form
1083+
``(atime, mtime)`` which is used to set the access and modified times,
1084+
respectively. Whether a directory can be given for *path* depends on whether
1085+
the operating system implements directories as files (for example, Windows
1086+
does not). Note that the exact times you set here may not be returned by a
1087+
subsequent :func:`stat` call, depending on the resolution with which your
1088+
operating system records access and modification times; see :func:`stat`.
10881089

10891090
Availability: Macintosh, Unix, Windows.
10901091

@@ -1596,6 +1597,9 @@ written in Python, such as a mail server's external command delivery program.
15961597
``-1``, status is requested for any process in the process group ``-pid`` (the
15971598
absolute value of *pid*).
15981599

1600+
An :exc:`OSError` is raised with the value of errno when the syscall
1601+
returns -1.
1602+
15991603
On Windows: Wait for completion of a process given by process handle *pid*, and
16001604
return a tuple containing *pid*, and its exit status shifted left by 8 bits
16011605
(shifting makes cross-platform use of the function easier). A *pid* less than or

Doc/reference/expressions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,13 +1266,13 @@ groups from right to left).
12661266
+----------------------------------------------+-------------------------------------+
12671267
| ``**`` | Exponentiation |
12681268
+----------------------------------------------+-------------------------------------+
1269-
| ``x.attribute`` | Attribute reference |
1270-
+----------------------------------------------+-------------------------------------+
12711269
| ``x[index]`` | Subscription |
12721270
+----------------------------------------------+-------------------------------------+
12731271
| ``x[index:index]`` | Slicing |
12741272
+----------------------------------------------+-------------------------------------+
1275-
| ``f(arguments...)`` | Function call |
1273+
| ``x(arguments...)`` | Call |
1274+
+----------------------------------------------|-------------------------------------+
1275+
| ``x.attribute`` | Attribute reference |
12761276
+----------------------------------------------+-------------------------------------+
12771277
| ``(expressions...)`` | Binding, tuple display, generator |
12781278
| | expressions |

Lib/email/message.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@
2020

2121
SEMISPACE = '; '
2222

23-
# Regular expression used to split header parameters. BAW: this may be too
24-
# simple. It isn't strictly RFC 2045 (section 5.1) compliant, but it catches
25-
# most headers found in the wild. We may eventually need a full fledged
26-
# parser eventually.
27-
paramre = re.compile(r'\s*;\s*')
2823
# Regular expression that matches `special' characters in parameters, the
2924
# existance of which force quoting of the parameter value.
3025
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
3126

3227

33-
3428
# Helper functions
29+
def _splitparam(param):
30+
# Split header parameters. BAW: this may be too simple. It isn't
31+
# strictly RFC 2045 (section 5.1) compliant, but it catches most headers
32+
# found in the wild. We may eventually need a full fledged parser
33+
# eventually.
34+
a, sep, b = param.partition(';')
35+
if not sep:
36+
return a.strip(), None
37+
return a.strip(), b.strip()
38+
3539
def _formatparam(param, value=None, quote=True):
3640
"""Convenience function to format and return a key=value pair.
3741
@@ -443,7 +447,7 @@ def get_content_type(self):
443447
if value is missing:
444448
# This should have no parameters
445449
return self.get_default_type()
446-
ctype = paramre.split(value)[0].lower().strip()
450+
ctype = _splitparam(value)[0].lower()
447451
# RFC 2045, section 5.2 says if its invalid, use text/plain
448452
if ctype.count('/') != 1:
449453
return 'text/plain'

Lib/zipfile.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,14 @@ def printdir(self, file=None):
813813

814814
def testzip(self):
815815
"""Read all the files and check the CRC."""
816+
chunk_size = 2 ** 20
816817
for zinfo in self.filelist:
817818
try:
818-
self.read(zinfo.filename) # Check CRC-32
819+
# Read by chunks, to avoid an OverflowError or a
820+
# MemoryError with very large embedded files.
821+
f = self.open(zinfo.filename, "r")
822+
while f.read(chunk_size): # Check CRC-32
823+
pass
819824
except BadZipfile:
820825
return zinfo.filename
821826

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Core and Builtins
3030
Library
3131
-------
3232

33+
- Issue #2676: in the email package, content-type parsing was hanging on
34+
pathological input because of quadratic or exponential behaviour of a
35+
regular expression.
36+
3337
- Issue #3476: binary buffered reading through the new "io" library is now
3438
thread-safe.
3539

Misc/developers.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
1717
Permissions History
1818
-------------------
1919

20+
- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
21+
for contributions to the Windows build.
22+
2023
- Antoine Pitrou was given SVN access on July 16 2008, by recommendation
2124
from GvR, for general contributions to Python.
2225

0 commit comments

Comments
 (0)