Skip to content

Commit 82a18bb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bpo-30555-windowsconsoleio-fd-redirection
2 parents 0644634 + 29adc13 commit 82a18bb

56 files changed

Lines changed: 847 additions & 339 deletions

Some content is hidden

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

.github/appveyor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
version: 3.7.0a0.{build}
22
clone_depth: 5
3+
branches:
4+
only:
5+
- master
6+
- /\d\.\d/
7+
- buildbot-custom
38
build_script:
49
- cmd: PCbuild\build.bat -e
510
test_script:

.travis.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ matrix:
2828
compiler: clang
2929
# Testing under macOS is optional until testing stability has been demonstrated.
3030
env: OPTIONAL=true
31+
before_install:
32+
- brew install openssl xz
33+
- export CPPFLAGS="-I$(brew --prefix openssl)/include"
34+
- export LDFLAGS="-L$(brew --prefix openssl)/lib"
3135
- os: linux
3236
language: python
3337
# Build the docs against a stable version of Python so code bugs don't hold up doc-related PRs.
@@ -46,7 +50,7 @@ matrix:
4650
env: OPTIONAL=true
4751
before_script:
4852
- |
49-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.(rst|yml)$)|(^Doc)|(^Misc)/'
53+
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
5054
then
5155
echo "Only docs were updated, stopping build process."
5256
exit
@@ -58,16 +62,16 @@ matrix:
5862
./venv/bin/python -m pip install -U coverage
5963
script:
6064
# Skip tests that re-run the entire test suite.
61-
- ./venv/bin/python -m coverage run --pylib -m test -uall -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn
65+
- ./venv/bin/python -m coverage run --pylib -m test -uall,-cpu,-tzdata -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn
6266
after_script: # Probably should be after_success once test suite updated to run under coverage.py.
6367
# Make the `coverage` command available to Codecov w/ a version of Python that can parse all source files.
6468
- source ./venv/bin/activate
6569
- bash <(curl -s https://codecov.io/bash)
6670

67-
# Travis provides only 2 cores, so don't overdue the parallelism and waste memory.
71+
# Travis provides only 2 cores, so don't overdo the parallelism and waste memory.
6872
before_script:
6973
- |
70-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.(rst|yml)$)|(^Doc)|(^Misc)/'
74+
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
7175
then
7276
echo "Only docs were updated, stopping build process."
7377
exit
@@ -77,7 +81,7 @@ before_script:
7781
7882
script:
7983
# `-r -w` implicitly provided through `make buildbottest`.
80-
- make buildbottest TESTOPTS="-j4"
84+
- make buildbottest TESTOPTS="-j4 -uall,-cpu,-tzdata"
8185

8286
notifications:
8387
email: false

Doc/howto/clinic.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,8 @@ Let's start with defining some terminology:
14071407

14081408
``two-pass``
14091409
A buffer like ``buffer``. However, a two-pass buffer can only
1410-
be written once, and it prints out all text sent to it during
1411-
all of processing, even from Clinic blocks *after* the
1410+
be dumped once, and it prints out all text sent to it during
1411+
all processing, even from Clinic blocks *after* the dumping point.
14121412

14131413
``suppress``
14141414
The text is suppressed—thrown away.
@@ -1471,7 +1471,7 @@ preset configurations, as follows:
14711471
The default filename is ``"{dirname}/clinic/{basename}.h"``.
14721472

14731473
``buffer``
1474-
Save up all most of the output from Clinic, to be written into
1474+
Save up most of the output from Clinic, to be written into
14751475
your file near the end. For Python files implementing modules
14761476
or builtin types, it's recommended that you dump the buffer
14771477
just above the static structures for your module or

Doc/howto/descriptor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ this::
282282
. . .
283283
def __get__(self, obj, objtype=None):
284284
"Simulate func_descr_get() in Objects/funcobject.c"
285-
return types.MethodType(self, obj, objtype)
285+
return types.MethodType(self, obj)
286286

287287
Running the interpreter shows how the function descriptor works in practice::
288288

Doc/library/calendar.rst

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ it's the base calendar for all computations.
147147
This class can be used to generate HTML calendars.
148148

149149

150-
:class:`HTMLCalendar` instances have the following methods:
150+
:class:`!HTMLCalendar` instances have the following methods:
151151

152152
.. method:: formatmonth(theyear, themonth, withyear=True)
153153

@@ -171,6 +171,85 @@ it's the base calendar for all computations.
171171
output (defaulting to the system default encoding).
172172

173173

