Skip to content

Commit f4cc6bb

Browse files
Merge branch 'main' into issue-140373-gen-unwind
2 parents 339346a + 75a1cbd commit f4cc6bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+629
-313
lines changed

Doc/library/logging.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,12 +1082,13 @@ LoggerAdapter Objects
10821082
information into logging calls. For a usage example, see the section on
10831083
:ref:`adding contextual information to your logging output <context-info>`.
10841084

1085-
.. class:: LoggerAdapter(logger, extra, merge_extra=False)
1085+
.. class:: LoggerAdapter(logger, extra=None, merge_extra=False)
10861086

10871087
Returns an instance of :class:`LoggerAdapter` initialized with an
1088-
underlying :class:`Logger` instance, a dict-like object (*extra*), and a
1089-
boolean (*merge_extra*) indicating whether or not the *extra* argument of
1090-
individual log calls should be merged with the :class:`LoggerAdapter` extra.
1088+
underlying :class:`Logger` instance, an optional dict-like object (*extra*),
1089+
and an optional boolean (*merge_extra*) indicating whether or not
1090+
the *extra* argument of individual log calls should be merged with
1091+
the :class:`LoggerAdapter` extra.
10911092
The default behavior is to ignore the *extra* argument of individual log
10921093
calls and only use the one of the :class:`LoggerAdapter` instance
10931094

@@ -1127,9 +1128,13 @@ information into logging calls. For a usage example, see the section on
11271128
Attribute :attr:`!manager` and method :meth:`!_log` were added, which
11281129
delegate to the underlying logger and allow adapters to be nested.
11291130

1131+
.. versionchanged:: 3.10
1132+
1133+
The *extra* argument is now optional.
1134+
11301135
.. versionchanged:: 3.13
11311136

1132-
The *merge_extra* argument was added.
1137+
The *merge_extra* parameter was added.
11331138

11341139

11351140
Thread Safety

Doc/library/unicodedata.rst

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ following functions:
3131
this module.
3232

3333

34-
.. function:: lookup(name)
34+
.. function:: lookup(name, /)
3535

3636
Look up character by name. If a character with the given name is found, return
3737
the corresponding character. If not found, :exc:`KeyError` is raised.
@@ -94,7 +94,7 @@ following functions:
9494
0.5
9595

9696

97-
.. function:: category(chr)
97+
.. function:: category(chr, /)
9898

9999
Returns the general category assigned to the character *chr* as
100100
string. General category names consist of two letters.
@@ -106,7 +106,7 @@ following functions:
106106
'Lu'
107107

108108

109-
.. function:: bidirectional(chr)
109+
.. function:: bidirectional(chr, /)
110110

111111
Returns the bidirectional class assigned to the character *chr* as
112112
string. If no such value is defined, an empty string is returned.
@@ -118,7 +118,7 @@ following functions:
118118
'AN'
119119

120120

121-
.. function:: combining(chr)
121+
.. function:: combining(chr, /)
122122

123123
Returns the canonical combining class assigned to the character *chr*
124124
as integer. Returns ``0`` if no combining class is defined.
@@ -127,14 +127,14 @@ following functions:
127127
for more information.
128128

129129

130-
.. function:: east_asian_width(chr)
130+
.. function:: east_asian_width(chr, /)
131131

132132
Returns the east asian width assigned to the character *chr* as
133133
string. For a list of widths and or more information, see the
134134
`Unicode Standard Annex #11 <https://www.unicode.org/reports/tr11/>`_.
135135

136136

137-
.. function:: mirrored(chr)
137+
.. function:: mirrored(chr, /)
138138

139139
Returns the mirrored property assigned to the character *chr* as
140140
integer. Returns ``1`` if the character has been identified as a "mirrored"
@@ -144,7 +144,37 @@ following functions:
144144
1
145145

146146

