Skip to content

Commit def9770

Browse files
Merge branch 'main' into patch-1
2 parents 0cfdd68 + 828c153 commit def9770

112 files changed

Lines changed: 1897 additions & 2575 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.

‎Doc/builtins/stdtypes.rst‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,10 @@ expression support in the :mod:`re` module).
26292629
Return ``True`` if all cased characters [4]_ in the string are uppercase and
26302630
there is at least one cased character, ``False`` otherwise.
26312631

2632+
For example:
2633+
2634+
.. doctest::
2635+
26322636
>>> 'BANANA'.isupper()
26332637
True
26342638
>>> 'banana'.isupper()
@@ -2692,10 +2696,25 @@ expression support in the :mod:`re` module).
26922696
>>> 'Lower Method Example'.lower()
26932697
'lower method example'
26942698

2699+
Note that ``s.lower().islower()`` might be ``False`` if ``s``
2700+
contains uncased characters or if the Unicode category of the resulting
2701+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
2702+
titlecase).
2703+
2704+
For example, see the word "Python" written in Punjabi:
2705+
2706+
.. doctest::
2707+
2708+
>>> 'ازگر'.lower().islower()
2709+
False
2710+
2711+
26952712
The lowercasing algorithm used is `described in section 3.13.2 'Default Case
26962713
Conversion' of the Unicode Standard
26972714
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
26982715

2716+
See also :meth:`islower` and :meth:`upper`.
2717+
26992718

27002719
.. method:: str.lstrip(chars=None, /)
27012720

@@ -3199,15 +3218,33 @@ expression support in the :mod:`re` module).
31993218
.. method:: str.upper()
32003219

32013220
Return a copy of the string with all the cased characters [4]_ converted to
3202-
uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s``
3221+
uppercase.
3222+
3223+
For example:
3224+
3225+
.. doctest::
3226+
3227+
>>> 'Upper Method Example'.upper()
3228+
'UPPER METHOD EXAMPLE'
3229+
3230+
Note that ``s.upper().isupper()`` might be ``False`` if ``s``
32033231
contains no cased characters or if the Unicode category of the resulting
3204-
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter,
3232+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
32053233
titlecase).
32063234

3235+
For example, see the word "Python" written in Punjabi:
3236+
3237+
.. doctest::
3238+
3239+
>>> 'ازگر'.upper().isupper()
3240+
False
3241+
32073242
The uppercasing algorithm used is `described in section 3.13.2 'Default Case
32083243
Conversion' of the Unicode Standard
32093244
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
32103245

3246+
See also :meth:`isupper` and :meth:`lower`.
3247+
32113248

32123249
.. method:: str.zfill(width, /)
32133250

‎Doc/library/linecache.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ The :mod:`!linecache` module defines the following functions:
6969
Example::
7070

7171
>>> import linecache
72-
>>> linecache.getline(linecache.__file__, 8)
73-
'import sys\n'
72+
>>> linecache.getline(linecache.__file__, 1)
73+
'"""Cache lines from Python source files.\n'

‎Doc/library/random.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ be found in any statistics text.
300300

301301
Return the next random floating-point number in the range ``0.0 <= X < 1.0``
302302

303+
The boolean expression ``random() < p`` is :const:`True` with probability
304+
``p``.
305+
303306

304307
.. function:: uniform(a, b)
305308

‎Doc/library/tempfile.rst‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@ The module defines the following user-callable items:
3333
.. function:: TemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
3434

3535
Return a :term:`file-like object` that can be used as a temporary storage area.
36-
The file is created securely, using the same rules as :func:`mkstemp`. It will be destroyed as soon
37-
as it is closed (including an implicit close when the object is garbage
38-
collected). Under Unix, the directory entry for the file is either not created at all or is removed
39-
immediately after the file is created. Other platforms do not support
36+
The file is created securely, using the same rules as :func:`mkstemp`.
37+
38+
The object can be used as a context manager
39+
(see :ref:`tempfile-examples`).
40+
Exiting the context manager closes the file.
41+
42+
Under Unix, the directory entry for the file is either not created at all or is
43+
removed immediately after the file is created. Other platforms do not support
4044
this; your code should not rely on a temporary file created using this
4145
function having or not having a visible name in the file system.
4246

