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

Commit 1085a35

Browse files
author
Anselm Kruis
committed
merge branch 3.5
2 parents 0feeeb0 + ff1d5ab commit 1085a35

Some content is hidden

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

45 files changed

+2893
-2668
lines changed

Doc/c-api/arg.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Unless otherwise stated, buffers are not NUL-terminated.
5959
Convert a Unicode object to a C pointer to a character string.
6060
A pointer to an existing string is stored in the character pointer
6161
variable whose address you pass. The C string is NUL-terminated.
62-
The Python string must not contain embedded NUL bytes; if it does,
63-
a :exc:`TypeError` exception is raised. Unicode objects are converted
62+
The Python string must not contain embedded null characters; if it does,
63+
a :exc:`ValueError` exception is raised. Unicode objects are converted
6464
to C strings using ``'utf-8'`` encoding. If this conversion fails, a
6565
:exc:`UnicodeError` is raised.
6666

@@ -71,6 +71,10 @@ Unless otherwise stated, buffers are not NUL-terminated.
7171
preferable to use the ``O&`` format with :c:func:`PyUnicode_FSConverter`
7272
as *converter*.
7373

74+
.. versionchanged:: 3.5
75+
Previously, :exc:`TypeError` was raised when embedded null characters
76+
were encountered in the Python string.
77+
7478
``s*`` (:class:`str` or :term:`bytes-like object`) [Py_buffer]
7579
This format accepts Unicode objects as well as bytes-like objects.
7680
It fills a :c:type:`Py_buffer` structure provided by the caller.
@@ -99,9 +103,13 @@ Unless otherwise stated, buffers are not NUL-terminated.
99103
``y`` (read-only :term:`bytes-like object`) [const char \*]
100104
This format converts a bytes-like object to a C pointer to a character
101105
string; it does not accept Unicode objects. The bytes buffer must not
102-
contain embedded NUL bytes; if it does, a :exc:`TypeError`
106+
contain embedded null bytes; if it does, a :exc:`ValueError`
103107
exception is raised.
104108

109+
.. versionchanged:: 3.5
110+
Previously, :exc:`TypeError` was raised when embedded null bytes were
111+
encountered in the bytes buffer.
112+
105113
``y*`` (:term:`bytes-like object`) [Py_buffer]
106114
This variant on ``s*`` doesn't accept Unicode objects, only
107115
bytes-like objects. **This is the recommended way to accept
@@ -127,14 +135,18 @@ Unless otherwise stated, buffers are not NUL-terminated.
127135
pointer variable, which will be filled with the pointer to an existing
128136
Unicode buffer. Please note that the width of a :c:type:`Py_UNICODE`
129137
character depends on compilation options (it is either 16 or 32 bits).
130-
The Python string must not contain embedded NUL characters; if it does,
131-
a :exc:`TypeError` exception is raised.
138+
The Python string must not contain embedded null characters; if it does,
139+
a :exc:`ValueError` exception is raised.
132140

133141
.. note::
134142
Since ``u`` doesn't give you back the length of the string, and it
135143
may contain embedded NUL characters, it is recommended to use ``u#``
136144
or ``U`` instead.
137145

146+
.. versionchanged:: 3.5
147+
Previously, :exc:`TypeError` was raised when embedded null characters
148+
were encountered in the Python string.
149+
138150
``u#`` (:class:`str`) [Py_UNICODE \*, int]
139151
This variant on ``u`` stores into two C variables, the first one a pointer to a
140152
Unicode data buffer, the second one its length.

Doc/c-api/bytes.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ called with a non-bytes parameter.
158158
159159
If *length* is *NULL*, the bytes object
160160
may not contain embedded null bytes;
161-
if it does, the function returns ``-1`` and a :exc:`TypeError` is raised.
161+
if it does, the function returns ``-1`` and a :exc:`ValueError` is raised.
162162
163163
The buffer refers to an internal buffer of *obj*, which includes an
164164
additional null byte at the end (not counted in *length*). The data
@@ -167,6 +167,10 @@ called with a non-bytes parameter.
167167
*obj* is not a bytes object at all, :c:func:`PyBytes_AsStringAndSize`
168168
returns ``-1`` and raises :exc:`TypeError`.
169169
170+
.. versionchanged:: 3.5
171+
Previously, :exc:`TypeError` was raised when embedded null bytes were
172+
encountered in the bytes object.
173+
170174
171175
.. c:function:: void PyBytes_Concat(PyObject **bytes, PyObject *newpart)
172176

