Skip to content

Commit f33126b

Browse files
Merge branch 'python:main' into fix-issue-using-ipmodule
2 parents 48c565f + 1c0a9c5 commit f33126b

13 files changed

+43
-13
lines changed

Doc/library/asyncio-eventloop.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ Server objects are created by :meth:`loop.create_server`,
15711571
:meth:`loop.create_unix_server`, :func:`start_server`,
15721572
and :func:`start_unix_server` functions.
15731573

1574-
Do not instantiate the class directly.
1574+
Do not instantiate the :class:`Server` class directly.
15751575

15761576
.. class:: Server
15771577

@@ -1662,7 +1662,8 @@ Do not instantiate the class directly.
16621662

16631663
.. attribute:: sockets
16641664

1665-
List of :class:`socket.socket` objects the server is listening on.
1665+
List of socket-like objects, ``asyncio.trsock.TransportSocket``, which
1666+
the server is listening on.
16661667

16671668
.. versionchanged:: 3.7
16681669
Prior to Python 3.7 ``Server.sockets`` used to return an

Lib/ensurepip/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
__all__ = ["version", "bootstrap"]
1212
_PACKAGE_NAMES = ('pip',)
13-
_PIP_VERSION = "23.1.1"
13+
_PIP_VERSION = "23.1.2"
1414
_PROJECTS = [
1515
("pip", _PIP_VERSION, "py3"),
1616
]

Lib/locale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ def getpreferredencoding(do_setlocale=True):
962962
'c.ascii': 'C',
963963
'c.en': 'C',
964964
'c.iso88591': 'en_US.ISO8859-1',
965-
'c.utf8': 'en_US.UTF-8',
965+
'c.utf8': 'C.UTF-8',
966966
'c_c': 'C',
967967
'c_c.c': 'C',
968968
'ca': 'ca_ES.ISO8859-1',

Lib/pdb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def namespace(self):
154154

155155
@property
156156
def code(self):
157-
with io.open(self) as fp:
157+
with io.open_code(self) as fp:
158158
return f"exec(compile({fp.read()!r}, {self!r}, 'exec'))"
159159

160160

Lib/test/test_dis.py

+8
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,14 @@ def test_findlabels(self):
19351935

19361936
self.assertEqual(sorted(labels), sorted(jumps))
19371937

1938+
def test_findlinestarts(self):
1939+
def func():
1940+
pass
1941+
1942+
code = func.__code__
1943+
offsets = [linestart[0] for linestart in dis.findlinestarts(code)]
1944+
self.assertEqual(offsets, [0, 2])
1945+
19381946

19391947
class TestDisTraceback(DisTestBase):
19401948
def setUp(self) -> None:

Lib/test/test_pdb.py

+6
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,12 @@ def _create_fake_frozen_module():
23962396
# verify that pdb found the source of the "frozen" function
23972397
self.assertIn('x = "Sentinel string for gh-93696"', stdout, "Sentinel statement not found")
23982398

2399+
def test_non_utf8_encoding(self):
2400+
script_dir = os.path.join(os.path.dirname(__file__), 'encoded_modules')
2401+
for filename in os.listdir(script_dir):
2402+
if filename.endswith(".py"):
2403+
self._run_pdb([os.path.join(script_dir, filename)], 'q')
2404+
23992405
class ChecklineTests(unittest.TestCase):
24002406
def setUp(self):
24012407
linecache.clearcache() # Pdb.checkline() uses linecache.getline()

Lib/test/test_urllib2.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -524,16 +524,17 @@ def http_open(self, req):
524524
return MockResponse(200, "OK", msg, "", req.get_full_url())
525525

526526

527-
class MockHTTPSHandler(urllib.request.HTTPSHandler):
528-
# Useful for testing the Proxy-Authorization request by verifying the
529-
# properties of httpcon
527+
if hasattr(http.client, 'HTTPSConnection'):
528+
class MockHTTPSHandler(urllib.request.HTTPSHandler):
529+
# Useful for testing the Proxy-Authorization request by verifying the
530+
# properties of httpcon
530531

531-
def __init__(self, debuglevel=None, context=None, check_hostname=None):
532-
super(MockHTTPSHandler, self).__init__(debuglevel, context, check_hostname)
533-
self.httpconn = MockHTTPClass()
532+
def __init__(self, debuglevel=None, context=None, check_hostname=None):
533+
super(MockHTTPSHandler, self).__init__(debuglevel, context, check_hostname)
534+
self.httpconn = MockHTTPClass()
534535

535-
def https_open(self, req):
536-
return self.do_open(self.httpconn, req)
536+
def https_open(self, req):
537+
return self.do_open(self.httpconn, req)
537538

538539

539540
class MockHTTPHandlerCheckAuth(urllib.request.BaseHandler):
@@ -1075,6 +1076,7 @@ def test_http_handler_local_debuglevel(self):
10751076
o.open("http://www.example.com")
10761077
self.assertEqual(h._debuglevel, 5)
10771078

1079+
@unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.')
10781080
def test_https_handler_global_debuglevel(self):
10791081
with mock.patch.object(http.client.HTTPSConnection, 'debuglevel', 7):
10801082
o = OpenerDirector()
@@ -1083,6 +1085,7 @@ def test_https_handler_global_debuglevel(self):
10831085
o.open("https://www.example.com")
10841086
self.assertEqual(h._debuglevel, 7)
10851087

1088+
@unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.')
10861089
def test_https_handler_local_debuglevel(self):
10871090
o = OpenerDirector()
10881091
h = MockHTTPSHandler(debuglevel=4)
@@ -1456,6 +1459,7 @@ def test_proxy_https(self):
14561459
self.assertEqual([(handlers[0], "https_open")],
14571460
[tup[0:2] for tup in o.calls])
14581461

1462+
@unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.')
14591463
def test_proxy_https_proxy_authorization(self):
14601464
o = OpenerDirector()
14611465
ph = urllib.request.ProxyHandler(dict(https='proxy.example.com:3128'))

Misc/ACKS

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ Dave Chambers
299299
Pascal Chambon
300300
Nicholas Chammas
301301
Ofey Chan
302+
Juhi Chandalia
302303
John Chandler
303304
Hye-Shik Chang
304305
Jeffrey Chang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a bug where :mod:`pdb` crashes when reading source file with different encoding by replacing :func:`io.open` with :func:`io.open_code`. The new method would also call into the hook set by :func:`PyFile_SetOpenCodeHook`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The C.UTF-8 locale is no longer converted to en_US.UTF-8, enabling the use
2+
of UTF-8 encoding on systems which have no locales installed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update the bundled copy of pip to version 23.1.2.

Tools/build/deepfreeze.py

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ def generate_unicode(self, name: str, s: str) -> str:
175175
return f"&_Py_STR({strings[s]})"
176176
if s in identifiers:
177177
return f"&_Py_ID({s})"
178+
if len(s) == 1:
179+
c = ord(s)
180+
if c < 128:
181+
return f"(PyObject *)&_Py_SINGLETON(strings).ascii[{c}]"
182+
elif c < 256:
183+
return f"(PyObject *)&_Py_SINGLETON(strings).latin1[{c - 128}]"
178184
if re.match(r'\A[A-Za-z0-9_]+\Z', s):
179185
name = f"const_str_{s}"
180186
kind, ascii = analyze_character_width(s)

0 commit comments

Comments
 (0)