Skip to content

Commit 4ef255d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into gh-114258-hash
2 parents 4031e7b + c3bcc92 commit 4ef255d

105 files changed

Lines changed: 8534 additions & 3710 deletions

File tree

Some content is hidden

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

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Python/frozen_modules/MANIFEST
180180

181181
# Local AI agent scratch state (per-PR and per-branch notebooks, sandbox
182182
# experiments) and personal agent overrides, none of which are committed.
183+
/do-not-commit/
183184
/.claude/pr-*
184185
/.claude/branch-*
185186
/.claude/sandbox/

‎Doc/library/binascii.rst‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,16 @@ The :mod:`!binascii` module defines the following functions:
283283

284284
.. versionadded:: 3.15
285285

286-
.. function:: a2b_qp(data, header=False)
286+
.. function:: a2b_qp(data, header=False, *, strip_ws=False)
287287

288288
Convert a block of quoted-printable data back to binary and return the binary
289289
data. More than one line may be passed at a time. If the optional argument
290290
*header* is present and true, underscores will be decoded as spaces.
291+
If the optional argument *strip_ws* is true,
292+
trailing whitespace is stripped from each line, as required by :rfc:`2045`.
293+
294+
.. versionchanged:: next
295+
Added the *strip_ws* parameter.
291296

292297

293298
.. function:: b2a_qp(data, quotetabs=False, istext=True, header=False)

‎Doc/library/datetime.rst‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,12 @@ Objects of the :class:`date` type are always naive.
180180

181181
An object of type :class:`.time` or :class:`.datetime` may be aware or naive.
182182

183-
A :class:`.datetime` object ``d`` is aware if both of the following hold:
184-
185-
1. ``d.tzinfo`` is not ``None``
186-
2. ``d.tzinfo.utcoffset(d)`` does not return ``None``
187-
183+
A :class:`.datetime` object ``d`` is aware if
184+
:meth:`d.utcoffset() <datetime.utcoffset>` does not return ``None``.
188185
Otherwise, ``d`` is naive.
189186

190-
A :class:`.time` object ``t`` is aware if both of the following hold:
191-
192-
1. ``t.tzinfo`` is not ``None``
193-
2. ``t.tzinfo.utcoffset(None)`` does not return ``None``.
194-
187+
A :class:`.time` object ``t`` is aware if
188+
:meth:`t.utcoffset() <time.utcoffset>` does not return ``None``.
195189
Otherwise, ``t`` is naive.
196190

197191
The distinction between aware and naive doesn't apply to :class:`timedelta`

‎Doc/library/email.compat32-message.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ Here are the methods of the :class:`Message` class:
214214
defect property (:class:`~email.errors.InvalidBase64PaddingDefect` or
215215
:class:`~email.errors.InvalidBase64CharactersDefect`, respectively).
216216

217+
.. note::
218+
219+
A ``quoted-printable`` payload is decoded without stripping
220+
trailing whitespace, contrary to :rfc:`2045` but matching
221+
common mail clients.
222+
Use :func:`binascii.a2b_qp` with ``strip_ws=True``
223+
(or ``email.quoprimime.decode``) for RFC-compliant decoding.
224+
217225
When *decode* is ``False`` (the default) the body is returned as a string
218226
without decoding the :mailheader:`Content-Transfer-Encoding`. However,
219227
for a :mailheader:`Content-Transfer-Encoding` of 8bit, an attempt is made

‎Doc/library/inspect.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,11 @@ Classes and functions
13471347
:func:`getargvalues`. The format\* arguments are the corresponding optional
13481348
formatting functions that are called to turn names and values into strings.
13491349

1350+
Arguments whose names are absent from *locals*, including ``*`` and ``**``
1351+
arguments, are displayed with a value of ``<deleted>``. A custom *formatvalue*
1352+
function receives a placeholder object whose :func:`repr` is ``<deleted>``
1353+
for these arguments.
1354+
13501355
.. note::
13511356
This function was inadvertently marked as deprecated in Python 3.5.
13521357

‎Doc/library/quopri.rst‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ few nonprintable characters; the base64 encoding scheme available via the
2020
:mod:`base64` module is more compact if there are many such characters, as when
2121
sending a graphics file.
2222