43-
The resulting object can be used as a :term:`context manager` (see
44-
:ref:`tempfile-examples`). On completion of the context or
45-
destruction of the file object the temporary file will be removed
46-
from the filesystem.
47+
The file will be removed from the file system when the object is closed
48+
(including an implicit close when the object is garbage collected).
4749

4850
The *mode* parameter defaults to ``'w+b'`` so that the file created can
4951
be read and written without being closed. Binary mode is used so that it

‎Doc/reference/datamodel.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,8 +3163,8 @@ behaviour. An example of this can be found in the :mod:`enum` module::
31633163
...
31643164
>>> # Enum classes have a custom metaclass:
31653165
>>> type(Menu)
3166-
<class 'enum.EnumMeta'>
3167-
>>> # EnumMeta defines __getitem__,
3166+
<class 'enum.EnumType'>
3167+
>>> # EnumType defines __getitem__,
31683168
>>> # so __class_getitem__ is not called,
31693169
>>> # and the result is not a GenericAlias object:
31703170
>>> Menu['SPAM']

‎Doc/tutorial/introduction.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ through all other variables that refer to it.::
438438
True
439439
>>> rgba.append("Alph")
440440
>>> rgb
441-
["Red", "Green", "Blue", "Alph"]
441+
['Red', 'Green', 'Blue', 'Alph']
442442

443443
All slice operations return a new list containing the requested elements. This
444444
means that the following slice returns a
@@ -447,9 +447,9 @@ means that the following slice returns a
447447
>>> correct_rgba = rgba[:]
448448
>>> correct_rgba[-1] = "Alpha"
449449
>>> correct_rgba
450-
["Red", "Green", "Blue", "Alpha"]
450+
['Red', 'Green', 'Blue', 'Alpha']
451451
>>> rgba
452-
["Red", "Green", "Blue", "Alph"]
452+
['Red', 'Green', 'Blue', 'Alph']
453453

454454
Assignment to slices is also possible, and this can even change the size of the
455455
list or clear it entirely::

‎Doc/using/mac.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ GUI programming
218218
There are several options for building GUI applications on the Mac with Python.
219219

