Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 6f00f52

Browse files
author
Anselm Kruis
committed
Merge tag v3.8.0b1 into main-slp
2 parents faa6003 + 3b5deb0 commit 6f00f52

File tree

218 files changed

+2326
-639
lines changed

Some content is hidden

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

218 files changed

+2326
-639
lines changed

‎Doc/library/asyncio-eventloop.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,12 @@ Running and stopping the loop
140140
The loop must not be running when this function is called.
141141
Any pending callbacks will be discarded.
142142

143-
This method clears all queues and shuts down the default executor. By
144-
default, it waits for the default executor to finish. Set
145-
*loop.wait_executor_on_close* to ``False`` to not wait for the executor.
143+
This method clears all queues and shuts down the executor, but does
144+
not wait for the executor to finish.
146145

147146
This method is idempotent and irreversible. No other methods
148147
should be called after the event loop is closed.
149148

150-
.. versionchanged:: 3.8
151-
The method now waits for the default executor to finish by default.
152-
Added *loop.wait_executor_on_close* attribute.
153-
154-
155149
.. coroutinemethod:: loop.shutdown_asyncgens()
156150

157151
Schedule all currently open :term:`asynchronous generator` objects to

‎Doc/library/datetime.rst

Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,56 +1365,64 @@ Examples of working with datetime objects:
13651365

13661366
Using datetime with tzinfo:
13671367

1368-
>>> from datetime import timedelta, datetime, tzinfo
1369-
>>> class GMT1(tzinfo):
1368+
>>> from datetime import timedelta, datetime, tzinfo, timezone
1369+
>>> class KabulTz(tzinfo):
1370+
... # Kabul used +4 until 1945, when they moved to +4:30
1371+
... UTC_MOVE_DATE = datetime(1944, 12, 31, 20, tzinfo=timezone.utc)
13701372
... def utcoffset(self, dt):
1371-
... return timedelta(hours=1) + self.dst(dt)
1372-
... def dst(self, dt):
1373-
... # DST starts last Sunday in March
1374-
... d = datetime(dt.year, 4, 1) # ends last Sunday in October
1375-
... self.dston = d - timedelta(days=d.weekday() + 1)
1376-
... d = datetime(dt.year, 11, 1)
1377-
... self.dstoff = d - timedelta(days=d.weekday() + 1)
1378-
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
1379-
... return timedelta(hours=1)
1373+
... if dt.year < 1945:
1374+
... return timedelta(hours=4)
1375+
... elif (1945, 1, 1, 0, 0) <= dt.timetuple()[:5] < (1945, 1, 1, 0, 30):
1376+
... # If dt falls in the imaginary range, use fold to decide how
1377+
... # to resolve. See PEP495
1378+
... return timedelta(hours=4, minutes=(30 if dt.fold else 0))
13801379
... else:
1381-
... return timedelta(0)
1382-
... def tzname(self,dt):
1383-
... return "GMT +1"
1380+
... return timedelta(hours=4, minutes=30)
1381+
...
1382+
... def fromutc(self, dt):
1383+
... # A custom implementation is required for fromutc as
1384+
... # the input to this function is a datetime with utc values
1385+
... # but with a tzinfo set to self
1386+
... # See datetime.astimezone or fromtimestamp
1387+
...
1388+
... # Follow same validations as in datetime.tzinfo
1389+
... if not isinstance(dt, datetime):
1390+
... raise TypeError("fromutc() requires a datetime argument")
1391+
... if dt.tzinfo is not self:
1392+
... raise ValueError("dt.tzinfo is not self")
1393+
...
1394+
... if dt.replace(tzinfo=timezone.utc) >= self.UTC_MOVE_DATE:
1395+
... return dt + timedelta(hours=4, minutes=30)
1396+
... else:
1397+
... return dt + timedelta(hours=4)
13841398
...
1385-
>>> class GMT2(tzinfo):
1386-
... def utcoffset(self, dt):
1387-
... return timedelta(hours=2) + self.dst(dt)
13881399
... def dst(self, dt):
1389-
... d = datetime(dt.year, 4, 1)
1390-
... self.dston = d - timedelta(days=d.weekday() + 1)
1391-
... d = datetime(dt.year, 11, 1)
1392-
... self.dstoff = d - timedelta(days=d.weekday() + 1)
1393-
... if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
1394-
... return timedelta(hours=1)
1400+
... return timedelta(0)
1401+
...
1402+
... def tzname(self, dt):
1403+
... if dt >= self.UTC_MOVE_DATE:
1404+
... return "+04:30"
13951405
... else:
1396-
... return timedelta(0)
1397-
... def tzname(self,dt):
1398-
... return "GMT +2"
1406+
... return "+04"
13991407
...
1400-
>>> gmt1 = GMT1()
1401-
>>> # Daylight Saving Time
1402-
>>> dt1 = datetime(2006, 11, 21, 16, 30, tzinfo=gmt1)
1403-
>>> dt1.dst()
1404-
datetime.timedelta(0)
1405-
>>> dt1.utcoffset()
1406-
datetime.timedelta(seconds=3600)
1407-
>>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=gmt1)
1408-
>>> dt2.dst()
1409-
datetime.timedelta(seconds=3600)
1410-
>>> dt2.utcoffset()
1411-
datetime.timedelta(seconds=7200)
1408+
... def__repr__(self):
1409+
... returnf"{self.__class__.__name__}()"
1410+
...
1411+
>>> tz1 = KabulTz()
1412+
>>> # Datetime before the change
1413+
>>> dt1= datetime(1900, 11, 21, 16, 30, tzinfo=tz1)
1414+
>>> print(dt1.utcoffset())
1415+
4:00:00
1416+
>>> # Datetime after the change
1417+
>>> dt2 =datetime(2006, 6, 14, 13, 0, tzinfo=tz1)
1418+
>>> print(dt2.utcoffset())
1419+
4:30:00
14121420
>>> # Convert datetime to another time zone
1413-
>>> dt3 = dt2.astimezone(GMT2())
1414-
>>> dt3# doctest: +ELLIPSIS
1415-
datetime.datetime(2006, 6, 14, 14, 0, tzinfo=<GMT2 object at 0x...>)
1416-
>>> dt2# doctest: +ELLIPSIS
1417-
datetime.datetime(2006, 6, 14, 13, 0, tzinfo=<GMT1 object at 0x...>)
1421+
>>> dt3 = dt2.astimezone(timezone.utc)
1422+
>>> dt3
1423+
datetime.datetime(2006, 6, 14, 8, 30, tzinfo=datetime.timezone.utc)
1424+
>>> dt2
1425+
datetime.datetime(2006, 6, 14, 13, 0, tzinfo=KabulTz())
14181426
>>> dt2.utctimetuple() == dt3.utctimetuple()
14191427
True
14201428