147-
.. function:: decomposition(chr)
147+
.. function:: isxidstart(chr, /)
148+
149+
Return ``True`` if *chr* is a valid identifier start per the
150+
`Unicode Standard Annex #31 <https://www.unicode.org/reports/tr31/>`_,
151+
that is, it has the ``XID_Start`` property. Return ``False`` otherwise.
152+
For example::
153+
154+
>>> unicodedata.isxidstart('S')
155+
True
156+
>>> unicodedata.isxidstart('0')
157+
False
158+
159+
.. versionadded:: next
160+
161+
162+
.. function:: isxidcontinue(chr, /)
163+
164+
Return ``True`` if *chr* is a valid identifier character per the
165+
`Unicode Standard Annex #31 <https://www.unicode.org/reports/tr31/>`_,
166+
that is, it has the ``XID_Continue`` property. Return ``False`` otherwise.
167+
For example::
168+
169+
>>> unicodedata.isxidcontinue('S')
170+
True
171+
>>> unicodedata.isxidcontinue(' ')
172+
False
173+
174+
.. versionadded:: next
175+
176+
177+
.. function:: decomposition(chr, /)
148178

149179
Returns the character decomposition mapping assigned to the character
150180
*chr* as string. An empty string is returned in case no such mapping is
@@ -154,7 +184,7 @@ following functions:
154184
'0041 0303'
155185

156186

157-
.. function:: normalize(form, unistr)
187+
.. function:: normalize(form, unistr, /)
158188

159189
Return the normal form *form* for the Unicode string *unistr*. Valid values for
160190
*form* are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
@@ -187,7 +217,7 @@ following functions:
187217
doesn't, they may not compare equal.
188218

189219

190-
.. function:: is_normalized(form, unistr)
220+
.. function:: is_normalized(form, unistr, /)
191221

192222
Return whether the Unicode string *unistr* is in the normal form *form*. Valid
193223
values for *form* are 'NFC', 'NFKC', 'NFD', and 'NFKD'.

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@ unicodedata
794794

795795
* The Unicode database has been updated to Unicode 17.0.0.
796796

797+
* Add :func:`unicodedata.isxidstart` and :func:`unicodedata.isxidcontinue`
798+
functions to check whether a character can start or continue a
799+
`Unicode Standard Annex #31 <https://www.unicode.org/reports/tr31/>`_ identifier.
800+
(Contributed by Stan Ulbrych in :gh:`129117`.)
801+
797802

798803
wave
799804
----

Include/internal/pycore_compile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ extern int _PyAST_Preprocess(
4949
PyObject *filename,
5050
int optimize,
5151
int ff_features,
52-
int syntax_check_only);
52+
int syntax_check_only,
53+
int enable_warnings);
5354

5455

5556
typedef struct {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef Py_INTERNAL_UNICODECTYPE_H
2+
#define Py_INTERNAL_UNICODECTYPE_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
extern int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res);
12+
extern int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res);
13+
extern int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res);
14+
extern int _PyUnicode_ToFoldedFull(Py_UCS4 ch, Py_UCS4 *res);
15+
extern int _PyUnicode_IsCaseIgnorable(Py_UCS4 ch);
16+
extern int _PyUnicode_IsCased(Py_UCS4 ch);
17+
18+
// Export for 'unicodedata' shared extension.
19+
PyAPI_FUNC(int) _PyUnicode_IsXidStart(Py_UCS4 ch);
20+
PyAPI_FUNC(int) _PyUnicode_IsXidContinue(Py_UCS4 ch);
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
#endif /* !Py_INTERNAL_UNICODECTYPE_H */

Include/internal/pycore_unicodeobject.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ _PyUnicodeWriter_WriteCharInline(_PyUnicodeWriter *writer, Py_UCS4 ch)
7474
return 0;
7575
}
7676

77-
78-
/* --- Characters Type APIs ----------------------------------------------- */
79-
80-
extern int _PyUnicode_IsXidStart(Py_UCS4 ch);
81-
extern int _PyUnicode_IsXidContinue(Py_UCS4 ch);
82-
extern int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res);
83-
extern int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res);
84-
extern int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res);
85-
extern int _PyUnicode_ToFoldedFull(Py_UCS4 ch, Py_UCS4 *res);
86-
extern int _PyUnicode_IsCaseIgnorable(Py_UCS4 ch);
87-
extern int _PyUnicode_IsCased(Py_UCS4 ch);
88-
8977
/* --- Unicode API -------------------------------------------------------- */
9078

