Skip to content

Commit e8fd6b8

Browse files
committed
Merge remote-tracking branch 'origin/main' into gh-152754-os-race-mutex
2 parents 4360e83 + a159c68 commit e8fd6b8

63 files changed

Lines changed: 2931 additions & 452 deletions

Some content is hidden

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

Doc/library/codecs.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,18 @@ On Windows, ``cpXXX`` codecs are available for all code pages.
10871087
But only codecs listed in the following table are guaranteed to exist on
10881088
other platforms.
10891089

1090+
On platforms that provide the C library's :manpage:`iconv(3)` function
1091+
(such as those using the GNU C Library),
1092+
every encoding known to ``iconv`` for which Python has no built-in codec
1093+
is available as well.
1094+
Such an encoding is looked up by its ``iconv`` name (for example ``cp1133``).
1095+
Prefixing the name with ``iconv:`` forces the use of the ``iconv``-based codec
1096+
even when a built-in codec of the same name exists (for example ``iconv:latin1``),
1097+
which is mostly useful for testing.
1098+
1099+
.. versionchanged:: next
1100+
Added support for encodings provided by the C library's ``iconv``.
1101+
10901102
.. impl-detail::
10911103

10921104
Some common encodings can bypass the codecs lookup machinery to

Doc/library/imaplib.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ In general, pass arguments unquoted and let the module quote them as needed.
192192
An argument that is already enclosed in double quotes is left unchanged,
193193
so that code which quotes arguments itself keeps working.
194194

195+
Mailbox names are encoded as modified UTF-7 (:rfc:`3501`, section 5.1.3),
196+
so a mailbox name containing non-ASCII characters can be passed as an
197+
ordinary :class:`str`.
198+
A :class:`str` that is already valid modified UTF-7 is left unchanged,
199+
so that a name obtained from :meth:`~IMAP4.list` (raw ``bytes`` decoded to
200+
text) round-trips; pass :class:`bytes` to send the exact bytes with no
201+
encoding.
202+
When ``UTF8=ACCEPT`` is enabled (see :meth:`~IMAP4.enable`), mailbox names
203+
are sent as UTF-8 instead.
204+
205+
.. versionchanged:: next
206+
Non-ASCII mailbox names are automatically encoded as modified UTF-7.
207+
195208
Most commands return a tuple: ``(type, [data, ...])`` where *type* is usually
196209
``'OK'`` or ``'NO'``, and *data* is either the text from the command response,
197210
or mandated results from the command. Each *data* is either a ``bytes``, or a

Doc/library/locale.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ The :mod:`!locale` module defines the following exception and functions:
342342
.. versionchanged:: 3.14
343343
The function now temporarily sets the ``LC_CTYPE`` locale in some cases.
344344

345+
.. versionchanged:: next
346+
On glibc, the ``LC_TIME`` items (except ``ERA``) are now decoded
347+
independently of the ``LC_CTYPE`` encoding.
348+
345349

346350
.. function:: getdefaultlocale([envvars])
347351

Doc/library/tkinter.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ Base and mixin classes
20662066

20672067
.. method:: winfo_exists()
20682068

2069-
Return ``1`` if the widget exists, ``0`` otherwise.
2069+
Return ``True`` if the widget exists, ``False`` otherwise.
20702070

20712071
.. method:: winfo_fpixels(number)
20722072

@@ -2115,7 +2115,7 @@ Base and mixin classes
21152115

21162116
.. method:: winfo_ismapped()
21172117

2118-
Return ``1`` if the widget is currently mapped, ``0`` otherwise.
2118+
Return ``True`` if the widget is currently mapped, ``False`` otherwise.
21192119

21202120
.. method:: winfo_manager()
21212121

@@ -2246,8 +2246,8 @@ Base and mixin classes
22462246

22472247
.. method:: winfo_viewable()
22482248

2249-
Return ``1`` if the widget and all of its ancestors up through the
2250-
nearest toplevel window are mapped, ``0`` otherwise.
2249+
Return ``True`` if the widget and all of its ancestors up through the
2250+
nearest toplevel window are mapped, ``False`` otherwise.
22512251

22522252
.. method:: winfo_visual()
22532253

@@ -5737,7 +5737,7 @@ Widget classes
57375737
.. method:: edit_modified(arg=None)
57385738

57395739
If *arg* is omitted, return the current state of the modified flag as
5740-
``0`` or ``1``; the flag is set automatically whenever the text is
5740+
a :class:`bool`; the flag is set automatically whenever the text is
57415741
inserted or deleted.
57425742
Otherwise set the flag to the boolean *arg*.
57435743

Doc/library/tkinter.ttk.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ ttk.Treeview
13721372
Without arguments, returns a tuple of all detached items,
13731373
but not their descendants (see :meth:`detached_all`).
13741374
With *item*, returns whether *item* is detached; since Tk 9.1, also
1375-
returns true if an ancestor of *item* is detached.
1375+
returns ``True`` if an ancestor of *item* is detached.
13761376