@@ -1656,26 +1664,27 @@ Instance methods:
16561664
Example:
16571665

16581666
>>> from datetime import time, tzinfo, timedelta
1659-
>>> class GMT1(tzinfo):
1667+
>>> class TZ1(tzinfo):
16601668
... def utcoffset(self, dt):
16611669
... return timedelta(hours=1)
16621670
... def dst(self, dt):
16631671
... return timedelta(0)
16641672
... def tzname(self,dt):
1665-
... return "Europe/Prague"
1673+
... return "+01:00"
1674+
... def __repr__(self):
1675+
... return f"{self.__class__.__name__}()"
16661676
...
1667-
>>> t = time(12, 10, 30, tzinfo=GMT1())
1668-
>>> t # doctest: +ELLIPSIS
1669-
datetime.time(12, 10, 30, tzinfo=<GMT1 object at 0x...>)
1670-
>>> gmt = GMT1()
1677+
>>> t = time(12, 10, 30, tzinfo=TZ1())
1678+
>>> t
1679+
datetime.time(12, 10, 30, tzinfo=TZ1())
16711680
>>> t.isoformat()
16721681
'12:10:30+01:00'
16731682
>>> t.dst()
16741683
datetime.timedelta(0)
16751684
>>> t.tzname()
1676-
'Europe/Prague'
1685+
'+01:00'
16771686
>>> t.strftime("%H:%M:%S %Z")
1678-
'12:10:30 Europe/Prague'
1687+
'12:10:30 +01:00'
16791688
>>> 'The {} is {:%H:%M}.'.format("time", t)
16801689
'The time is 12:10.'
16811690

‎Doc/library/math.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ Number-theoretic and representation functions
4141
Return the number of ways to choose *k* items from *n* items without repetition
4242
and without order.
4343