9179
// Export for '_json' shared extension

Lib/logging/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,9 +1849,9 @@ class LoggerAdapter(object):
18491849

18501850
def __init__(self, logger, extra=None, merge_extra=False):
18511851
"""
1852-
Initialize the adapter with a logger and a dict-like object which
1853-
provides contextual information. This constructor signature allows
1854-
easy stacking of LoggerAdapters, if so desired.
1852+
Initialize the adapter with a logger and an optional dict-like object
1853+
which provides contextual information. This constructor signature
1854+
allows easy stacking of LoggerAdapters, if so desired.
18551855
18561856
You can effectively pass keyword arguments as shown in the
18571857
following example:
@@ -1882,8 +1882,9 @@ def process(self, msg, kwargs):
18821882
Normally, you'll only need to override this one method in a
18831883
LoggerAdapter subclass for your specific needs.
18841884
"""
1885-
if self.merge_extra and "extra" in kwargs:
1886-
kwargs["extra"] = {**self.extra, **kwargs["extra"]}
1885+
if self.merge_extra and kwargs.get("extra") is not None:
1886+
if self.extra is not None:
1887+
kwargs["extra"] = {**self.extra, **kwargs["extra"]}
18871888
else:
18881889
kwargs["extra"] = self.extra
18891890
return msg, kwargs

Lib/os.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ def reload_environ():
832832
env_data.clear()
833833
env_data.update(data)
834834

835+
__all__.append("reload_environ")
835836

836837
def getenv(key, default=None):
837838
"""Get an environment variable, return None if it doesn't exist.

Lib/test/support/socket_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ def filter_error(err):
259259
# raise OSError('socket error', msg) from msg
260260
elif len(a) >= 2 and isinstance(a[1], OSError):
261261
err = a[1]
262+
# The error can also be wrapped as __cause__:
263+
# raise URLError(f"ftp error: {exp}") from exp
264+
elif isinstance(err, urllib.error.URLError) and err.__cause__:
265+
err = err.__cause__
262266
else:
263267
break
264268
filter_error(err)

Lib/test/test_ast/test_ast.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,61 +1057,6 @@ def test_repr_large_input_crash(self):
10571057
r"Exceeds the limit \(\d+ digits\)"):
10581058
repr(ast.Constant(value=eval(source)))
10591059

1060-
def test_pep_765_warnings(self):
1061-
srcs = [
1062-
textwrap.dedent("""
1063-
def f():
1064-
try:
1065-
pass
1066-
finally:
1067-
return 42
1068-
"""),
1069-
textwrap.dedent("""
1070-
for x in y:
1071-
try:
1072-
pass
1073-
finally:
1074-
break
1075-
"""),
1076-
textwrap.dedent("""
1077-
for x in y:
1078-
try:
1079-
pass
1080-
finally:
1081-
continue
1082-
"""),
1083-
]
1084-
for src in srcs:
1085-
with self.assertWarnsRegex(SyntaxWarning, 'finally'):
1086-
ast.parse(src)
1087-
1088-
def test_pep_765_no_warnings(self):
1089-
srcs = [
1090-
textwrap.dedent("""
1091-
try:
1092-
pass
1093-
finally:
1094-
def f():
1095-
return 42
1096-
"""),
1097-
textwrap.dedent("""
1098-
try:
1099-
pass
1100-
finally:
1101-
for x in y:
1102-
break
1103-
"""),
1104-
textwrap.dedent("""
1105-
try:
1106-
pass
1107-
finally:
1108-
for x in y:
1109-
continue
1110-
"""),
1111-
]
1112-
for src in srcs:
1113-
ast.parse(src)
1114-
11151060
def test_tstring(self):
11161061
# Test AST structure for simple t-string
11171062
tree = ast.parse('t"Hello"')

0 commit comments

Comments
 (0)