summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2013-11-24 14:05:57 -0800
committerLarry Hastings <larry@hastings.org>2013-11-24 14:05:57 -0800
commitfb8b21546f0333e9d5ce37924234077471baafb0 (patch)
tree77d66ba8d54f68b5f4f44c56778f720b476baf87 /Lib
parentf3b4448ef4db2f642dad864f3cd9b4b874b106c5 (diff)
parent6421a893e42c136a02b64369c8ffe72dbf857548 (diff)
downloadcpython-fb8b21546f0333e9d5ce37924234077471baafb0.tar.gz
Merged 3.4.0b1 release head back into trunk.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_strptime.py2
-rw-r--r--Lib/asyncio/windows_events.py11
-rw-r--r--Lib/decimal.py1
-rw-r--r--Lib/fileinput.py2
-rw-r--r--Lib/test/test_codecs.py4
-rw-r--r--Lib/test/test_decimal.py1
-rw-r--r--Lib/test/test_fileinput.py8
-rw-r--r--Lib/test/test_gdb.py1
-rw-r--r--Lib/test/test_io.py3
-rw-r--r--Lib/test/test_strptime.py4
-rw-r--r--Lib/test/test_time.py4
-rw-r--r--Lib/test/test_zipfile.py29
12 files changed, 54 insertions, 16 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index 3884a670b8..d101c6de05 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -329,7 +329,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
(bad_directive, format)) from None
# IndexError only occurs when the format string is "%"
except IndexError:
- raise ValueError("stray %% in format '%s'" % format)
+ raise ValueError("stray %% in format '%s'" % format) from None
_regex_cache[format] = format_regex
found = format_regex.match(data_string)
if not found:
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 64fe38617d..b2ed2415e4 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -327,14 +327,21 @@ class IocpProactor:
handle, self._iocp, ov.address, ms)
f = _WaitHandleFuture(wh, loop=self._loop)
- def finish(timed_out, _, ov):
+ def finish(trans, key, ov):
if not f.cancelled():
try:
_overlapped.UnregisterWait(wh)
except OSError as e:
if e.winerror != _overlapped.ERROR_IO_PENDING:
raise
- return not timed_out
+ # Note that this second wait means that we should only use
+ # this with handles types where a successful wait has no
+ # effect. So events or processes are all right, but locks
+ # or semaphores are not. Also note if the handle is
+ # signalled and then quickly reset, then we may return
+ # False even though we have not timed out.
+ return (_winapi.WaitForSingleObject(handle, 0) ==
+ _winapi.WAIT_OBJECT_0)
self._cache[ov.address] = (f, ov, None, finish)
return f
diff --git a/Lib/decimal.py b/Lib/decimal.py
index fc95ae9576..7bc1c943b5 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -140,6 +140,7 @@ __all__ = [
__version__ = '1.70' # Highest version of the spec this complies with
# See http://speleotrove.com/decimal/
+__libmpdec_version__ = "2.4.0" # compatible libmpdec version
import copy as _copy
import math as _math
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index 11ba82df87..de2951844a 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -224,7 +224,7 @@ class FileInput:
"'r', 'rU', 'U' and 'rb'")
if 'U' in mode:
import warnings
- warnings.warn("Use of 'U' mode is deprecated",
+ warnings.warn("'U' mode is deprecated",
DeprecationWarning, 2)
self._mode = mode
if openhook:
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 639ce9fd85..f6823805fe 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -602,7 +602,9 @@ class UTF16Test(ReadTest, unittest.TestCase):
self.addCleanup(support.unlink, support.TESTFN)
with open(support.TESTFN, 'wb') as fp:
fp.write(s)
- with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
+ with support.check_warnings(('', DeprecationWarning)):
+ reader = codecs.open(support.TESTFN, 'U', encoding=self.encoding)
+ with reader:
self.assertEqual(reader.read(), s1)
class UTF16LETest(ReadTest, unittest.TestCase):
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index ac8a7bebc1..6378ef300e 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -4149,6 +4149,7 @@ class CheckAttributes(unittest.TestCase):
self.assertTrue(P.HAVE_THREADS is True or P.HAVE_THREADS is False)
self.assertEqual(C.__version__, P.__version__)
+ self.assertEqual(C.__libmpdec_version__, P.__libmpdec_version__)
x = dir(C)
y = [s for s in dir(P) if '__' in s or not s.startswith('_')]
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index c5e57d4715..db6082cb12 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -22,7 +22,7 @@ except ImportError:
from io import StringIO
from fileinput import FileInput, hook_encoded
-from test.support import verbose, TESTFN, run_unittest
+from test.support import verbose, TESTFN, run_unittest, check_warnings
from test.support import unlink as safe_unlink
@@ -224,8 +224,10 @@ class FileInputTests(unittest.TestCase):
try:
# try opening in universal newline mode
t1 = writeTmp(1, [b"A\nB\r\nC\rD"], mode="wb")
- fi = FileInput(files=t1, mode="U")
- lines = list(fi)
+ with check_warnings(('', DeprecationWarning)):
+ fi = FileInput(files=t1, mode="U")
+ with check_warnings(('', DeprecationWarning)):
+ lines = list(fi)
self.assertEqual(lines, ["A\n", "B\n", "C\n", "D"])
finally:
remove_tempfiles(t1)
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index b543889d86..cc2900fc7a 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -170,6 +170,7 @@ class DebuggerTests(unittest.TestCase):
'Do you need "set solib-search-path" or '
'"set sysroot"?',
'warning: Source file is more recent than executable.',
+ 'Missing separate debuginfo for ',
)
for line in errlines:
if not line.startswith(ignore_patterns):
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index c1ea6f245f..57f3659667 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2777,7 +2777,8 @@ class MiscIOTest(unittest.TestCase):
self.assertEqual(f.mode, "wb")
f.close()
- f = self.open(support.TESTFN, "U")
+ with support.check_warnings(('', DeprecationWarning)):
+ f = self.open(support.TESTFN, "U")
self.assertEqual(f.name, support.TESTFN)
self.assertEqual(f.buffer.name, support.TESTFN)
self.assertEqual(f.buffer.raw.name, support.TESTFN)
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 68e6a67636..d5bc39d0dd 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -223,6 +223,10 @@ class StrptimeTests(unittest.TestCase):
with self.assertRaises(ValueError) as e:
_strptime._strptime_time('', '%D')
self.assertIs(e.exception.__suppress_context__, True)
+ # additional check for IndexError branch (issue #19545)
+ with self.assertRaises(ValueError) as e:
+ _strptime._strptime_time('19', '%Y %')
+ self.assertIs(e.exception.__suppress_context__, True)
def test_unconverteddata(self):
# Check ValueError is raised when there is unconverted data
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index f3643b63ff..44bcb943cb 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -198,6 +198,10 @@ class TimeTestCase(unittest.TestCase):
with self.assertRaises(ValueError) as e:
time.strptime('', '%D')
self.assertIs(e.exception.__suppress_context__, True)
+ # additional check for IndexError branch (issue #19545)
+ with self.assertRaises(ValueError) as e:
+ time.strptime('19', '%Y %')
+ self.assertIs(e.exception.__suppress_context__, True)
def test_asctime(self):
time.asctime(time.gmtime(self.t))
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index c15ea9fa26..49eccbb1d7 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -14,7 +14,7 @@ from random import randint, random, getrandbits
from test.support import (TESTFN, findfile, unlink,
requires_zlib, requires_bz2, requires_lzma,
- captured_stdout)
+ captured_stdout, check_warnings)
TESTFN2 = TESTFN + "2"
TESTFNDIR = TESTFN + "d"
@@ -35,6 +35,10 @@ def get_files(test):
yield f
test.assertFalse(f.closed)
+def openU(zipfp, fn):
+ with check_warnings(('', DeprecationWarning)):
+ return zipfp.open(fn, 'rU')
+
class AbstractTestsWithSourceFile:
@classmethod
def setUpClass(cls):
@@ -875,6 +879,17 @@ class OtherTests(unittest.TestCase):
data += zipfp.read(info)
self.assertIn(data, {b"foobar", b"barfoo"})
+ def test_universal_deprecation(self):
+ f = io.BytesIO()
+ with zipfile.ZipFile(f, "w") as zipfp:
+ zipfp.writestr('spam.txt', b'ababagalamaga')
+
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for mode in 'U', 'rU':
+ with self.assertWarns(DeprecationWarning):
+ zipopen = zipfp.open('spam.txt', mode)
+ zipopen.close()
+
def test_universal_readaheads(self):
f = io.BytesIO()
@@ -884,7 +899,7 @@ class OtherTests(unittest.TestCase):
data2 = b''
with zipfile.ZipFile(f, 'r') as zipfp, \
- zipfp.open(TESTFN, 'rU') as zipopen:
+ openU(zipfp, TESTFN) as zipopen:
for line in zipopen:
data2 += line
@@ -1613,7 +1628,7 @@ class AbstractUniversalNewlineTests:
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as fp:
+ with openU(zipfp, fn) as fp:
zipdata = fp.read()
self.assertEqual(self.arcdata[sep], zipdata)
@@ -1627,7 +1642,7 @@ class AbstractUniversalNewlineTests:
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as zipopen:
+ with openU(zipfp, fn) as zipopen:
data = b''
while True:
read = zipopen.readline()
@@ -1652,7 +1667,7 @@ class AbstractUniversalNewlineTests:
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as zipopen:
+ with openU(zipfp, fn) as zipopen:
for line in self.line_gen:
linedata = zipopen.readline()
self.assertEqual(linedata, line + b'\n')
@@ -1667,7 +1682,7 @@ class AbstractUniversalNewlineTests:
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as fp:
+ with openU(zipfp, fn) as fp:
ziplines = fp.readlines()
for line, zipline in zip(self.line_gen, ziplines):
self.assertEqual(zipline, line + b'\n')
@@ -1682,7 +1697,7 @@ class AbstractUniversalNewlineTests:
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as fp:
+ with openU(zipfp, fn) as fp:
for line, zipline in zip(self.line_gen, fp):
self.assertEqual(zipline, line + b'\n')