Skip to content

Commit 51834da

Browse files
Merge branch 'main' into fix-kw_defaults-asdl
2 parents 41094eb + 4274b47 commit 51834da

File tree

13 files changed

+97
-152
lines changed

13 files changed

+97
-152
lines changed

Doc/c-api/unicode.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,17 @@ APIs:
645645
difference being that it decrements the reference count of *right* by one.
646646
647647
648+
.. c:function:: PyObject* PyUnicode_BuildEncodingMap(PyObject* string)
649+
650+
Return a mapping suitable for decoding a custom single-byte encoding.
651+
Given a Unicode string *string* of up to 256 characters representing an encoding
652+
table, returns either a compact internal mapping object or a dictionary
653+
mapping character ordinals to byte values. Raises a :exc:`TypeError` and
654+
return ``NULL`` on invalid input.
655+
656+
.. versionadded:: 3.2
657+
658+
648659
.. c:function:: const char* PyUnicode_GetDefaultEncoding(void)
649660
650661
Return the name of the default string encoding, ``"utf-8"``.

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,6 +2778,9 @@ PyUnicode_AppendAndDel:void:::
27782778
PyUnicode_AppendAndDel:PyObject**:p_left:0:
27792779
PyUnicode_AppendAndDel:PyObject*:right:-1:
27802780

2781+
PyUnicode_BuildEncodingMap:PyObject*::+1:
2782+
PyUnicode_BuildEncodingMap:PyObject*:string:::
2783+
27812784
PyUnicode_GetDefaultEncoding:const char*:::
27822785
PyUnicode_GetDefaultEncoding::void::
27832786

Doc/data/stable_abi.dat

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.14.rst

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ As another example, generating HTML attributes from data:
153153
.. code-block:: python
154154
155155
attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
156-
template = t"<img {attributes} />"
157-
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice" />'
156+
template = t"<img {attributes}>"
157+
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice">'
158158
159-
Unlike f-strings, the ``html`` function has access to template attributes
159+
Compared to using an f-string, the ``html`` function has access to template attributes
160160
containing the original information: static strings, interpolations, and values
161161
from the original scope. Unlike existing templating approaches, t-strings build
162162
from the well-known f-string syntax and rules. Template systems thus benefit
@@ -443,6 +443,9 @@ Python without deferred evaluation of annotations, reaches its end of life in 20
443443
In Python 3.14, the behavior of code using ``from __future__ import annotations``
444444
is unchanged.
445445

446+
.. seealso::
447+
:pep:`649`.
448+
446449

447450
Improved error messages
448451
-----------------------
@@ -584,8 +587,27 @@ Improved error messages
584587
^^^^^^
585588
SyntaxError: cannot use subscript as import target
586589
587-
.. seealso::
588-
:pep:`649`.
590+
* Improved error message when trying to add an instance of an unhashable type to
591+
a :class:`dict` or :class:`set`. (Contributed by CF Bolz-Tereick and Victor Stinner
592+
in :gh:`132828`.)
593+
594+
.. code-block:: pycon
595+
596+
>>> s = set()
597+
>>> s.add({'pages': 12, 'grade': 'A'})
598+
Traceback (most recent call last):
599+
File "<python-input-1>", line 1, in <module>
600+
s.add({'pages': 12, 'grade': 'A'})
601+
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
602+
TypeError: cannot use 'dict' as a set element (unhashable type: 'dict')
603+
>>> d = {}
604+
>>> l = [1, 2, 3]
605+
>>> d[l] = 12
606+
Traceback (most recent call last):
607+
File "<python-input-4>", line 1, in <module>
608+
d[l] = 12
609+
~^^^
610+
TypeError: cannot use 'list' as a dict key (unhashable type: 'list')
589611
590612
591613
.. _whatsnew314-pep741:

Doc/whatsnew/3.15.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ Deprecated C APIs
167167
Removed C APIs
168168
--------------
169169

170+
* Remove deprecated ``PyUnicode`` functions:
171+
172+
* :c:func:`!PyUnicode_AsDecodedObject`:
173+
Use :c:func:`PyCodec_Decode` instead.
174+
* :c:func:`!PyUnicode_AsDecodedUnicode`:
175+
Use :c:func:`PyCodec_Decode` instead; Note that some codecs (for example, "base64")
176+
may return a type other than :class:`str`, such as :class:`bytes`.
177+
* :c:func:`!PyUnicode_AsEncodedObject`:
178+
Use :c:func:`PyCodec_Encode` instead.
179+
* :c:func:`!PyUnicode_AsEncodedUnicode`:
180+
Use :c:func:`PyCodec_Encode` instead; Note that some codecs (for example, "base64")
181+
may return a type other than :class:`bytes`, such as :class:`str`.
182+
183+
(Contributed by Stan Ulbrych in :gh:`133612`)
184+
170185
* :c:func:`!PyImport_ImportModuleNoBlock`: deprecated alias
171186
of :c:func:`PyImport_ImportModule`.
172187

