Skip to content

Commit 87f5945

Browse files
Merge branch 'master' into sqlite-no-hasattr
2 parents 4585ae8 + 1426daa commit 87f5945

118 files changed

Lines changed: 1691 additions & 876 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ matrix:
4040
# compiler here and the other to run the coverage build. Clang is preferred
4141
# in this instance for its better error messages.
4242
env: TESTING=cpython
43+
addons:
44+
apt:
45+
packages:
46+
- xvfb
4347
- os: linux
4448
language: python
4549
# Build the docs against a stable version of Python so code bugs don't hold up doc-related PRs.
@@ -70,6 +74,7 @@ matrix:
7074
apt:
7175
packages:
7276
- lcov
77+
- xvfb
7378
before_script:
7479
- ./configure
7580
- make coverage -s -j4
@@ -79,7 +84,7 @@ matrix:
7984
- ./venv/bin/python -m test.pythoninfo
8085
script:
8186
# Skip tests that re-run the entire test suite.
82-
- ./venv/bin/python -m coverage run --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures
87+
- xvfb-run ./venv/bin/python -m coverage run --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures
8388
after_script: # Probably should be after_success once test suite updated to run under coverage.py.
8489
# Make the `coverage` command available to Codecov w/ a version of Python that can parse all source files.
8590
- source ./venv/bin/activate
@@ -150,7 +155,7 @@ script:
150155
# Check that all symbols exported by libpython start with "Py" or "_Py"
151156
- make smelly
152157
# `-r -w` implicitly provided through `make buildbottest`.
153-
- make buildbottest TESTOPTS="-j4 -uall,-cpu"
158+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then XVFB_RUN=xvfb-run; fi; $XVFB_RUN make buildbottest TESTOPTS="-j4 -uall,-cpu"
154159

155160
notifications:
156161
email: false
File renamed without changes.

Doc/howto/functional.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,23 +273,24 @@ dictionary's keys::
273273

274274
>>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
275275
... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
276-
>>> for key in m: #doctest: +SKIP
276+
>>> for key in m:
277277
... print(key, m[key])
278-
Mar 3
278+
Jan 1
279279
Feb 2
280-
Aug 8
281-
Sep 9
280+
Mar 3
282281
Apr 4
282+
May 5
283283
Jun 6
284284
Jul 7
285-
Jan 1
286-
May 5
285+
Aug 8
286+
Sep 9
287+
Oct 10
287288
Nov 11
288289
Dec 12
289-
Oct 10
290290

291-
Note that the order is essentially random, because it's based on the hash
292-
ordering of the objects in the dictionary.
291+
Note that starting with Python 3.7, dictionary iteration order is guaranteed
292+
to be the same as the insertion order. In earlier versions, the behaviour was
293+
unspecified and could vary between implementations.
293294

294295
Applying :func:`iter` to a dictionary always loops over the keys, but
295296
dictionaries have methods that return other iterators. If you want to iterate
@@ -301,8 +302,8 @@ The :func:`dict` constructor can accept an iterator that returns a finite stream
301302
of ``(key, value)`` tuples:
302303

303304
>>> L = [('Italy', 'Rome'), ('France', 'Paris'), ('US', 'Washington DC')]
304-
>>> dict(iter(L)) #doctest: +SKIP
305-
{'Italy': 'Rome', 'US': 'Washington DC', 'France': 'Paris'}
305+
>>> dict(iter(L))
306+
{'Italy': 'Rome', 'France': 'Paris', 'US': 'Washington DC'}
306307

307308
Files also support iteration by calling the :meth:`~io.TextIOBase.readline`
308309
method until there are no more lines in the file. This means you can read each

Doc/library/contextlib.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,22 @@ Functions and classes provided:
152152

153153
.. function:: nullcontext(enter_result=None)
154154

155-
Return a context manager that returns enter_result from ``__enter__``, but
155+
Return a context manager that returns *enter_result* from ``__enter__``, but
156156
otherwise does nothing. It is intended to be used as a stand-in for an
157157
optional context manager, for example::
158158

