Skip to content

Commit 01e844c

Browse files
Merge branch '3.14' into backport-b582d75-3.14
2 parents 7ee2696 + d86ca7b commit 01e844c

File tree

17 files changed

+131
-60
lines changed

17 files changed

+131
-60
lines changed

Doc/library/http.cookiejar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Netscape protocol strictness switches:
570570

571571
Don't allow setting cookies whose path doesn't path-match request URI.
572572

573-
:attr:`strict_ns_domain` is a collection of flags. Its value is constructed by
573+
:attr:`~DefaultCookiePolicy.strict_ns_domain` is a collection of flags. Its value is constructed by
574574
or-ing together (for example, ``DomainStrictNoDots|DomainStrictNonDomain`` means
575575
both flags are set).
576576

Doc/library/tarfile.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Some facts and figures:
6363
+------------------+---------------------------------------------+
6464
| mode | action |
6565
+==================+=============================================+
66-
| ``'r' or 'r:*'`` | Open for reading with transparent |
67-
| | compression (recommended). |
66+
| ``'r'`` or | Open for reading with transparent |
67+
| ``'r:*'`` | compression (recommended). |
6868
+------------------+---------------------------------------------+
6969
| ``'r:'`` | Open for reading exclusively without |
7070
| | compression. |
@@ -98,10 +98,11 @@ Some facts and figures:
9898
| | Raise a :exc:`FileExistsError` exception |
9999
| | if it already exists. |
100100
+------------------+---------------------------------------------+
101-
| ``'a' or 'a:'`` | Open for appending with no compression. The |
102-
| | file is created if it does not exist. |
101+
| ``'a'`` or | Open for appending with no compression. The |
102+
| ``'a:'`` | file is created if it does not exist. |
103103
+------------------+---------------------------------------------+
104-
| ``'w' or 'w:'`` | Open for uncompressed writing. |
104+
| ``'w'`` or | Open for uncompressed writing. |
105+
| ``'w:'`` | |
105106
+------------------+---------------------------------------------+
106107
| ``'w:gz'`` | Open for gzip compressed writing. |
107108
+------------------+---------------------------------------------+

Lib/concurrent/interpreters/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,8 @@ def __del__(self):
146146
self._decref()
147147

148148
# for pickling:
149-
def __getnewargs__(self):
150-
return (self._id,)
151-
152-
# for pickling:
153-
def __getstate__(self):
154-
return None
149+
def __reduce__(self):
150+
return (type(self), (self._id,))
155151

156152
def _decref(self):
157153
if not self._ownsref:

Lib/concurrent/interpreters/_queues.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,8 @@ def __hash__(self):
130130
return hash(self._id)
131131

132132
# for pickling:
133-
def __getnewargs__(self):
134-
return (self._id,)
135-
136-
# for pickling:
137-
def __getstate__(self):
138-
return None
133+
def __reduce__(self):
134+
return (type(self), (self._id,))
139135

140136
def _set_unbound(self, op, items=None):
141137
assert not hasattr(self, '_unbound')

Lib/html/parser.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
starttagopen = re.compile('<[a-zA-Z]')
3030
endtagopen = re.compile('</[a-zA-Z]')
3131
piclose = re.compile('>')
32-
commentclose = re.compile(r'--\s*>')
32+
commentclose = re.compile(r'--!?>')
33+
commentabruptclose = re.compile(r'-?>')
3334
# Note:
3435
# 1) if you change tagfind/attrfind remember to update locatetagend too;
3536
# 2) if you change tagfind/attrfind and/or locatetagend the parser will
@@ -336,6 +337,21 @@ def parse_html_declaration(self, i):
336337
else:
337338
return self.parse_bogus_comment(i)
338339

340+
# Internal -- parse comment, return length or -1 if not terminated
341+
# see https://html.spec.whatwg.org/multipage/parsing.html#comment-start-state
342+
def parse_comment(self, i, report=True):
343+
rawdata = self.rawdata
344+
assert rawdata.startswith('<!--', i), 'unexpected call to parse_comment()'
345+
match = commentclose.search(rawdata, i+4)
346+
if not match:
347+
match = commentabruptclose.match(rawdata, i+4)
348+
if not match:
349+
return -1
350+
if report:
351+
j = match.start()
352+
self.handle_comment(rawdata[i+4: j])
353+
return match.end()
354+
339355
# Internal -- parse bogus comment, return length or -1 if not terminated
340356
# see https://html.spec.whatwg.org/multipage/parsing.html#bogus-comment-state
341357
def parse_bogus_comment(self, i, report=1):

Lib/test/support/channels.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,8 @@ def __eq__(self, other):
105105
return other._id == self._id
106106

107107
# for pickling:
108-
def __getnewargs__(self):
109-
return (int(self._id),)
110-
111-
# for pickling:
112-
def __getstate__(self):
113-
return None
108+
def __reduce__(self):
109+
return (type(self), (int(self._id),))
114110