13771377
Requires Tk 9.0 or newer.
13781378

Doc/library/urllib.parse.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,9 @@ task isn't already covered by the URL parsing functions above.
649649

650650
The optional *encoding* and *errors* parameters specify how to deal with
651651
non-ASCII characters, as accepted by the :meth:`str.encode` method.
652-
*encoding* defaults to ``'utf-8'``.
653-
*errors* defaults to ``'strict'``, meaning unsupported characters raise a
652+
Although these parameters default to ``None`` in the function signature,
653+
when processing :class:`str` inputs, *encoding* effectively defaults to ``'utf-8'``
654+
and *errors* to ``'strict'``, meaning unsupported characters raise a
654655
:class:`UnicodeEncodeError`.
655656
*encoding* and *errors* must not be supplied if *string* is a
656657
:class:`bytes`, or a :class:`TypeError` is raised.

Doc/whatsnew/3.16.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ New modules
8686
Improved modules
8787
================
8888

89+
codecs
90+
------
91+
92+
* On platforms that provide the C library's :manpage:`iconv(3)` function,
93+
every encoding known to ``iconv`` for which Python has no built-in codec
94+
is now available (for example ``cp1133``).
95+
Prefixing an encoding name with ``iconv:`` forces the ``iconv``-based codec
96+
even when a built-in codec of the same name exists.
97+
(Contributed by Serhiy Storchaka in :gh:`152997`.)
98+
8999
curses
90100
------
91101

@@ -252,6 +262,11 @@ imaplib
252262
user names and passwords.
253263
(Contributed by Przemysław Buczkowski and Serhiy Storchaka in :gh:`89869`.)
254264

265+
* Non-ASCII mailbox names are now automatically encoded as modified UTF-7
266+
(:rfc:`3501`, section 5.1.3), so international mailbox names can be passed
267+
as ordinary :class:`str`.
268+
(Contributed by Serhiy Storchaka in :gh:`49555`.)
269+
255270

256271
ipaddress
257272
---------

Include/internal/pycore_pylifecycle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ extern int _Py_LegacyLocaleDetected(int warn);
108108
// Export for 'readline' shared extension
109109
PyAPI_FUNC(char*) _Py_SetLocaleFromEnv(int category);
110110

111-
// Export for special main.c string compiling with source tracebacks
112-
int _PyRun_SimpleStringFlagsWithName(const char *command, const char* name, PyCompilerFlags *flags);
113-
114111

115112
/* interpreter config */
116113

Include/internal/pycore_pythonrun.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
extern int _PyRun_SimpleFileObject(
11+
extern PyObject* _PyRun_SimpleFile(
1212
FILE *fp,
1313
PyObject *filename,
1414
int closeit,
1515
PyCompilerFlags *flags);
1616

17-
extern int _PyRun_AnyFileObject(
17+
extern PyObject* _PyRun_AnyFile(
1818
FILE *fp,
1919
PyObject *filename,
2020
int closeit,
2121
PyCompilerFlags *flags);
2222

23-
extern int _PyRun_InteractiveLoopObject(
24-
FILE *fp,
25-
PyObject *filename,
26-
PyCompilerFlags *flags);
27-
2823
extern int _PyObject_SupportedAsScript(PyObject *);
2924
extern const char* _Py_SourceAsString(
3025
PyObject *cmd,
@@ -39,6 +34,12 @@ extern PyObject * _Py_CompileStringObjectWithModule(
3934
PyCompilerFlags *flags, int optimize,
4035
PyObject *module);
4136

37+
// Export for special main.c string compiling with source tracebacks
38+
extern PyObject* _PyRun_SimpleString(
39+
const char *command,
40+
PyObject* name,
41+
PyCompilerFlags *flags);
42+
4243

4344
/* Stack size, in "pointers". This must be large enough, so
4445
* no two calls to check recursion depth are more than this far

Include/internal/pycore_unicodeobject.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,22 @@ extern int _PyUnicodeWriter_FormatV(
182182
const char *format,
183183
va_list vargs);
184184

185+
/* --- iconv Codec -------------------------------------------------------- */
186+
187+
#ifdef HAVE_ICONV
188+
extern PyObject* _PyUnicode_DecodeIconv(
189+
const char *encoding, /* iconv encoding name */
190+
const char *string, /* encoded string */
191+
Py_ssize_t length, /* size of string */
192+
const char *errors, /* error handling */
193+
Py_ssize_t *consumed); /* bytes consumed, or NULL for non-stateful */
194+
195+
extern PyObject* _PyUnicode_EncodeIconv(
196+
const char *encoding, /* iconv encoding name */
197+
PyObject *unicode, /* Unicode object */
198+
const char *errors); /* error handling */
199+
#endif
200+
185201
/* --- UTF-7 Codecs ------------------------------------------------------- */
186202

187203
extern PyObject* _PyUnicode_EncodeUTF7(

0 commit comments

Comments
 (0)