159+
def myfunction(arg, ignore_exceptions=False):
160+
if ignore_exceptions:
161+
# Use suppress to ignore all exceptions.
162+
cm = contextlib.suppress(Exception)
163+
else:
164+
# Do not ignore any exceptions, cm has no effect.
165+
cm = contextlib.nullcontext()
166+
with cm:
167+
# Do something
168+
169+
An example using *enter_result*::
170+
159171
def process_file(file_or_path):
160172
if isinstance(file_or_path, str):
161173
# If string, open file

Doc/library/ctypes.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,22 @@ As we can easily check, our array is sorted now::
10251025
1 5 7 33 99
10261026
>>>
10271027

1028+
The function factories can be used as decorator factories, so we may as well
1029+
write::
1030+
1031+
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
1032+
... def py_cmp_func(a, b):
1033+
... print("py_cmp_func", a[0], b[0])
1034+
... return a[0] - b[0]
1035+
...
1036+
>>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)
1037+
py_cmp_func 5 1
1038+
py_cmp_func 33 99
1039+
py_cmp_func 7 33
1040+
py_cmp_func 1 7
1041+
py_cmp_func 5 7
1042+
>>>
1043+
10281044
.. note::
10291045

10301046
Make sure you keep references to :func:`CFUNCTYPE` objects as long as they
@@ -1577,7 +1593,9 @@ Foreign functions can also be created by instantiating function prototypes.
15771593
Function prototypes are similar to function prototypes in C; they describe a
15781594
function (return type, argument types, calling convention) without defining an
15791595
implementation. The factory functions must be called with the desired result
1580-
type and the argument types of the function.
1596+
type and the argument types of the function, and can be used as decorator
1597+
factories, and as such, be applied to functions through the ``@wrapper`` syntax.
1598+
See :ref:`ctypes-callback-functions` for examples.
15811599

15821600

15831601
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)

Doc/library/dataclasses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ Mutable default values
532532
class C:
533533
x = []
534534
def add(self, element):
535-
self.x += element
535+
self.x.append(element)
536536

537537
o1 = C()
538538
o2 = C()

Doc/library/email.parser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ in the top-level :mod:`email` package namespace.
246246
Removed the *strict* argument. Added the *policy* keyword.
247247

248248

249-
.. function:: message_from_binary_file(fp, _class=None, *,
249+
.. function:: message_from_binary_file(fp, _class=None, *, \
250250
policy=policy.compat32)
251251

252252
Return a message object structure tree from an open binary :term:`file

Doc/library/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ The following exceptions are the exceptions that are usually raised.
525525

526526
.. exception:: ValueError
527527

528-
Raised when a built-in operation or function receives an argument that has the
528+
Raised when an operation or function receives an argument that has the
529529
right type but an inappropriate value, and the situation is not described by a
530530
more precise exception such as :exc:`IndexError`.
531531

Doc/library/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ are always available. They are listed here in alphabetical order.
241241
interactive statement (in the latter case, expression statements that
242242
evaluate to something other than ``None`` will be printed).
243243

244-
The optional arguments *flags* and *dont_inherit* control which future
245-
statements (see :pep:`236`) affect the compilation of *source*. If neither
244+
The optional arguments *flags* and *dont_inherit* control which :ref:`future
245+
statements <future>` affect the compilation of *source*. If neither
246246
is present (or both are zero) the code is compiled with those future
247247
statements that are in effect in the code that is calling :func:`compile`. If the
248248
*flags* argument is given and *dont_inherit* is not (or is zero) then the

Doc/library/platform.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Mac OS Platform
243243
Unix Platforms
244244
--------------
245245

246-
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
246+
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=16384)
247247

248248
Tries to determine the libc version against which the file executable (defaults
249249
to the Python interpreter) is linked. Returns a tuple of strings ``(lib,

0 commit comments

Comments
 (0)