Include/unicodeobject.h

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -341,49 +341,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_Decode(
341341
const char *errors /* error handling */
342342
);
343343

344-
/* Decode a Unicode object unicode and return the result as Python
345-
object.
346-
347-
This API is DEPRECATED and will be removed in 3.15.
348-
The only supported standard encoding is rot13.
349-
Use PyCodec_Decode() to decode with rot13 and non-standard codecs
350-
that decode from str. */
351-
352-
Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject(
353-
PyObject *unicode, /* Unicode object */
354-
const char *encoding, /* encoding */
355-
const char *errors /* error handling */
356-
);
357-
358-
/* Decode a Unicode object unicode and return the result as Unicode
359-
object.
360-
361-
This API is DEPRECATED and will be removed in 3.15.
362-
The only supported standard encoding is rot13.
363-
Use PyCodec_Decode() to decode with rot13 and non-standard codecs
364-
that decode from str to str. */
365-
366-
Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
367-
PyObject *unicode, /* Unicode object */
368-
const char *encoding, /* encoding */
369-
const char *errors /* error handling */
370-
);
371-
372-
/* Encodes a Unicode object and returns the result as Python
373-
object.
374-
375-
This API is DEPRECATED and will be removed in 3.15.
376-
It is superseded by PyUnicode_AsEncodedString()
377-
since all standard encodings (except rot13) encode str to bytes.
378-
Use PyCodec_Encode() for encoding with rot13 and non-standard codecs
379-
that encode form str to non-bytes. */
380-
381-
Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject(
382-
PyObject *unicode, /* Unicode object */
383-
const char *encoding, /* encoding */
384-
const char *errors /* error handling */
385-
);
386-
387344
/* Encodes a Unicode object and returns the result as Python string
388345
object. */
389346

@@ -393,20 +350,6 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString(
393350
const char *errors /* error handling */
394351
);
395352

396-
/* Encodes a Unicode object and returns the result as Unicode
397-
object.
398-
399-
This API is DEPRECATED and will be removed in 3.15.
400-
The only supported standard encodings is rot13.
401-
Use PyCodec_Encode() to encode with rot13 and non-standard codecs
402-
that encode from str to str. */
403-
404-
Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode(
405-
PyObject *unicode, /* Unicode object */
406-
const char *encoding, /* encoding */
407-
const char *errors /* error handling */
408-
);
409-
410353
/* Build an encoding map. */
411354

412355
PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap(

Lib/test/libregrtest/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
EXIT_TIMEOUT = 120.0
3232

3333

34-
ALL_RESOURCES = ('audio', 'curses', 'largefile', 'network',
34+
ALL_RESOURCES = ('audio', 'console', 'curses', 'largefile', 'network',
3535
'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui', 'walltime')
3636

3737
# Other resources excluded from --use=all:

Lib/test/support/strace_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ def get_syscalls(code, strace_flags, prelude="", cleanup="",
178178
# Moderately expensive (spawns a subprocess), so share results when possible.
179179
@cache
180180
def _can_strace():
181-
res = strace_python("import sys; sys.exit(0)", [], check=False)
181+
res = strace_python("import sys; sys.exit(0)",
182+
# --trace option needs strace 5.5 (gh-133741)
183+
["--trace=%process"],
184+
check=False)
182185
if res.strace_returncode == 0 and res.python_returncode == 0:
183186
assert res.events(), "Should have parsed multiple calls"
184187
return True

Lib/test/test_embed.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def test_pre_initialization_api(self):
296296
if MS_WINDOWS:
297297
expected_path = self.test_exe
298298
else:
299-
expected_path = os.path.join(os.getcwd(), "spam")
299+
expected_path = os.path.join(os.getcwd(), "_testembed")
300300
expected_output = f"sys.executable: {expected_path}\n"
301301
self.assertIn(expected_output, out)
302302
self.assertEqual(err, '')
@@ -969,7 +969,6 @@ def test_init_global_config(self):
969969
'utf8_mode': True,
970970
}
971971
config = {
972-
'program_name': './globalvar',
973972
'site_import': False,
974973
'bytes_warning': True,
975974
'warnoptions': ['default::BytesWarning'],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove deprecated functions :c:func:`!PyUnicode_AsDecodedObject`,
2+
:c:func:`!PyUnicode_AsDecodedUnicode`, :c:func:`!PyUnicode_AsEncodedObject`,
3+
and :c:func:`!PyUnicode_AsEncodedUnicode`.

0 commit comments

Comments
 (0)