23-
.. function:: decode(input, output, header=False)
23+
.. function:: decode(input, output, header=False, *, strip_ws=False)
2424

2525
Decode the contents of the *input* file and write the resulting decoded binary
2626
data to the *output* file. *input* and *output* must be :term:`binary file objects
2727
<file object>`. If the optional argument *header* is present and true, underscore
2828
will be decoded as space. This is used to decode "Q"-encoded headers as
2929
described in :rfc:`1522`: "MIME (Multipurpose Internet Mail Extensions)
3030
Part Two: Message Header Extensions for Non-ASCII Text".
31+
If the optional argument *strip_ws* is true,
32+
trailing whitespace is stripped from each line, as required by :rfc:`2045`.
33+
34+
.. versionchanged:: next
35+
Added the *strip_ws* parameter.
3136

3237

3338
.. function:: encode(input, output, quotetabs, header=False)
@@ -43,11 +48,14 @@ sending a graphics file.
4348
as underscores as per :rfc:`1522`.
4449

4550

46-
.. function:: decodestring(s, header=False)
51+
.. function:: decodestring(s, header=False, *, strip_ws=False)
4752

4853
Like :func:`decode`, except that it accepts a source :class:`bytes` and
4954
returns the corresponding decoded :class:`bytes`.
5055

56+
.. versionchanged:: next
57+
Added the *strip_ws* parameter.
58+
5159

5260
.. function:: encodestring(s, quotetabs=False, header=False)
5361

‎Doc/license.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ mimalloc
10341034

10351035
MIT License::
10361036

1037-
Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen
1037+
Copyright (c) 2018-2025 Microsoft Corporation, Daan Leijen
10381038

10391039
Permission is hereby granted, free of charge, to any person obtaining a copy
10401040
of this software and associated documentation files (the "Software"), to deal

‎Doc/whatsnew/3.16.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,16 @@ pickle
614614
:class:`!WeakMethod` and :class:`!WeakSet` can now also be copied.
615615
(Contributed by Serhiy Storchaka in :gh:`74876`.)
616616

