Branch merge
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 8296a4d..73b3901 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -30,7 +30,7 @@
:class:`tzinfo` objects capture information about the offset from UTC time, the
time zone name, and whether Daylight Saving Time is in effect. Note that only
one concrete :class:`tzinfo` class, the :class:`timezone` class, is supplied by the
-:mod:`datetime` module. The :class:`timezone` class can reprsent simple
+:mod:`datetime` module. The :class:`timezone` class can represent simple
timezones with fixed offset from UTC such as UTC itself or North American EST and
EDT timezones. Supporting timezones at whatever level of detail is
required is up to the application. The rules for time adjustment across the
diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst
index c8634ba..2ab632f 100644
--- a/Doc/library/heapq.rst
+++ b/Doc/library/heapq.rst
@@ -191,8 +191,8 @@
def get_top_priority():
while True:
priority, count, task = heappop(pq)
- del task_finder[task]
if count is not INVALID:
+ del task_finder[task]
return task
def delete_task(task):
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 3040411..2b10e6e 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -169,6 +169,7 @@
The end-point value ``b`` may or may not be included in the range
depending on floating-point rounding in the equation ``a + (b-a) * random()``.
+
.. function:: triangular(low, high, mode)
Return a random floating point number *N* such that ``low <= N <= high`` and
@@ -197,6 +198,12 @@
Gamma distribution. (*Not* the gamma function!) Conditions on the
parameters are ``alpha > 0`` and ``beta > 0``.
+ The probability distribution function is::
+
+ x ** (alpha - 1) * math.exp(-x / beta)
+ pdf(x) = --------------------------------------
+ math.gamma(alpha) * beta ** alpha
+
.. function:: gauss(mu, sigma)
diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index be5990c..5e4a1cb 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -399,12 +399,19 @@
otherwise.
-.. function:: skip_unless_symlink()
+.. decorator:: skip_unless_symlink()
A decorator for running tests that require support for symbolic links.
-.. function:: run_with_locale(catstr, *locales)
+.. decorator:: anticipate_failure(condition)
+
+ A decorator to conditionally mark tests with
+ :func:`unittest.expectedFailure`. Any use of this decorator should
+ have an associated comment identifying the relevant tracker issue.
+
+
+.. decorator:: run_with_locale(catstr, *locales)
A decorator for running a function in a different locale, correctly
resetting it after it has finished. *catstr* is the locale category as
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 03af378..015564b 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -57,6 +57,7 @@
"get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
"TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
"import_fresh_module", "requires_zlib", "PIPE_MAX_SIZE", "failfast",
+ "anticipate_failure"
]
class Error(Exception):
@@ -127,6 +128,17 @@
return saved
+def anticipate_failure(condition):
+ """Decorator to mark a test that is known to be broken in some cases
+
+ Any use of this decorator should have a comment identifying the
+ associated tracker issue.
+ """
+ if condition:
+ return unittest.expectedFailure
+ return lambda f: f
+
+
def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
"""Imports and returns a module, deliberately bypassing the sys.modules cache
and importing a fresh copy of the module. Once the import is complete,
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 83351b9..f47e61e 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -167,6 +167,9 @@
raise TypeError("test_func must be a callable function")
try:
test_func()
+ except unittest._ExpectedFailure:
+ # We deliberately ignore expected failures
+ pass
except BaseException as e:
self.queue.put(e)
finally:
@@ -2090,6 +2093,8 @@
def _testFDPassCMSG_LEN(self):
self.createAndSendFDs(1)
+ # Issue #12958: The following test has problems on Mac OS X
+ @support.anticipate_failure(sys.platform == "darwin")
@requireAttrs(socket, "CMSG_SPACE")
def testFDPassSeparate(self):
# Pass two FDs in two separate arrays. Arrays may be combined
@@ -2099,6 +2104,7 @@
maxcmsgs=2)
@testFDPassSeparate.client_skip
+ @support.anticipate_failure(sys.platform == "darwin")
def _testFDPassSeparate(self):
fd0, fd1 = self.newFDs(2)
self.assertEqual(
@@ -2110,6 +2116,8 @@
array.array("i", [fd1]))]),
len(MSG))
+ # Issue #12958: The following test has problems on Mac OS X
+ @support.anticipate_failure(sys.platform == "darwin")
@requireAttrs(socket, "CMSG_SPACE")
def testFDPassSeparateMinSpace(self):
# Pass two FDs in two separate arrays, receiving them into the
@@ -2121,6 +2129,7 @@
maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC)
@testFDPassSeparateMinSpace.client_skip
+ @support.anticipate_failure(sys.platform == "darwin")
def _testFDPassSeparateMinSpace(self):
fd0, fd1 = self.newFDs(2)
self.assertEqual(
@@ -3024,9 +3033,12 @@
self.assertNotIsInstance(cm.exception, socket.timeout)
self.assertEqual(cm.exception.errno, errno.EINTR)
+ # Issue #12958: The following tests have problems on Mac OS X
+ @support.anticipate_failure(sys.platform == "darwin")
def testInterruptedSendTimeout(self):
self.checkInterruptedSend(self.serv_conn.send, b"a"*512)
+ @support.anticipate_failure(sys.platform == "darwin")
def testInterruptedSendtoTimeout(self):
# Passing an actual address here as Python's wrapper for
# sendto() doesn't allow passing a zero-length one; POSIX
@@ -3035,6 +3047,7 @@
self.checkInterruptedSend(self.serv_conn.sendto, b"a"*512,
self.serv_addr)
+ @support.anticipate_failure(sys.platform == "darwin")
@requireAttrs(socket.socket, "sendmsg")
def testInterruptedSendmsgTimeout(self):
self.checkInterruptedSend(self.serv_conn.sendmsg, [b"a"*512])
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 355e01f..2fc509d 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -375,6 +375,8 @@
#endif
#endif
+/* A helper used by a number of POSIX-only functions */
+#ifndef MS_WINDOWS
static int
_parse_off_t(PyObject* arg, void* addr)
{
@@ -387,6 +389,7 @@
return 0;
return 1;
}
+#endif
#if defined _MSC_VER && _MSC_VER >= 1400
/* Microsoft CRT in VS2005 and higher will verify that a filehandle is