Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 38ad290

Browse files
author
Anselm Kruis
committed
merge branch 3.5
2 parents 072a8cd + 231d906 commit 38ad290

Some content is hidden

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

53 files changed

+1032
-235
lines changed

.hgtags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,4 @@ b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3
170170
82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3
171171
413e0e0004f4f954331cb8122aa55fe208984955 v3.5.0a4
172172
071fefbb5e3db770c6c19fba9994699f121b1cea v3.5.0b1
173+
7a088af5615bf04024e9912068f4bd8f43ed3917 v3.5.0b2

Doc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ doctest:
9696

9797
pydoc-topics: BUILDER = pydoc-topics
9898
pydoc-topics: build
99-
@echo "Building finished; now copy build/pydoc-topics/topics.py" \
100-
"to ../Lib/pydoc_data/topics.py"
99+
@echo "Building finished; now run this:" \
100+
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
101101

102102
htmlview: html
103103
$(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"

Doc/library/cmath.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,38 @@ Classification functions
207207
and ``False`` otherwise.
208208

209209

210+
.. function:: isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
211+
212+
Return ``True`` if the values *a* and *b* are close to each other and
213+
``False`` otherwise.
214+
215+
Whether or not two values are considered close is determined according to
216+
given absolute and relative tolerances.
217+
218+
*rel_tol* is the relative tolerance -- it is the maximum allowed difference
219+
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
220+
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
221+
tolerance is ``1e-09``, which assures that the two values are the same
222+
within about 9 decimal digits. *rel_tol* must be greater than zero.
223+
224+
*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
225+
zero. *abs_tol* must be at least zero.
226+
227+
If no errors occur, the result will be:
228+
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
229+
230+
The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
231+
handled according to IEEE rules. Specifically, ``NaN`` is not considered
232+
close to any other value, including ``NaN``. ``inf`` and ``-inf`` are only
233+
considered close to themselves.
234+
235+
.. versionadded:: 3.5
236+
237+
.. seealso::
238+
239+
:pep:`485` -- A function for testing approximate equality
240+
241+
210242
Constants
211243
---------
212244

Doc/library/inspect.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ attributes:
4343
+-----------+-----------------+---------------------------+
4444
| class | __doc__ | documentation string |
4545
+-----------+-----------------+---------------------------+
46+
| | __name__ | name with which this |
47+
| | | class was defined |
48+
+-----------+-----------------+---------------------------+
49+
| | __qualname__ | qualified name |
50+
+-----------+-----------------+---------------------------+
4651
| | __module__ | name of module in which |
4752
| | | this class was defined |
4853
+-----------+-----------------+---------------------------+
@@ -51,6 +56,8 @@ attributes:
5156
| | __name__ | name with which this |
5257
| | | method was defined |
5358
+-----------+-----------------+---------------------------+
59+
| | __qualname__ | qualified name |
60+
+-----------+-----------------+---------------------------+
5461
| | __func__ | function object |
5562
| | | containing implementation |
5663
| | | of method |
@@ -64,6 +71,8 @@ attributes:
6471
| | __name__ | name with which this |
6572
| | | function was defined |
6673
+-----------+-----------------+---------------------------+
74+
| | __qualname__ | qualified name |
75+
+-----------+-----------------+---------------------------+
6776
| | __code__ | code object containing |
6877
| | | compiled function |
6978
| | | :term:`bytecode` |
@@ -174,6 +183,8 @@ attributes:
174183
| | __name__ | original name of this |
175184
| | | function or method |
176185
+-----------+-----------------+---------------------------+
186+
| | __qualname__ | qualified name |
187+
+-----------+-----------------+---------------------------+
177188
| | __self__ | instance to which a |
178189
| | | method is bound, or |
179190
| | | ``None`` |

Doc/library/math.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ Number-theoretic and representation functions
110110
.. versionadded:: 3.5
111111

112112

113+
.. function:: isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
114+
115+
Return ``True`` if the values *a* and *b* are close to each other and
116+
``False`` otherwise.
117+
118+
Whether or not two values are considered close is determined according to
119+
given absolute and relative tolerances.
120+
121+
*rel_tol* is the relative tolerance -- it is the maximum allowed difference
122+
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
123+
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
124+
tolerance is ``1e-09``, which assures that the two values are the same
125+
within about 9 decimal digits. *rel_tol* must be greater than zero.
126+
127+
*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
128+
zero. *abs_tol* must be at least zero.
129+
130+
If no errors occur, the result will be:
131+
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
132+
133+
The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
134+
handled according to IEEE rules. Specifically, ``NaN`` is not considered
135+
close to any other value, including ``NaN``. ``inf`` and ``-inf`` are only
136+
considered close to themselves.
137+
138+
.. versionadded:: 3.5
139+
140+
.. seealso::
141+
142+
:pep:`485` -- A function for testing approximate equality
143+
144+
113145
.. function:: isfinite(x)
114146

115147
Return ``True`` if *x* is neither an infinity nor a NaN, and

Doc/library/socket.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,14 @@ The :mod:`socket` module also offers various network-related services:
478478
method.
479479

480480
The following example fetches address information for a hypothetical TCP
481-
connection to ``www.python.org`` on port 80 (results may differ on your
481+
connection to ``example.org`` on port 80 (results may differ on your
482482
system if IPv6 isn't enabled)::
483483

484-
>>> socket.getaddrinfo("www.python.org", 80, proto=socket.IPPROTO_TCP)
485-
[(2, 1, 6, '', ('82.94.164.162', 80)),
486-
(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]
484+
>>> socket.getaddrinfo("example.org", 80, proto=socket.IPPROTO_TCP)
485+
[(<AddressFamily.AF_INET6: 10>, <SocketType.SOCK_STREAM: 1>,
486+
6, '', ('2606:2800:220:1:248:1893:25c8:1946', 80, 0, 0)),
487+
(<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>,
488+
6, '', ('93.184.216.34', 80))]
487489

488490
.. versionchanged:: 3.2
489491
parameters can now be passed using keyword arguments.

Doc/library/sys.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,18 @@ always available.
576576
*service_pack_major*, *suite_mask*, and *product_type*.
577577

578578

579+
.. function:: get_coroutine_wrapper()
580+
581+
Returns ``None``, or a wrapper set by :func:`set_coroutine_wrapper`.
582+
583+
.. versionadded:: 3.5
584+
See :pep:`492` for more details.
585+
586+
.. note::
587+
This function has been added on a provisional basis (see :pep:`411`
588+
for details.) Use it only for debug purposes.
589+
590+
579591
.. data:: hash_info
580592

581593
A :term:`struct sequence` giving parameters of the numeric hash
@@ -1061,6 +1073,28 @@ always available.
10611073
thus not likely to be implemented elsewhere.
10621074

10631075

1076+
.. function:: set_coroutine_wrapper(wrapper)
1077+
1078+
Allows to intercept creation of :term:`coroutine` objects.
1079+
1080+
*wrapper* must be either:
1081+
1082+
* a callable that accepts one argument (a coroutine object);
1083+
* ``None``, to reset the wrapper.
1084+
1085+
If called twice, the new wrapper replaces the previous one. The function
1086+
is thread-specific.
1087+
1088+
See also :func:`get_coroutine_wrapper`.
1089+
1090+
.. versionadded:: 3.5
1091+
See :pep:`492` for more details.
1092+
1093+
.. note::
1094+
This function has been added on a provisional basis (see :pep:`411`
1095+
for details.) Use it only for debug purposes.
1096+
1097+
10641098
.. data:: stdin
10651099
stdout
10661100
stderr

Doc/whatsnew/3.5.rst

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ Implementation improvements:
9797

9898
Significantly Improved Library Modules:
9999

100+
* :class:`collections.OrderedDict` is now implemented in C, which improves
101+
its performance between 4x to 100x times. Contributed by Eric Snow in
102+
:issue:`16991`.
103+
100104
* You may now pass bytes to the :mod:`tempfile` module's APIs and it will
101105
return the temporary pathname as bytes instead of str. It also accepts
102106
a value of ``None`` on parameters where only str was accepted in the past to
@@ -147,8 +151,8 @@ PEP written and implemented by Yury Selivanov.
147151
:pep:`492` -- Coroutines with async and await syntax
148152

149153

150-
PEP 461 - Adding formatting to bytes and bytearray
151-
--------------------------------------------------
154+
PEP 461 - Formatting support for bytes and bytearray
155+
----------------------------------------------------
152156

153157
This PEP proposes adding % formatting operations similar to Python 2's ``str``
154158
type to :class:`bytes` and :class:`bytearray`.
@@ -281,6 +285,18 @@ rather than being restricted to ASCII.
281285

282286
:pep:`488` -- Multi-phase extension module initialization
283287

288+
PEP 485: A function for testing approximate equality
289+
----------------------------------------------------
290+
291+
:pep:`485` adds the :func:`math.isclose` and :func:`cmath.isclose`
292+
functions which tell whether two values are approximately equal or
293+
"close" to each other. Whether or not two values are considered
294+
close is determined according to given absolute and relative tolerances.
295+
296+
.. seealso::
297+
298+
:pep:`485` -- A function for testing approximate equality
299+
284300
Other Language Changes
285301
======================
286302

@@ -342,6 +358,13 @@ cgi
342358
* :class:`~cgi.FieldStorage` now supports the context management protocol.
343359
(Contributed by Berker Peksag in :issue:`20289`.)
344360

361+
cmath
362+
-----
363+
364+
* :func:`cmath.isclose` function added.
365+
(Contributed by Chris Barker and Tal Einat in :issue:`24270`.)
366+
367+
345368
code
346369
----
347370

@@ -527,6 +550,14 @@ json
527550
* JSON decoder now raises :exc:`json.JSONDecodeError` instead of
528551
:exc:`ValueError`. (Contributed by Serhiy Storchaka in :issue:`19361`.)
529552

553+
math
554+
----
555+
556+
* :data:`math.inf` and :data:`math.nan` constants added. (Contributed by Mark
557+
Dickinson in :issue:`23185`.)
558+
* :func:`math.isclose` function added.
559+
(Contributed by Chris Barker and Tal Einat in :issue:`24270`.)
560+
530561
os
531562
--
532563

@@ -569,12 +600,6 @@ re
569600
* Now unmatched groups are replaced with empty strings in :func:`re.sub`
570601
and :func:`re.subn`. (Contributed by Serhiy Storchaka in :issue:`1519638`.)
571602

572-
math
573-
----
574-
575-
* :data:`math.inf` and :data:`math.nan` constants added. (Contributed by Mark
576-
Dickinson in :issue:`23185`.)
577-
578603
shutil
579604
------
580605

@@ -664,6 +689,12 @@ subprocess
664689
API than :func:`~subprocess.call`, :func:`~subprocess.check_call` and
665690
:func:`~subprocess.check_output`.
666691

692+
sys
693+
---
694+
695+
* New :func:`~sys.set_coroutine_wrapper` and :func:`~sys.get_coroutine_wrapper`
696+
functions. (Contributed by Yury Selivanov in :issue:`24017`.)
697+
667698
sysconfig
668699
---------
669700

@@ -1045,6 +1076,10 @@ Changes in the Python API
10451076
program depends on patching the module level variable to capture the debug
10461077
output, you will need to update it to capture sys.stderr instead.
10471078

1079+
* The :meth:`str.startswith` and :meth:`str.endswith` methods no longer return
1080+
``True`` when finding the empty string and the indexes are completely out of
1081+
range. See :issue:`24284`.
1082+
10481083
Changes in the C API
10491084
--------------------
10501085

Include/ceval.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
2323
#ifndef Py_LIMITED_API
2424
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
2525
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
26-
PyAPI_FUNC(void) PyEval_SetCoroutineWrapper(PyObject *wrapper);
27-
PyAPI_FUNC(PyObject *) PyEval_GetCoroutineWrapper(void);
26+
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *wrapper);
27+
PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void);
2828
#endif
2929

3030
struct _frame; /* Avoid including frameobject.h */

Include/dictobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type;
4545
#define PyDict_Check(op) \
4646
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
4747
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
48-
#define PyDictKeys_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictKeys_Type))
49-
#define PyDictItems_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictItems_Type))
50-
#define PyDictValues_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictValues_Type))
48+
#define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type)
49+
#define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type)
50+
#define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type)
5151
/* This excludes Values, since they are not sets. */
5252
# define PyDictViewSet_Check(op) \
5353
(PyDictKeys_Check(op) || PyDictItems_Check(op))

Include/odictobject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyODictValues_Type;
1919

2020
#endif /* Py_LIMITED_API */
2121

22-
#define PyODict_Check(op) PyObject_IsInstance(op, (PyObject *)&PyODict_Type)
22+
#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
2323
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
2424
#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used
2525
#define PyODict_HasKey(od, key) (PyMapping_HasKey(PyObject *)od, key)
@@ -30,11 +30,12 @@ PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key);
3030

3131
/* wrappers around PyDict* functions */
3232
#define PyODict_GetItem(od, key) PyDict_GetItem((PyObject *)od, key)
33+
#define PyODict_GetItemWithError(od, key) \
34+
PyDict_GetItemWithError((PyObject *)od, key)
3335
#define PyODict_Contains(od, key) PyDict_Contains((PyObject *)od, key)
3436
#define PyODict_Size(od) PyDict_Size((PyObject *)od)
3537
#define PyODict_GetItemString(od, key) \
3638
PyDict_GetItemString((PyObject *)od, key)
37-
#define Py_ODict_GetItemId(od, key) _PyDict_GetItemId((PyObject *)od, key)
3839

3940
#ifdef __cplusplus
4041
}

Include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#define PY_MINOR_VERSION 5
2121
#define PY_MICRO_VERSION 0
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA
23-
#define PY_RELEASE_SERIAL 1
23+
#define PY_RELEASE_SERIAL 2
2424

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

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

Include/typeslots.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@
7979
#define Py_am_await 77
8080
#define Py_am_aiter 78
8181
#define Py_am_anext 79
82+
#define Py_tp_finalize 80

0 commit comments

Comments
 (0)