174+
:class:`!HTMLCalendar` has the following attributes you can override to
175+
customize the CSS classes used by the calendar:
176+
177+
.. attribute:: cssclasses
178+
179+
A list of CSS classes used for each weekday. The default class list is::
180+
181+
cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
182+
183+
more styles can be added for each day::
184+
185+
cssclasses = ["mon text-bold", "tue", "wed", "thu", "fri", "sat", "sun red"]
186+
187+
Note that the length of this list must be seven items.
188+
189+
190+
.. attribute:: cssclass_noday
191+
192+
The CSS class for a weekday occurring in the previous or coming month.
193+
194+
.. versionadded:: 3.7
195+
196+
197+
.. attribute:: cssclasses_weekday_head
198+
199+
A list of CSS classes used for weekday names in the header row.
200+
The default is the same as :attr:`cssclasses`.
201+
202+
.. versionadded:: 3.7
203+
204+
205+
.. attribute:: cssclass_month_head
206+
207+
The month's head CSS class (used by :meth:`formatmonthname`).
208+
The default value is ``"month"``.
209+
210+
.. versionadded:: 3.7
211+
212+
213+
.. attribute:: cssclass_month
214+
215+
The CSS class for the whole month's table (used by :meth:`formatmonth`).
216+
The default value is ``"month"``.
217+
218+
.. versionadded:: 3.7
219+
220+
221+
.. attribute:: cssclass_year
222+
223+
The CSS class for the whole year's table of tables (used by
224+
:meth:`formatyear`). The default value is ``"year"``.
225+
226+
.. versionadded:: 3.7
227+
228+
229+
.. attribute:: cssclass_year_head
230+
231+
The CSS class for the table head for the whole year (used by
232+
:meth:`formatyear`). The default value is ``"year"``.
233+
234+
.. versionadded:: 3.7
235+
236+
237+
Note that although the naming for the above described class attributes is
238+
singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the
239+
single CSS class with a space separated list of CSS classes, for example::
240+
241+
"text-bold text-red"
242+
243+
Here is an example how :class:`!HTMLCalendar` can be customized::
244+
245+
class CustomHTMLCal(calendar.HTMLCalendar):
246+
cssclasses = [style + " text-nowrap" for style in
247+
calendar.HTMLCalendar.cssclasses]
248+
cssclass_month_head = "text-center month-head"
249+
cssclass_month = "text-center month"
250+
cssclass_year = "text-italic lead"
251+
252+
174253
.. class:: LocaleTextCalendar(firstweekday=0, locale=None)
175254

176255
This subclass of :class:`TextCalendar` can be passed a locale name in the

Doc/library/datetime.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,11 +1853,11 @@ only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
18531853

18541854
.. seealso::
18551855

1856-
`datetuil.tz <https://dateutil.readthedocs.io/en/stable/tz.html>`_
1856+
`dateutil.tz <https://dateutil.readthedocs.io/en/stable/tz.html>`_
18571857
The standard library has :class:`timezone` class for handling arbitrary
18581858
fixed offsets from UTC and :attr:`timezone.utc` as UTC timezone instance.
18591859