220220
The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-platform
221-
Tk toolkit (https://www.tcl.tk). A macOS-native version of Tk is included with
221+
Tk toolkit (https://www.tcl-lang.org/). A macOS-native version of Tk is included with
222222
the installer.
223223

224224
*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework.

‎Include/internal/mimalloc/mimalloc.h‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ terms of the MIT license. A copy of the license can be found in the file
1515
// ------------------------------------------------------
1616

1717
#ifdef __cplusplus
18-
#if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11
18+
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER > 1900) // C++11
1919
#define mi_attr_noexcept noexcept
2020
#else
2121
#define mi_attr_noexcept throw()
@@ -30,7 +30,7 @@ terms of the MIT license. A copy of the license can be found in the file
3030
#define mi_decl_nodiscard __attribute__((warn_unused_result))
3131
#elif defined(_HAS_NODISCARD)
3232
#define mi_decl_nodiscard _NODISCARD
33-
#elif (_MSC_VER >= 1700)
33+
#elif defined(_MSC_VER) && (_MSC_VER >= 1700)
3434
#define mi_decl_nodiscard _Check_return_
3535
#else
3636
#define mi_decl_nodiscard
@@ -513,7 +513,7 @@ mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_heap_alloc_new_n(mi_h
513513

514514
#include <cstddef> // std::size_t
515515
#include <cstdint> // PTRDIFF_MAX
516-
#if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11
516+
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER > 1900) // C++11
517517
#include <type_traits> // std::true_type
518518
#include <utility> // std::forward
519519
#endif
@@ -527,7 +527,7 @@ template<class T> struct _mi_stl_allocator_common {
527527
typedef value_type* pointer;
528528
typedef value_type const* const_pointer;
529529

530-
#if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
530+
#if ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER > 1900)) // C++11
531531
using propagate_on_container_copy_assignment = std::true_type;
532532
using propagate_on_container_move_assignment = std::true_type;
533533
using propagate_on_container_swap = std::true_type;
@@ -562,7 +562,7 @@ template<class T> struct mi_stl_allocator : public _mi_stl_allocator_common<T> {
562562
mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast<pointer>(mi_new_n(count, sizeof(value_type))); }
563563
#endif
564564

565-
#if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
565+
#if ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER > 1900)) // C++11
566566
using is_always_equal = std::true_type;
567567
#endif
568568
};
@@ -571,7 +571,7 @@ template<class T1,class T2> bool operator==(const mi_stl_allocator<T1>& , const
571571
template<class T1,class T2> bool operator!=(const mi_stl_allocator<T1>& , const mi_stl_allocator<T2>& ) mi_attr_noexcept { return false; }
572572

573573

574-
#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) // C++11
574+
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900) // C++11
575575
#define MI_HAS_HEAP_STL_ALLOCATOR 1
576576

577577
#include <memory> // std::shared_ptr
@@ -591,7 +591,7 @@ template<class T, bool _mi_destroy> struct _mi_heap_stl_allocator_common : publi
591591
mi_decl_nodiscard pointer allocate(size_type count, const void* = 0) { return static_cast<pointer>(mi_heap_alloc_new_n(this->heap.get(), count, sizeof(value_type))); }
592592
#endif
593593

594-
#if ((__cplusplus >= 201103L) || (_MSC_VER > 1900)) // C++11
594+
#if ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER > 1900)) // C++11
595595
using is_always_equal = std::false_type;
596596
#endif
597597

‎Include/internal/mimalloc/mimalloc/atomic.h‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ terms of the MIT license. A copy of the license can be found in the file
1414
#define WIN32_LEAN_AND_MEAN
1515
#endif
1616
#include <windows.h>
17-
#elif !defined(__wasi__) && (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__))
18-
#define MI_USE_PTHREADS
17+
#endif
18+
#if !defined(MI_USE_PTHREADS)
19+
#if !defined(_WIN32) && !defined(__wasi__) && (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__))
20+
#define MI_USE_PTHREADS 1
21+
#else
22+
#define MI_USE_PTHREADS 0
23+
#endif
24+
#endif
25+
#if MI_USE_PTHREADS
1926
#include <pthread.h>
2027
#endif
2128

@@ -511,7 +518,7 @@ static inline void mi_atomic_yield_sleep( size_t* ticks, const size_t ticks_unti
511518
// These should be light-weight in-process only locks.
512519
// Only used for reserving arena's and to maintain the abandoned list.
513520
// ----------------------------------------------------------------------
514-
#if _MSC_VER
521+
#if defined(_MSC_VER)
515522
#pragma warning(disable:26110) // unlock with holding lock
516523
#endif
517524

@@ -543,7 +550,7 @@ static inline void mi_lock_done(mi_lock_t* lock) {
543550
(void)(lock);
544551
}
545552

546-
#elif defined(MI_USE_PTHREADS)
553+
#elif MI_USE_PTHREADS
547554

548555
#include <string.h> // memcpy
549556
void _mi_error_message(int err, const char* fmt, ...);

‎Include/internal/mimalloc/mimalloc/internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void _mi_segment_page_abandon(mi_page_t* page, mi_segments_tld_t* tld);
236236
bool _mi_segment_try_reclaim_abandoned( mi_heap_t* heap, bool try_all, mi_segments_tld_t* tld);
237237
void _mi_segment_collect(mi_segment_t* segment, bool force);
238238

239-
#if MI_HUGE_PAGE_ABANDON
239+
#if defined(MI_HUGE_PAGE_ABANDON) && MI_HUGE_PAGE_ABANDON
240240
void _mi_segment_huge_page_free(mi_segment_t* segment, mi_page_t* page, mi_block_t* block);
241241
#else
242242
void _mi_segment_huge_page_reset(mi_segment_t* segment, mi_page_t* page, mi_block_t* block);

0 commit comments

Comments
 (0)