617+
quopri
618+
------
619+
620+
* :func:`quopri.decode`, :func:`quopri.decodestring` and
621+
:func:`binascii.a2b_qp` gained a *strip_ws* parameter. When true, trailing
622+
whitespace is stripped from each line while decoding, as required by
623+
:rfc:`2045` for a quoted-printable body.
624+
(Contributed by Serhiy Storchaka in :gh:`62222`.)
625+
626+
617627
re
618628
--
619629

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* ----------------------------------------------------------------------------
2+
Copyright (c) 2018-2025, Microsoft Research, Daan Leijen
3+
This is free software; you can redistribute it and/or modify it under the
4+
terms of the MIT license. A copy of the license can be found in the file
5+
"LICENSE" at the root of this distribution.
6+
-----------------------------------------------------------------------------*/
7+
#pragma once
8+
#ifndef MIMALLOC_STATS_H
9+
#define MIMALLOC_STATS_H
10+
11+
#include "mimalloc.h"
12+
#include <stdint.h>
13+
14+
#define MI_STAT_VERSION 4 // increased on every backward incompatible change
15+
16+
// count allocation over time
17+
typedef struct mi_stat_count_s {
18+
int64_t total; // total allocated
19+
int64_t peak; // peak allocation
20+
int64_t current; // current allocation
21+
} mi_stat_count_t;
22+
23+
// counters only increase
24+
typedef struct mi_stat_counter_s {
25+
int64_t total; // total count
26+
} mi_stat_counter_t;
27+
28+
#define MI_STAT_FIELDS() \
29+
MI_STAT_COUNT(pages) /* count of mimalloc pages */ \
30+
MI_STAT_COUNT(reserved) /* reserved memory bytes */ \
31+
MI_STAT_COUNT(committed) /* committed bytes */ \
32+
MI_STAT_COUNTER(reset) /* reset bytes */ \
33+
MI_STAT_COUNTER(purged) /* purged bytes */ \
34+
MI_STAT_COUNT(page_committed) /* committed memory inside pages */ \
35+
MI_STAT_COUNT(pages_abandoned) /* abandoned pages count */ \
36+
MI_STAT_COUNT(threads) /* number of threads */ \
37+
MI_STAT_COUNT(malloc_normal) /* allocated bytes <= MI_LARGE_OBJ_SIZE_MAX */ \
38+
MI_STAT_COUNT(malloc_huge) /* allocated bytes in huge pages */ \
39+
MI_STAT_COUNT(malloc_requested) /* malloc requested bytes */ \
40+
\
41+
MI_STAT_COUNTER(mmap_calls) \
42+
MI_STAT_COUNTER(commit_calls) \
43+
MI_STAT_COUNTER(reset_calls) \
44+
MI_STAT_COUNTER(purge_calls) \
45+
MI_STAT_COUNTER(arena_count) /* number of memory arena's */ \
46+
MI_STAT_COUNTER(malloc_normal_count) /* number of blocks <= MI_LARGE_OBJ_SIZE_MAX */ \
47+
MI_STAT_COUNTER(malloc_huge_count) /* number of huge bloks */ \
48+
MI_STAT_COUNTER(malloc_guarded_count) /* number of allocations with guard pages */ \
49+
\
50+
/* internal statistics */ \
51+
MI_STAT_COUNTER(arena_rollback_count) \
52+
MI_STAT_COUNTER(arena_purges) \
53+
MI_STAT_COUNTER(pages_extended) /* number of page extensions */ \
54+
MI_STAT_COUNTER(pages_retire) /* number of pages that are retired */ \
55+
MI_STAT_COUNTER(page_searches) /* total pages searched for a fresh page */ \
56+
MI_STAT_COUNTER(page_searches_count) /* searched count for a fresh page */ \
57+
/* only on v1 and v2 */ \
58+
MI_STAT_COUNT(segments) \
59+
MI_STAT_COUNT(segments_abandoned) \
60+
MI_STAT_COUNT(segments_cache) \
61+
MI_STAT_COUNT(_segments_reserved) \
62+
/* only on v3 */ \
63+
MI_STAT_COUNTER(pages_reclaim_on_alloc) \
64+
MI_STAT_COUNTER(pages_reclaim_on_free) \
65+
MI_STAT_COUNTER(pages_reabandon_full) \
66+
MI_STAT_COUNTER(pages_unabandon_busy_wait) \
67+
68+
69+
// Define the statistics structure
70+
#define MI_BIN_HUGE (73U) // see types.h
71+
#define MI_STAT_COUNT(stat) mi_stat_count_t stat;
72+
#define MI_STAT_COUNTER(stat) mi_stat_counter_t stat;
73+
74+
typedef struct mi_stats_s
75+
{
76+
size_t size; // size of the mi_stats_t structure
77+
size_t version;
78+
79+
MI_STAT_FIELDS()
80+
81+
// future extension
82+
mi_stat_count_t _stat_reserved[4];
83+
mi_stat_counter_t _stat_counter_reserved[4];
84+
85+
// size segregated statistics
86+
mi_stat_count_t malloc_bins[MI_BIN_HUGE+1]; // allocation per size bin
87+
mi_stat_count_t page_bins[MI_BIN_HUGE+1]; // pages allocated per size bin
88+
} mi_stats_t;
89+
90+
#undef MI_STAT_COUNT
91+
#undef MI_STAT_COUNTER
92+
93+
// helper
94+
#define mi_stats_t_decl(name) mi_stats_t name = { 0 }; name.size = sizeof(mi_stats_t); name.version = MI_STAT_VERSION;
95+
96+
// Exported definitions
97+
#ifdef __cplusplus
98+
extern "C" {
99+
#endif
100+
101+
mi_decl_export bool mi_stats_get( mi_stats_t* stats ) mi_attr_noexcept;
102+
mi_decl_export char* mi_stats_get_json( size_t buf_size, char* buf ) mi_attr_noexcept; // use mi_free to free the result if the input buf == NULL
103+
104+
#ifdef __cplusplus
105+
}
106+
#endif
107+
108+
#endif // MIMALLOC_STATS_H

0 commit comments

Comments
 (0)