115111
@property
116112
def id(self):

Lib/test/test_getpath.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,27 @@ def test_venv_posix(self):
354354
actual = getpath(ns, expected)
355355
self.assertEqual(expected, actual)
356356

357+
def test_venv_posix_without_home_key(self):
358+
ns = MockPosixNamespace(
359+
argv0="/venv/bin/python3",
360+
PREFIX="/usr",
361+
ENV_PATH="/usr/bin",
362+
)
363+
# Setup the bare minimum venv
364+
ns.add_known_xfile("/usr/bin/python3")
365+
ns.add_known_xfile("/venv/bin/python3")
366+
ns.add_known_link("/venv/bin/python3", "/usr/bin/python3")
367+
ns.add_known_file("/venv/pyvenv.cfg", [
368+
# home = key intentionally omitted
369+
])
370+
expected = dict(
371+
executable="/venv/bin/python3",
372+
prefix="/venv",
373+
base_prefix="/usr",
374+
)
375+
actual = getpath(ns, expected)
376+
self.assertEqual(expected, actual)
377+
357378
def test_venv_changed_name_posix(self):
358379
"Test a venv layout on *nix."
359380
ns = MockPosixNamespace(

Lib/test/test_htmlparser.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,45 @@ def test_comments(self):
367367
html = ("<!-- I'm a valid comment -->"
368368
'<!--me too!-->'
369369
'<!------>'
370+
'<!----->'
370371
'<!---->'
372+
# abrupt-closing-of-empty-comment
373+
'<!--->'
374+
'<!-->'
371375
'<!----I have many hyphens---->'
372376
'<!-- I have a > in the middle -->'
373-
'<!-- and I have -- in the middle! -->')
377+
'<!-- and I have -- in the middle! -->'
378+
'<!--incorrectly-closed-comment--!>'
379+
'<!----!>'
380+
'<!----!-->'
381+
'<!---- >-->'
382+
'<!---!>-->'
383+
'<!--!>-->'
384+
# nested-comment
385+
'<!-- <!-- nested --> -->'
386+
'<!--<!-->'
387+
'<!--<!--!>'
388+
)
374389
expected = [('comment', " I'm a valid comment "),
375390
('comment', 'me too!'),
376391
('comment', '--'),
392+
('comment', '-'),
393+
('comment', ''),
394+
('comment', ''),
377395
('comment', ''),
378396
('comment', '--I have many hyphens--'),
379397
('comment', ' I have a > in the middle '),
380-
('comment', ' and I have -- in the middle! ')]
398+
('comment', ' and I have -- in the middle! '),
399+
('comment', 'incorrectly-closed-comment'),
400+
('comment', ''),
401+
('comment', '--!'),
402+
('comment', '-- >'),
403+
('comment', '-!>'),
404+
('comment', '!>'),
405+
('comment', ' <!-- nested '), ('data', ' -->'),
406+
('comment', '<!'),
407+
('comment', '<!'),
408+
]
381409
self._run_check(html, expected)
382410

383411
def test_condcoms(self):

Lib/test/test_interpreters/test_api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ def test_equality(self):
412412

413413
def test_pickle(self):
414414
interp = interpreters.create()
415-
data = pickle.dumps(interp)
416-
unpickled = pickle.loads(data)
417-
self.assertEqual(unpickled, interp)
415+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
416+
with self.subTest(protocol=protocol):
417+
data = pickle.dumps(interp, protocol)
418+
unpickled = pickle.loads(data)
419+
self.assertEqual(unpickled, interp)
418420

419421

420422
class TestInterpreterIsRunning(TestBase):

Lib/test/test_interpreters/test_channels.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ def test_equality(self):
121121

122122
def test_pickle(self):
123123
ch, _ = channels.create()
124-
data = pickle.dumps(ch)
125-
unpickled = pickle.loads(data)
126-
self.assertEqual(unpickled, ch)
124+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
125+
with self.subTest(protocol=protocol):
126+
data = pickle.dumps(ch, protocol)
127+
unpickled = pickle.loads(data)
128+
self.assertEqual(unpickled, ch)
127129

128130

129131
class TestSendChannelAttrs(TestBase):
@@ -152,9 +154,11 @@ def test_equality(self):
152154

153155
def test_pickle(self):
154156
_, ch = channels.create()
155-
data = pickle.dumps(ch)
156-
unpickled = pickle.loads(data)
157-
self.assertEqual(unpickled, ch)
157+
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
158+
with self.subTest(protocol=protocol):
159+
data = pickle.dumps(ch, protocol)
160+
unpickled = pickle.loads(data)
161+
self.assertEqual(unpickled, ch)
158162

159163

160164
class TestSendRecv(TestBase):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy