Skip to content

Commit 6980619

Browse files
Merge branch 'main' into sqlite3-fixup
2 parents 6b59a0b + 30b1d8f commit 6980619

33 files changed

+443
-516
lines changed

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/library/shutil.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ Directory and files operations
454454
:envvar:`PATH` environment variable is read from :data:`os.environ`,
455455
falling back to :data:`os.defpath` if it is not set.
456456

457+
If *cmd* contains a directory component, :func:`!which` only checks the
458+
specified path directly and does not search the directories listed in
459+
*path* or in the system's :envvar:`PATH` environment variable.
460+
457461
On Windows, the current directory is prepended to the *path* if *mode* does
458462
not include ``os.X_OK``. When the *mode* does include ``os.X_OK``, the
459463
Windows API ``NeedCurrentDirectoryForExePathW`` will be consulted to

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/internal/pycore_interpframe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ static inline _PyStackRef *_PyFrame_Stackbase(_PyInterpreterFrame *f) {
4848
}
4949

5050
static inline _PyStackRef _PyFrame_StackPeek(_PyInterpreterFrame *f) {
51-
assert(f->stackpointer > f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
51+
assert(f->stackpointer > _PyFrame_Stackbase(f));
5252
assert(!PyStackRef_IsNull(f->stackpointer[-1]));
5353
return f->stackpointer[-1];
5454
}
5555

5656
static inline _PyStackRef _PyFrame_StackPop(_PyInterpreterFrame *f) {
57-
assert(f->stackpointer > f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
57+
assert(f->stackpointer > _PyFrame_Stackbase(f));
5858
f->stackpointer--;
5959
return *f->stackpointer;
6060
}

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/_pydatetime.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ def isoformat(self):
11271127
This is 'YYYY-MM-DD'.
11281128
11291129
References:
1130-
- http://www.w3.org/TR/NOTE-datetime
1131-
- http://www.cl.cam.ac.uk/~mgk25/iso-time.html
1130+
- https://www.w3.org/TR/NOTE-datetime
1131+
- https://www.cl.cam.ac.uk/~mgk25/iso-time.html
11321132
"""
11331133
return "%04d-%02d-%02d" % (self._year, self._month, self._day)
11341134

@@ -1262,7 +1262,7 @@ def isocalendar(self):
12621262
The first week is 1; Monday is 1 ... Sunday is 7.
12631263
12641264
ISO calendar algorithm taken from
1265-
http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
1265+
https://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
12661266
(used with permission)
12671267
"""
12681268
year = self._year
@@ -2089,7 +2089,6 @@ def _local_timezone(self):
20892089
else:
20902090
ts = (self - _EPOCH) // timedelta(seconds=1)
20912091
localtm = _time.localtime(ts)
2092-
local = datetime(*localtm[:6])
20932092
# Extract TZ data
20942093
gmtoff = localtm.tm_gmtoff
20952094
zone = localtm.tm_zone

Lib/compression/zstd/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_frame_info(frame_buffer):
7171
the frame may or may not need a dictionary to be decoded,
7272
and the ID of such a dictionary is not specified.
7373
"""
74-
return FrameInfo(*_zstd._get_frame_info(frame_buffer))
74+
return FrameInfo(*_zstd.get_frame_info(frame_buffer))
7575

7676

7777
def train_dict(samples, dict_size):
@@ -91,7 +91,7 @@ def train_dict(samples, dict_size):
9191
chunk_sizes = tuple(_nbytes(sample) for sample in samples)
9292
if not chunks:
9393
raise ValueError("samples contained no data; can't train dictionary.")
94-
dict_content = _zstd._train_dict(chunks, chunk_sizes, dict_size)
94+
dict_content = _zstd.train_dict(chunks, chunk_sizes, dict_size)
9595
return ZstdDict(dict_content)
9696

9797

@@ -127,7 +127,7 @@ def finalize_dict(zstd_dict, /, samples, dict_size, level):
127127
if not chunks:
128128
raise ValueError("The samples are empty content, can't finalize the"
129129
"dictionary.")
130-
dict_content = _zstd._finalize_dict(zstd_dict.dict_content,
130+
dict_content = _zstd.finalize_dict(zstd_dict.dict_content,
131131
chunks, chunk_sizes,
132132
dict_size, level)
133133
return ZstdDict(dict_content)
@@ -201,7 +201,7 @@ def bounds(self):
201201
202202
Both the lower and upper bounds are inclusive.
203203
"""
204-
return _zstd._get_param_bounds(self.value, is_compress=True)
204+
return _zstd.get_param_bounds(self.value, is_compress=True)
205205

206206

207207
class DecompressionParameter(enum.IntEnum):
@@ -214,7 +214,7 @@ def bounds(self):
214214
215215
Both the lower and upper bounds are inclusive.
216216
"""
217-
return _zstd._get_param_bounds(self.value, is_compress=False)
217+
return _zstd.get_param_bounds(self.value, is_compress=False)
218218

219219

220220
class Strategy(enum.IntEnum):
@@ -237,4 +237,4 @@ class Strategy(enum.IntEnum):
237237

238238

239239
# Check validity of the CompressionParameter & DecompressionParameter types
240-
_zstd._set_parameter_types(CompressionParameter, DecompressionParameter)
240+
_zstd.set_parameter_types(CompressionParameter, DecompressionParameter)

Lib/compression/zstd/_zstdfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def __init__(self, file, /, mode="r", *,
8989
raw = _streams.DecompressReader(
9090
self._fp,
9191
ZstdDecompressor,
92-
trailing_error=ZstdError,
9392
zstd_dict=zstd_dict,
9493
options=options,
9594
)

Lib/inspect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,13 +2074,11 @@ def _signature_is_functionlike(obj):
20742074
code = getattr(obj, '__code__', None)
20752075
defaults = getattr(obj, '__defaults__', _void) # Important to use _void ...
20762076
kwdefaults = getattr(obj, '__kwdefaults__', _void) # ... and not None here
2077-
annotations = getattr(obj, '__annotations__', None)
20782077

20792078
return (isinstance(code, types.CodeType) and
20802079
isinstance(name, str) and
20812080
(defaults is None or isinstance(defaults, tuple)) and
2082-
(kwdefaults is None or isinstance(kwdefaults, dict)) and
2083-
(isinstance(annotations, (dict)) or annotations is None) )
2081+
(kwdefaults is None or isinstance(kwdefaults, dict)))
20842082

20852083

20862084
def _signature_strip_non_python_syntax(signature):

0 commit comments

Comments
 (0)