1860-
*datetuil.tz* library brings the *IANA timezone database* (also known as the
1860+
*dateutil.tz* library brings the *IANA timezone database* (also known as the
18611861
Olson database) to Python and its usage is recommended.
18621862

18631863
`IANA timezone database <https://www.iana.org/time-zones>`_

Doc/library/logging.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ is the module's name in the Python package namespace.
323323

324324
.. versionadded:: 3.2
325325

326+
.. versionchanged:: 3.7
327+
Loggers can now be picked and unpickled.
326328

327329
.. _levels:
328330

Doc/library/token.rst

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,37 @@ The token constants are:
101101
AWAIT
102102
ASYNC
103103
ERRORTOKEN
104-
COMMENT
105-
NL
106-
ENCODING
107104
N_TOKENS
108105
NT_OFFSET
109106

110-
.. versionchanged:: 3.5
111-
Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with
112-
Python 3.7, "async" and "await" will be tokenized as :data:`NAME`
113-
tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed.
114107

115-
.. versionchanged:: 3.7
116-
Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING` to bring
117-
the tokens in the C code in line with the tokens needed in
118-
:mod:`tokenize` module. These tokens aren't used by the C tokenizer.
108+
The following token type values aren't used by the C tokenizer but are needed for
109+
the :mod:`tokenize` module.
110+
111+
.. data:: COMMENT
112+
113+
Token value used to indicate a comment.
114+
115+
116+
.. data:: NL
117+
118+
Token value used to indicate a non-terminating newline. The
119+
:data:`NEWLINE` token indicates the end of a logical line of Python code;
120+
``NL`` tokens are generated when a logical line of code is continued over
121+
multiple physical lines.
122+
123+
124+
.. data:: ENCODING
125+
126+
Token value that indicates the encoding used to decode the source bytes
127+
into text. The first token returned by :func:`tokenize.tokenize` will
128+
always be an ``ENCODING`` token.
129+
130+
131+
.. versionchanged:: 3.5
132+
Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with
133+
Python 3.7, "async" and "await" will be tokenized as :data:`NAME`
134+
tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed.
135+
136+
.. versionchanged:: 3.7
137+
Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING` tokens.

Doc/library/tokenize.rst

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ as well, making it useful for implementing "pretty-printers," including
1717
colorizers for on-screen displays.
1818

1919
To simplify token stream handling, all :ref:`operators` and :ref:`delimiters`
20-
tokens are returned using the generic :data:`token.OP` token type. The exact
20+
tokens are returned using the generic :data:`~token.OP` token type. The exact
2121
type can be determined by checking the ``exact_type`` property on the
2222
:term:`named tuple` returned from :func:`tokenize.tokenize`.
2323

@@ -44,7 +44,7 @@ The primary entry point is a :term:`generator`:
4444

4545
The returned :term:`named tuple` has an additional property named
4646
``exact_type`` that contains the exact operator type for
47-
:data:`token.OP` tokens. For all other token types ``exact_type``
47+
:data:`~token.OP` tokens. For all other token types ``exact_type``
4848
equals the named tuple ``type`` field.
4949

5050
.. versionchanged:: 3.1
@@ -58,26 +58,7 @@ The primary entry point is a :term:`generator`:
5858

5959

6060
All constants from the :mod:`token` module are also exported from
61-
:mod:`tokenize`, as are three additional token type values:
62-
63-
.. data:: COMMENT
64-
65-
Token value used to indicate a comment.
66-
67-
68-
.. data:: NL
69-
70-
Token value used to indicate a non-terminating newline. The NEWLINE token
71-
indicates the end of a logical line of Python code; NL tokens are generated
72-
when a logical line of code is continued over multiple physical lines.
73-
74-
75-
.. data:: ENCODING
76-
77-
Token value that indicates the encoding used to decode the source bytes
78-
into text. The first token returned by :func:`.tokenize` will always be an
79-
ENCODING token.
80-
61+
:mod:`tokenize`.
8162

8263
Another function is provided to reverse the tokenization process. This is
8364
useful for creating tools that tokenize a script, modify the token stream, and
@@ -96,8 +77,8 @@ write back the modified script.
9677
token type and token string as the spacing between tokens (column
9778
positions) may change.
9879

99-
It returns bytes, encoded using the ENCODING token, which is the first
100-
token sequence output by :func:`.tokenize`.
80+
It returns bytes, encoded using the :data:`~token.ENCODING` token, which
81+
is the first token sequence output by :func:`.tokenize`.
10182

10283

10384
:func:`.tokenize` needs to detect the encoding of source files it tokenizes. The
@@ -115,7 +96,7 @@ function it uses to do this is available:
11596

11697
It detects the encoding from the presence of a UTF-8 BOM or an encoding
11798
cookie as specified in :pep:`263`. If both a BOM and a cookie are present,
118-
but disagree, a SyntaxError will be raised. Note that if the BOM is found,
99+
but disagree, a :exc:`SyntaxError` will be raised. Note that if the BOM is found,
119100
``'utf-8-sig'`` will be returned as an encoding.
120101

121102
If no encoding is specified, then the default of ``'utf-8'`` will be
@@ -147,8 +128,8 @@ function it uses to do this is available:
147128
3
148129

149130
Note that unclosed single-quoted strings do not cause an error to be
150-
raised. They are tokenized as ``ERRORTOKEN``, followed by the tokenization of
151-
their contents.
131+
raised. They are tokenized as :data:`~token.ERRORTOKEN`, followed by the
132+
tokenization of their contents.
152133

153134

154135
.. _tokenize-cli:
@@ -260,7 +241,7 @@ the name of the token, and the final column is the value of the token (if any)
260241
4,11-4,12: NEWLINE '\n'
261242
5,0-5,0: ENDMARKER ''
262243
263-
The exact token type names can be displayed using the ``-e`` option:
244+
The exact token type names can be displayed using the :option:`-e` option:
264245

265246
.. code-block:: sh
266247

Doc/reference/datamodel.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ Callable types
510510
| :attr:`__closure__` | ``None`` or a tuple of cells | Read-only |
511511
| | that contain bindings for the | |
512512
| | function's free variables. | |
513+
| | See below for information on | |
514+
| | the ``cell_contents`` | |
515+
| | attribute. | |
513516
+-------------------------+-------------------------------+-----------+
514517
| :attr:`__annotations__` | A dict containing annotations | Writable |
515518
| | of parameters. The keys of | |
@@ -530,6 +533,9 @@ Callable types
530533
implementation only supports function attributes on user-defined functions.
531534
Function attributes on built-in functions may be supported in the future.*
532535

536+
A cell object has the attribute ``cell_contents``. This can be used to get
537+
the value of the cell, as well as set the value.
538+
533539
Additional information about a function's definition can be retrieved from its
534540
code object; see the description of internal types below.
535541

0 commit comments

Comments
 (0)