Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(filter)
STRUCT_FOR_ID(filters)
STRUCT_FOR_ID(final)
STRUCT_FOR_ID(finalizer)
STRUCT_FOR_ID(find_class)
STRUCT_FOR_ID(firstiter)
STRUCT_FOR_ID(fix_imports)
STRUCT_FOR_ID(flags)
STRUCT_FOR_ID(flush)
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,7 @@ def test_cli_converters(self):
"DWORD",
"fildes",
"float",
"gid_t",
"HANDLE",
"int",
"long",
Expand All @@ -4032,6 +4033,7 @@ def test_cli_converters(self):
"size_t",
"slice_index",
"str",
"uid_t",
"uint16",
"uint32",
"uint64",
Expand Down
50 changes: 29 additions & 21 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ def wrapped(self, *args, **kwargs):

WIDE_BUILD = import_module('_curses')._wide_character_support

def encodable(s, encoding):
# Wide characters are only supported in a locale that can encode them.
try:
s.encode(encoding)
except UnicodeEncodeError:
return False
return True

def storable(s, encoding):
# Text the current build can place in character cells. A wide build
# stores any locale-encodable text (combining sequences and multibyte
# characters included). A narrow build has no wide-character cells, so
# each character must occupy a single cell -- that is, encode to exactly
# one byte.
if not encodable(s, encoding):
return False
if WIDE_BUILD:
return True
return len(s.encode(encoding)) == len(s)

def requires_wide_build(test):
@functools.wraps(test)
def wrapped(self, *args, **kwargs):
Expand Down Expand Up @@ -387,24 +407,10 @@ def test_refresh_control(self):
# combining sequence or a multibyte character are guarded with _storable().

def _encodable(self, s):
# Wide characters are only supported in a locale that can encode them.
try:
s.encode(self.stdscr.encoding)
except UnicodeEncodeError:
return False
return True
return encodable(s, self.stdscr.encoding)

def _storable(self, s):
# Text the current build can place in character cells. A wide build
# stores any locale-encodable text (combining sequences and multibyte
# characters included). A narrow build has no wide-character cells, so
# each character must occupy a single cell -- that is, encode to exactly
# one byte.
if not self._encodable(s):
return False
if WIDE_BUILD:
return True
return len(s.encode(self.stdscr.encoding)) == len(s)
return storable(s, self.stdscr.encoding)

def _char_code(self, ch):
# The integer the int-input API (addch(int), do_command()) uses for a
Expand Down Expand Up @@ -1124,7 +1130,11 @@ def test_cell_null_char(self):
# A cell holding a NUL reads back as the cell that writes it.
win = curses.newwin(3, 8, 0, 0)
win.insch(0, 0, '\0')
self.assertEqual(win.in_wch(0, 0), cell)
if WIDE_BUILD:
self.assertEqual(win.in_wch(0, 0), cell)
else:
# A narrow build inserts a NUL as "^@".
self.assertEqual(str(win.in_wch(0, 0)), '^')
# A string of cells cannot hold a NUL: it would end a batch write.
self.assertRaises(ValueError, curses.complexstr, 'a\0b')
self.assertRaises(ValueError, curses.complexstr, '\0')
Expand Down Expand Up @@ -3593,10 +3603,8 @@ def test_set_and_label(self):
def test_set_wide(self):
screen = self.make_slk_screen()
label = 'Ångström'
try:
label.encode(screen.stdscr.encoding)
except UnicodeEncodeError:
self.skipTest('the locale cannot encode %r' % label)
if not storable(label, screen.stdscr.encoding):
self.skipTest('cannot store %r in this locale' % label)
curses.slk_set(1, label, 0)
# The label can be truncated to fit the soft label width, e.g. in the
# EUC-JP locale, where "Å" and "ö" are double-width JIS X 0212
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -6170,11 +6170,10 @@ def test_builtins_have_signatures(self):
no_signature = {'type', 'super', 'bytearray', 'bytes',
'dict', 'frozendict', 'int', 'str'}
# These need PEP 457 groups
needs_groups = {"range", "slice", "dir", "getattr",
"next", "vars"}
needs_groups = {"range", "slice", "getattr", "next"}
no_signature |= needs_groups
# These have unrepresentable parameter default values of NULL
unsupported_signature = {"aiter", "iter"}
unsupported_signature = {"aiter", "iter", "dir", "vars"}
# These need *args support in Argument Clinic
needs_varargs = {"min", "max", "__build_class__"}
no_signature |= needs_varargs
Expand Down Expand Up @@ -6207,10 +6206,12 @@ def test_types_module_has_signatures(self):
methods_no_signature=methods_no_signature)

def test_sys_module_has_signatures(self):
no_signature = {'getsizeof', 'set_asyncgen_hooks'}
no_signature |= {name for name in ['getobjects']
if hasattr(sys, name)}
self._test_module_has_signatures(sys, no_signature)
no_signature = {name for name in ['getobjects']
if hasattr(sys, name)}
# The C default is NULL and None has other meaning
unsupported_signature = {'getsizeof', 'set_asyncgen_hooks'}
self._test_module_has_signatures(sys, no_signature,
unsupported_signature)

def test_abc_module_has_signatures(self):
import abc
Expand Down Expand Up @@ -6313,7 +6314,6 @@ def test_pwd_module_has_signatures(self):
def test_re_module_has_signatures(self):
import re
methods_no_signature = {
'Match': {'group'},
'Pattern': {'match'}, # It is now an alias for prefixmatch
}
self._test_module_has_signatures(re,
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_property_set_name_incorrect_args(self):
for i in (0, 1, 3):
with self.assertRaisesRegex(
TypeError,
fr'^__set_name__\(\) takes 2 positional arguments but {i} were given$'
fr'^__set_name__ expected 2 arguments?, got {i}$'
):
p.__set_name__(*([0] * i))

Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_pwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def test_errors(self):
self.assertRaises(TypeError, pwd.getpwuid, 0.0)
self.assertRaises(TypeError, pwd.getpwuid, 0, 0)
# should be out of uid_t range
self.assertRaises(KeyError, pwd.getpwuid, 2**128)
self.assertRaises(KeyError, pwd.getpwuid, -2**128)
self.assertRaises(OverflowError, pwd.getpwuid, 2**128)
self.assertRaises(OverflowError, pwd.getpwuid, -2**128)
self.assertRaises(TypeError, pwd.getpwnam)
self.assertRaises(TypeError, pwd.getpwnam, 42)
self.assertRaises(TypeError, pwd.getpwnam, b'root')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Revert :gh:`146064`. The linked PyMutex change was
causing a significant performance regression in some cases.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:func:`pwd.getpwuid` now raises :exc:`OverflowError` instead of
:exc:`KeyError` if the user id is out of the range of the C ``uid_t`` type,
as :func:`grp.getgrgid` does for the group id.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Argument Clinic: the ``pid_t``, ``Py_off_t``, ``HANDLE``, ``DWORD`` and
``BOOL`` converters, previously defined in 9 different files, are now
provided by Argument Clinic itself.
Argument Clinic: the ``pid_t``, ``uid_t``, ``gid_t``, ``Py_off_t``,
``HANDLE``, ``DWORD`` and ``BOOL`` converters, previously defined in
individual files, are now provided by Argument Clinic itself.
Loading
Loading