Skip to content

Commit

Permalink
Merge branch 'main' into supermon
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Apr 26, 2023
2 parents 862c3dc + 6c4124d commit d3470cd
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))"


Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 12 additions & 8 deletions Lib/test/test_urllib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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'))
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ Dave Chambers
Pascal Chambon
Nicholas Chammas
Ofey Chan
Juhi Chandalia
John Chandler
Hye-Shik Chang
Jeffrey Chang
Expand Down
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the bundled copy of pip to version 23.1.2.
2 changes: 2 additions & 0 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions Tools/build/deepfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d3470cd

Please sign in to comment.