Skip to content

Commit bf1c52f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into conditional_jump_only_forward
2 parents 5c983d8 + 9c197bc commit bf1c52f

File tree

6 files changed

+641
-551
lines changed

6 files changed

+641
-551
lines changed

Lib/inspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,9 @@ def getsourcefile(object):
946946
elif any(filename.endswith(s) for s in
947947
importlib.machinery.EXTENSION_SUFFIXES):
948948
return None
949+
# return a filename found in the linecache even if it doesn't exist on disk
950+
if filename in linecache.cache:
951+
return filename
949952
if os.path.exists(filename):
950953
return filename
951954
# only return a non-existent filename if the module has a PEP 302 loader
@@ -954,9 +957,6 @@ def getsourcefile(object):
954957
return filename
955958
elif getattr(getattr(module, "__spec__", None), "loader", None) is not None:
956959
return filename
957-
# or it is in the linecache
958-
elif filename in linecache.cache:
959-
return filename
960960

961961
def getabsfile(object, _filename=None):
962962
"""Return an absolute path to the source or compiled file for an object.

Lib/test/test_coroutines.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pickle
55
import sys
66
import types
7+
import traceback
78
import unittest
89
import warnings
910
from test import support
@@ -2207,6 +2208,29 @@ async def f():
22072208
with self.assertWarns(RuntimeWarning):
22082209
gen.cr_frame.clear()
22092210

2211+
def test_stack_in_coroutine_throw(self):
2212+
# Regression test for https://github.com/python/cpython/issues/93592
2213+
async def a():
2214+
return await b()
2215+
2216+
async def b():
2217+
return await c()
2218+
2219+
@types.coroutine
2220+
def c():
2221+
try:
2222+
# traceback.print_stack()
2223+
yield len(traceback.extract_stack())
2224+
except ZeroDivisionError:
2225+
# traceback.print_stack()
2226+
yield len(traceback.extract_stack())
2227+
2228+
coro = a()
2229+
len_send = coro.send(None)
2230+
len_throw = coro.throw(ZeroDivisionError)
2231+
# before fixing, visible stack from throw would be shorter than from send.
2232+
self.assertEqual(len_send, len_throw)
2233+
22102234

22112235
@unittest.skipIf(
22122236
support.is_emscripten or support.is_wasi,

Lib/test/test_unicodedata.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
7171

7272
# Update this if the database changes. Make sure to do a full rebuild
7373
# (e.g. 'make distclean && make') to get the correct checksum.
74-
expectedchecksum = '98d602e1f69d5c5bb8a5910c40bbbad4e18e8370'
74+
expectedchecksum = '4975f3ec0acd4a62465d18c9bf8519b1964181f6'
7575

7676
@requires_resource('cpu')
7777
def test_function_checksum(self):
@@ -90,6 +90,7 @@ def test_function_checksum(self):
9090
self.db.decomposition(char),
9191
str(self.db.mirrored(char)),
9292
str(self.db.combining(char)),
93+
unicodedata.east_asian_width(char),
9394
]
9495
h.update(''.join(data).encode("ascii"))
9596
result = h.hexdigest()
@@ -220,6 +221,23 @@ def test_east_asian_width(self):
220221
self.assertEqual(eaw('\u2010'), 'A')
221222
self.assertEqual(eaw('\U00020000'), 'W')
222223

224+
def test_east_asian_width_unassigned(self):
225+
eaw = self.db.east_asian_width
226+
# unassigned
227+
for char in '\u0530\u0ece\u10c6\u20fc\uaaca\U000107bd\U000115f2':
228+
self.assertEqual(eaw(char), 'N')
229+
self.assertIs(self.db.name(char, None), None)
230+
231+
# unassigned but reserved for CJK
232+
for char in '\uFA6E\uFADA\U0002A6E0\U0002FA20\U0003134B\U0003FFFD':
233+
self.assertEqual(eaw(char), 'W')
234+
self.assertIs(self.db.name(char, None), None)
235+
236+
# private use areas
237+
for char in '\uE000\uF800\U000F0000\U000FFFEE\U00100000\U0010FFF0':
238+
self.assertEqual(eaw(char), 'A')
239+
self.assertIs(self.db.name(char, None), None)
240+
223241
def test_east_asian_width_9_0_changes(self):
224242
self.assertEqual(self.db.ucd_3_2_0.east_asian_width('\u231a'), 'N')
225243
self.assertEqual(self.db.east_asian_width('\u231a'), 'W')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a bug in ``unicodedata``: ``east_asian_width`` used to return the wrong
2+
value for unassigned characters; and for yet unassigned, but reserved
3+
characters.

0 commit comments

Comments
 (0)