44-
Also called the binomial coefficient. It is mathematically equal to the expression
45-
``n! / (k! (n - k)!)``. It is equivalent to the coefficient of the *k*-th term in the
46-
polynomial expansion of the expression ``(1 + x) ** n``.
44+
Evaluates to ``n! / (k! * (n - k)!)`` when ``k <= n`` and evaluates
45+
to zero when ``k > n``.
4746

48-
Raises :exc:`TypeError` if the arguments not integers.
49-
Raises :exc:`ValueError` if the arguments are negative or if *k* > *n*.
47+
Also called the binomial coefficient because it is equivalent
48+
to the coefficient of k-th term in polynomial expansion of the
49+
expression ``(1 + x) ** n``.
50+
51+
Raises :exc:`TypeError` if either of the arguments are not integers.
52+
Raises :exc:`ValueError` if either of the arguments are negative.
5053

5154
.. versionadded:: 3.8
5255

@@ -212,10 +215,11 @@ Number-theoretic and representation functions
212215
Return the number of ways to choose *k* items from *n* items
213216
without repetition and with order.
214217

215-
It is mathematically equal to the expression ``n! / (n - k)!``.
218+
Evaluates to ``n! / (n - k)!`` when ``k <= n`` and evaluates
219+
to zero when ``k > n``.
216220

217-
Raises :exc:`TypeError` if the arguments not integers.
218-
Raises :exc:`ValueError` if the arguments are negative or if *k* > *n*.
221+
Raises :exc:`TypeError` if either of the arguments are not integers.
222+
Raises :exc:`ValueError` if either of the arguments are negative.
219223

220224
.. versionadded:: 3.8
221225

‎Doc/reference/simple_stmts.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ statement, of a variable or attribute annotation and an optional assignment stat
330330

331331
.. productionlist::
332332
annotated_assignment_stmt: `augtarget` ":" `expression`
333-
: ["=" (`expression_list` | `yield_expression`)]
333+
: ["=" (`starred_expression` | `yield_expression`)]
334334

335-
The difference from normal :ref:`assignment` is that only single target and
336-
only single right hand side value is allowed.
335+
The difference from normal :ref:`assignment` is that only single target is allowed.
337336

338337
For simple names as assignment targets, if in class or module scope,
339338
the annotations are evaluated and stored in a special class or module
@@ -369,7 +368,7 @@ target, then the interpreter evaluates the target except for the last
369368

370369
.. versionchanged:: 3.8
371370
Now annotated assignments allow same expressions in the right hand side as
372-
the augmented assignments. Previously, some expressions (like un-parenthesized
371+
the regular assignments. Previously, some expressions (like un-parenthesized
373372
tuple expressions) caused a syntax error.
374373

375374

‎Doc/tools/extensions/pyspecific.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
ISSUE_URI = 'https://bugs.python.org/issue%s'
39-
SOURCE_URI = 'https://github.com/python/cpython/tree/master/%s'
39+
SOURCE_URI = 'https://github.com/python/cpython/tree/3.8/%s'
4040

4141
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
4242
from docutils.parsers.rst.states import Body

‎Include/patchlevel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#define PY_MAJOR_VERSION 3
2020
#define PY_MINOR_VERSION 8
2121
#define PY_MICRO_VERSION 0
22-
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
23-
#define PY_RELEASE_SERIAL 4
22+
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA
23+
#define PY_RELEASE_SERIAL 1
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.8.0a4+"
26+
#define PY_VERSION "3.8.0b1"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

‎Lib/asyncio/base_events.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,6 @@ async def wait_closed(self):
380380
class BaseEventLoop(events.AbstractEventLoop):
381381

382382
def __init__(self):
383-
# If true, close() waits for the default executor to finish
384-
self.wait_executor_on_close = True
385383
self._timer_cancelled_count = 0
386384
self._closed = False
387385
self._stopping = False
@@ -637,7 +635,7 @@ def close(self):
637635
executor = self._default_executor
638636
if executor is not None:
639637
self._default_executor = None
640-
executor.shutdown(wait=self.wait_executor_on_close)
638+
executor.shutdown(wait=False)
641639

642640
def is_closed(self):
643641
"""Returns True if the event loop was closed."""

‎Lib/logging/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ def start(self):
14371437
t.daemon = True
14381438
t.start()
14391439

1440-
def prepare(self, record):
1440+
def prepare(self, record):
14411441
"""
14421442
Prepare a record for handling.
14431443

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /