diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 5138afc2bbe47b..e3dcd088be2fbd 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -1571,7 +1571,7 @@ Server objects are created by :meth:`loop.create_server`, :meth:`loop.create_unix_server`, :func:`start_server`, and :func:`start_unix_server` functions. -Do not instantiate the class directly. +Do not instantiate the :class:`Server` class directly. .. class:: Server @@ -1662,7 +1662,8 @@ Do not instantiate the class directly. .. attribute:: sockets - List of :class:`socket.socket` objects the server is listening on. + List of socket-like objects, ``asyncio.trsock.TransportSocket``, which + the server is listening on. .. versionchanged:: 3.7 Prior to Python 3.7 ``Server.sockets`` used to return an diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 4278422dfacc9f..5f4f1d75b43e64 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -10,7 +10,7 @@ __all__ = ["version", "bootstrap"] _PACKAGE_NAMES = ('pip',) -_PIP_VERSION = "23.1.1" +_PIP_VERSION = "23.1.2" _PROJECTS = [ ("pip", _PIP_VERSION, "py3"), ] diff --git a/Lib/ensurepip/_bundled/pip-23.1.1-py3-none-any.whl b/Lib/ensurepip/_bundled/pip-23.1.2-py3-none-any.whl similarity index 93% rename from Lib/ensurepip/_bundled/pip-23.1.1-py3-none-any.whl rename to Lib/ensurepip/_bundled/pip-23.1.2-py3-none-any.whl index dee4c0304b2c36..6a2515615ccda3 100644 Binary files a/Lib/ensurepip/_bundled/pip-23.1.1-py3-none-any.whl and b/Lib/ensurepip/_bundled/pip-23.1.2-py3-none-any.whl differ diff --git a/Lib/locale.py b/Lib/locale.py index 4127d917465936..e94f0d1acbaa7d 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -962,7 +962,7 @@ def getpreferredencoding(do_setlocale=True): 'c.ascii': 'C', 'c.en': 'C', 'c.iso88591': 'en_US.ISO8859-1', - 'c.utf8': 'en_US.UTF-8', + 'c.utf8': 'C.UTF-8', 'c_c': 'C', 'c_c.c': 'C', 'ca': 'ca_ES.ISO8859-1', diff --git a/Lib/pdb.py b/Lib/pdb.py index a3553b345a8dd3..645cbf518e58e3 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -154,7 +154,7 @@ def namespace(self): @property def code(self): - with io.open(self) as fp: + with io.open_code(self) as fp: return f"exec(compile({fp.read()!r}, {self!r}, 'exec'))" diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 2d5c73c9adc920..97960726991b76 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1935,6 +1935,14 @@ def test_findlabels(self): self.assertEqual(sorted(labels), sorted(jumps)) + def test_findlinestarts(self): + def func(): + pass + + code = func.__code__ + offsets = [linestart[0] for linestart in dis.findlinestarts(code)] + self.assertEqual(offsets, [0, 2]) + class TestDisTraceback(DisTestBase): def setUp(self) -> None: diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index b5c413af344c93..2f712a10257984 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2396,6 +2396,12 @@ def _create_fake_frozen_module(): # verify that pdb found the source of the "frozen" function self.assertIn('x = "Sentinel string for gh-93696"', stdout, "Sentinel statement not found") + def test_non_utf8_encoding(self): + script_dir = os.path.join(os.path.dirname(__file__), 'encoded_modules') + for filename in os.listdir(script_dir): + if filename.endswith(".py"): + self._run_pdb([os.path.join(script_dir, filename)], 'q') + class ChecklineTests(unittest.TestCase): def setUp(self): linecache.clearcache() # Pdb.checkline() uses linecache.getline() diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index b7c6f6dd8f1b99..99c9e24994732f 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -524,16 +524,17 @@ def http_open(self, req): return MockResponse(200, "OK", msg, "", req.get_full_url()) -class MockHTTPSHandler(urllib.request.HTTPSHandler): - # Useful for testing the Proxy-Authorization request by verifying the - # properties of httpcon +if hasattr(http.client, 'HTTPSConnection'): + class MockHTTPSHandler(urllib.request.HTTPSHandler): + # Useful for testing the Proxy-Authorization request by verifying the + # properties of httpcon - def __init__(self, debuglevel=None, context=None, check_hostname=None): - super(MockHTTPSHandler, self).__init__(debuglevel, context, check_hostname) - self.httpconn = MockHTTPClass() + def __init__(self, debuglevel=None, context=None, check_hostname=None): + super(MockHTTPSHandler, self).__init__(debuglevel, context, check_hostname) + self.httpconn = MockHTTPClass() - def https_open(self, req): - return self.do_open(self.httpconn, req) + def https_open(self, req): + return self.do_open(self.httpconn, req) class MockHTTPHandlerCheckAuth(urllib.request.BaseHandler): @@ -1075,6 +1076,7 @@ def test_http_handler_local_debuglevel(self): o.open("http://www.example.com") self.assertEqual(h._debuglevel, 5) + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') def test_https_handler_global_debuglevel(self): with mock.patch.object(http.client.HTTPSConnection, 'debuglevel', 7): o = OpenerDirector() @@ -1083,6 +1085,7 @@ def test_https_handler_global_debuglevel(self): o.open("https://www.example.com") self.assertEqual(h._debuglevel, 7) + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') def test_https_handler_local_debuglevel(self): o = OpenerDirector() h = MockHTTPSHandler(debuglevel=4) @@ -1456,6 +1459,7 @@ def test_proxy_https(self): self.assertEqual([(handlers[0], "https_open")], [tup[0:2] for tup in o.calls]) + @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.') def test_proxy_https_proxy_authorization(self): o = OpenerDirector() ph = urllib.request.ProxyHandler(dict(https='proxy.example.com:3128')) diff --git a/Misc/ACKS b/Misc/ACKS index 633e9d90a36f16..19475698a4bc37 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -299,6 +299,7 @@ Dave Chambers Pascal Chambon Nicholas Chammas Ofey Chan +Juhi Chandalia John Chandler Hye-Shik Chang Jeffrey Chang diff --git a/Misc/NEWS.d/next/Library/2023-04-16-18-29-04.gh-issue-103578.fly1wc.rst b/Misc/NEWS.d/next/Library/2023-04-16-18-29-04.gh-issue-103578.fly1wc.rst new file mode 100644 index 00000000000000..69986c2a15b39e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-04-16-18-29-04.gh-issue-103578.fly1wc.rst @@ -0,0 +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`. diff --git a/Misc/NEWS.d/next/Library/2023-04-25-22-06-00.gh-issue-74940.TOacQ9.rst b/Misc/NEWS.d/next/Library/2023-04-25-22-06-00.gh-issue-74940.TOacQ9.rst new file mode 100644 index 00000000000000..c37d795f3eb33d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-04-25-22-06-00.gh-issue-74940.TOacQ9.rst @@ -0,0 +1,2 @@ +The C.UTF-8 locale is no longer converted to en_US.UTF-8, enabling the use +of UTF-8 encoding on systems which have no locales installed. diff --git a/Misc/NEWS.d/next/Library/2023-04-26-09-38-47.gh-issue-103872.8LBsDz.rst b/Misc/NEWS.d/next/Library/2023-04-26-09-38-47.gh-issue-103872.8LBsDz.rst new file mode 100644 index 00000000000000..b840f9f5769f08 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-04-26-09-38-47.gh-issue-103872.8LBsDz.rst @@ -0,0 +1 @@ +Update the bundled copy of pip to version 23.1.2. diff --git a/Python/specialize.c b/Python/specialize.c index 9230087a78beac..33a3c4561c7ca2 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -544,8 +544,10 @@ _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *class, PyObject * write_u32(cache->self_type_version, Py_TYPE(self)->tp_version_tag); write_obj(cache->method, res); // borrowed instr->op.code = LOAD_SUPER_ATTR_METHOD; + Py_DECREF(res); goto success; } + Py_DECREF(res); SPECIALIZATION_FAIL(LOAD_SUPER_ATTR, SPEC_FAIL_SUPER_NOT_METHOD); fail: diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py index 5cfef5c572c4ae..b084d3e457f782 100644 --- a/Tools/build/deepfreeze.py +++ b/Tools/build/deepfreeze.py @@ -175,6 +175,12 @@ def generate_unicode(self, name: str, s: str) -> str: return f"&_Py_STR({strings[s]})" if s in identifiers: return f"&_Py_ID({s})" + if len(s) == 1: + c = ord(s) + if c < 128: + return f"(PyObject *)&_Py_SINGLETON(strings).ascii[{c}]" + elif c < 256: + return f"(PyObject *)&_Py_SINGLETON(strings).latin1[{c - 128}]" if re.match(r'\A[A-Za-z0-9_]+\Z', s): name = f"const_str_{s}" kind, ascii = analyze_character_width(s)