Doc/includes/email-alternative-new-api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# Create the base text message.
1010
msg = EmailMessage()
1111
msg['Subject'] = "Ayons asperges pour le déjeuner"
12-
msg['From'] = Address("Pepé Le Pew", "pepe@example.com")
13-
msg['To'] = (Address("Penelope Pussycat", "penelope@example.com"),
14-
Address("Fabrette Pussycat", "fabrette@example.com"))
12+
msg['From'] = Address("Pepé Le Pew", "pepe", "example.com")
13+
msg['To'] = (Address("Penelope Pussycat", "penelope", "example.com"),
14+
Address("Fabrette Pussycat", "fabrette", "example.com"))
1515
msg.set_content("""\
1616
Salut!
1717

Doc/library/collections.abc.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ ABC Inherits from Abstract Methods Mixin
5555
``__len__``,
5656
``insert``
5757

58+
:class:`ByteString` :class:`Sequence` ``__getitem__``, Inherited :class:`Sequence` methods
59+
``__len__``
60+
5861
:class:`Set` :class:`Sized`, ``__contains__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
5962
:class:`Iterable`, ``__iter__``, ``__gt__``, ``__ge__``, ``__and__``, ``__or__``,
6063
:class:`Container` ``__len__`` ``__sub__``, ``__xor__``, and ``isdisjoint``
@@ -119,6 +122,7 @@ ABC Inherits from Abstract Methods Mixin
119122

120123
.. class:: Sequence
121124
MutableSequence
125+
ByteString
122126

123127
ABCs for read-only and mutable :term:`sequences <sequence>`.
124128

@@ -135,7 +139,6 @@ ABC Inherits from Abstract Methods Mixin
135139
The index() method added support for *stop* and *start*
136140
arguments.
137141

138-
139142
.. class:: Set
140143
MutableSet
141144

Doc/library/email-examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ way we could process it:
6161

6262
Up to the prompt, the output from the above is::
6363

64-
To: Penelope Pussycat <"[email protected]">, Fabrette Pussycat <"[email protected]">
64+
To: Penelope Pussycat <[email protected]>, Fabrette Pussycat <[email protected]>
6565
From: Pepé Le Pew <[email protected]>
6666
Subject: Ayons asperges pour le déjeuner
6767

Doc/library/pathlib.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,9 @@ call fails (for example because the path doesn't exist):
891891

892892
.. method:: Path.rename(target)
893893

894-
Rename this file or directory to the given *target*. *target* can be
895-
either a string or another path object::
894+
Rename this file or directory to the given *target*. On Unix, if
895+
*target* exists and is a file, it will be replaced silently if the user
896+
has permission. *target* can be either a string or another path object::
896897

897898
>>> p = Path('foo')
898899
>>> p.open('w').write('some text')

Doc/library/pyexpat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ XMLParser Objects
244244

245245
The following attributes contain values relating to the most recent error
246246
encountered by an :class:`xmlparser` object, and will only have correct values
247-
once a call to :meth:`Parse` or :meth:`ParseFile` has raised a
247+
once a call to :meth:`Parse` or :meth:`ParseFile` has raised an
248248
:exc:`xml.parsers.expat.ExpatError` exception.
249249

250250

Doc/library/tkinter.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ A Simple Hello World Program
199199

200200
class Application(tk.Frame):
201201
def __init__(self, master=None):
202-
tk.Frame.__init__(self, master)
202+
super().__init__(master)
203203
self.pack()
204-
self.createWidgets()
204+
self.create_widgets()
205205

206-
def createWidgets(self):
206+
def create_widgets(self):
207207
self.hi_there = tk.Button(self)
208208
self.hi_there["text"] = "Hello World\n(click me)"
209209
self.hi_there["command"] = self.say_hi
210210
self.hi_there.pack(side="top")
211211

212-
self.QUIT = tk.Button(self, text="QUIT", fg="red",
212+
self.quit = tk.Button(self, text="QUIT", fg="red",
213213
command=root.destroy)
214-
self.QUIT.pack(side="bottom")
214+
self.quit.pack(side="bottom")
215215

216216
def say_hi(self):
217217
print("hi there, everyone!")
@@ -536,7 +536,7 @@ For example::
536536

537537
class App(Frame):
538538
def __init__(self, master=None):
539-
Frame.__init__(self, master)
539+
super().__init__(master)
540540
self.pack()
541541

542542
self.entrythingy = Entry()
@@ -581,13 +581,13 @@ part of the implementation, and not an interface to Tk functionality.
581581

582582
Here are some examples of typical usage::
583583

584-
from tkinter import *
585-
class App(Frame):
584+
import tkinter as tk
585+
586+
class App(tk.Frame):
586587
def __init__(self, master=None):
587-
Frame.__init__(self, master)
588+
super().__init__(master)
588589
self.pack()
589590

590-
591591
# create the application
592592
myapp = App()
593593

@@ -708,13 +708,13 @@ add
708708

709709
For example::
710710

711-
def turnRed(self, event):
711+
def turn_red(self, event):
712712
event.widget["activeforeground"] = "red"
713713

714-
self.button.bind("<Enter>", self.turnRed)
714+
self.button.bind("<Enter>", self.turn_red)
715715

716716
Notice how the widget field of the event is being accessed in the
717-
:meth:`turnRed` callback. This field contains the widget that caught the X
717+
``turn_red()`` callback. This field contains the widget that caught the X
718718
event. The following table lists the other event fields you can access, and how
719719
they are denoted in Tk, which can be useful when referring to the Tk man pages.
720720

Doc/library/urllib.request.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ the returned bytes object to string once it determines or guesses
11381138
the appropriate encoding.
11391139

11401140
The following W3C document, https://www.w3.org/International/O-charset\ , lists
1141-
the various ways in which a (X)HTML or a XML document could have specified its
1141+
the various ways in which an (X)HTML or an XML document could have specified its
11421142
encoding information.
11431143

11441144
As the python.org website uses *utf-8* encoding as specified in its meta tag, we

Doc/library/xml.dom.minidom.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ document: the one that holds all others. Here is an example program::
9494

9595
When you are finished with a DOM tree, you may optionally call the
9696
:meth:`unlink` method to encourage early cleanup of the now-unneeded
97-
objects. :meth:`unlink` is a :mod:`xml.dom.minidom`\ -specific
97+
objects. :meth:`unlink` is an :mod:`xml.dom.minidom`\ -specific
9898
extension to the DOM API that renders the node and its descendants are
9999
essentially useless. Otherwise, Python's garbage collector will
100100
eventually take care of the objects in the tree.

Doc/library/xmlrpc.server.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ requests sent to Python CGI scripts.
293293

294294
.. method:: CGIXMLRPCRequestHandler.handle_request(request_text=None)
295295

296-
Handle a XML-RPC request. If *request_text* is given, it should be the POST
296+
Handle an XML-RPC request. If *request_text* is given, it should be the POST
297297
data provided by the HTTP server, otherwise the contents of stdin will be used.
298298

299299
Example::

Grammar/Grammar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ arglist: argument (',' argument)* [',']
132132
# to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
133133
# we explicitly match '*' here, too, to give it proper precedence.
134134
# Illegal combinations and orderings are blocked in ast.c:
135-
# multiple (test comp_for) arguements are blocked; keyword unpackings
135+
# multiple (test comp_for) arguments are blocked; keyword unpackings
136136
# that precede iterable unpackings are blocked; etc.
137137
argument: ( test [comp_for] |
138138
test '=' test |

Lib/asyncio/base_events.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,6 @@ def create_connection(self, protocol_factory, host=None, port=None, *,
707707
raise ValueError(
708708
'host and port was not specified and no sock specified')
709709

710-
sock.setblocking(False)
711-
712710
transport, protocol = yield from self._create_connection_transport(
713711
sock, protocol_factory, ssl, server_hostname)
714712
if self._debug:
@@ -721,14 +719,17 @@ def create_connection(self, protocol_factory, host=None, port=None, *,
721719

722720
@coroutine
723721
def _create_connection_transport(self, sock, protocol_factory, ssl,
724-
server_hostname):
722+
server_hostname, server_side=False):
723+
724+
sock.setblocking(False)
725+
725726
protocol = protocol_factory()
726727
waiter = self.create_future()
727728
if ssl:
728729
sslcontext = None if isinstance(ssl, bool) else ssl
729730
transport = self._make_ssl_transport(
730731
sock, protocol, sslcontext, waiter,
731-
server_side=False, server_hostname=server_hostname)
732+
server_side=server_side, server_hostname=server_hostname)
732733
else:
733734
transport = self._make_socket_transport(sock, protocol, waiter)
734735

@@ -979,6 +980,25 @@ def create_server(self, protocol_factory, host=None, port=None,
979980
logger.info("%r is serving", server)
980981
return server
981982

983+
@coroutine
984+
def connect_accepted_socket(self, protocol_factory, sock, *, ssl=None):
985+
"""Handle an accepted connection.
986+
987+
This is used by servers that accept connections outside of
988+
asyncio but that use asyncio to handle connections.
989+
990+
This method is a coroutine. When completed, the coroutine
991+
returns a (transport, protocol) pair.
992+
"""
993+
transport, protocol = yield from self._create_connection_transport(
994+
sock, protocol_factory, ssl, '', server_side=True)
995+
if self._debug:
996+
# Get the socket from the transport because SSL transport closes
997+
# the old socket and creates a new SSL socket
998+
sock = transport.get_extra_info('socket')
999+
logger.debug("%r handled: (%r, %r)", sock, transport, protocol)
1000+
return transport, protocol
1001+
9821002
@coroutine
9831003
def connect_read_pipe(self, protocol_factory, pipe):
9841004
protocol = protocol_factory()

Lib/distutils/tests/test_build_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def test_check_extensions_list(self):
243243
self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
244244

245245
# second element of each tuple in 'ext_modules'
246-
# must be a ary (build info)
246+
# must be a dictionary (build info)
247247
exts = [('foo.bar', '')]
248248
self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
249249

Lib/email/feedparser.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(self, _factory=None, *, policy=compat32):
145145
146146
"""
147147
self.policy = policy
148-
self._factory_kwds = lambda: {'policy': self.policy}
148+
self._old_style_factory = False
149149
if _factory is None:
150150
# What this should be:
151151
#self._factory = policy.default_message_factory
@@ -160,7 +160,7 @@ def __init__(self, _factory=None, *, policy=compat32):
160160
_factory(policy=self.policy)
161161
except TypeError:
162162
# Assume this is an old-style factory
163-
self._factory_kwds = lambda: {}
163+
self._old_style_factory = True
164164
self._input = BufferedSubFile()
165165
self._msgstack = []
166166
self._parse = self._parsegen().__next__
@@ -197,7 +197,10 @@ def close(self):
197197
return root
198198

199199
def _new_message(self):
200-
msg = self._factory(**self._factory_kwds())
200+
if self._old_style_factory:
201+
msg = self._factory()
202+
else:
203+
msg = self._factory(policy=self.policy)
201204
if self._cur and self._cur.get_content_type() == 'multipart/digest':
202205
msg.set_default_type('message/rfc822')
203206
if self._msgstack:

Lib/http/cookiejar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def time2netscape(t=None):
120120
dt = datetime.datetime.utcnow()
121121
else:
122122
dt = datetime.datetime.utcfromtimestamp(t)
123-
return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % (
123+
return "%s, %02d-%s-%04d %02d:%02d:%02d GMT" % (
124124
DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
125125
dt.year, dt.hour, dt.minute, dt.second)
126126

Lib/idlelib/NEWS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ What's New in IDLE 3.5.0?
195195
Changes are written to HOME/.idlerc/config-extensions.cfg.
196196
Original patch by Tal Einat.
197197

198-
- Issue #16233: A module browser (File : Class Browser, Alt+C) requires a
198+
- Issue #16233: A module browser (File : Class Browser, Alt+C) requires an
199199
editor window with a filename. When Class Browser is requested otherwise,
200200
from a shell, output window, or 'Untitled' editor, Idle no longer displays
201201
an error box. It now pops up an Open Module box (Alt+M). If a valid name

Lib/idlelib/run.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
import __main__
2121

22+
for mod in ('simpledialog', 'messagebox', 'font',
23+
'dialog', 'filedialog', 'commondialog',
24+
'colorchooser'):
25+
delattr(tkinter, mod)
26+
del sys.modules['tkinter.' + mod]
27+
2228
LOCALHOST = '127.0.0.1'
2329

2430
import warnings

Lib/imp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ def find_module(name, path=None):
266266
raise TypeError("'name' must be a str, not {}".format(type(name)))
267267
elif not isinstance(path, (type(None), list)):
268268
# Backwards-compatibility
269-
raise RuntimeError("'list' must be None or a list, "
270-
"not {}".format(type(name)))
269+
raise RuntimeError("'path' must be None or a list, "
270+
"not {}".format(type(path)))
271271

272272
if path is None:
273273
if is_builtin(name):

0 commit comments

Comments
 (0)