Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46c70ab

Browse files
authored
Merge branch 'python:main' into non-printing-char
2 parents ab39fbd + a05433f commit 46c70ab

24 files changed

+1235
-366
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ jobs:
658658
build_asan,
659659
build_tsan,
660660
test_hypothesis,
661+
cross-build-linux,
661662
'
662663
|| ''
663664
}}

Doc/c-api/unicode.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,8 @@ the Python configuration.
256256
257257
.. c:function:: int Py_UNICODE_ISPRINTABLE(Py_UCS4 ch)
258258
259-
Return ``1`` or ``0`` depending on whether *ch* is a printable character.
260-
Nonprintable characters are those characters defined in the Unicode character
261-
database as "Other" or "Separator", excepting the ASCII space (0x20) which is
262-
considered printable. (Note that printable characters in this context are
263-
those which should not be escaped when :func:`repr` is invoked on a string.
264-
It has no bearing on the handling of strings written to :data:`sys.stdout` or
265-
:data:`sys.stderr`.)
259+
Return ``1`` or ``0`` depending on whether *ch* is a printable character,
260+
in the sense of :meth:`str.isprintable`.
266261
267262
268263
These APIs can be used for fast direct character conversions:

Doc/glossary.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,11 +939,16 @@ Glossary
939939
modules, respectively.
940940

941941
namespace package
942-
A :pep:`420` :term:`package` which serves only as a container for
943-
subpackages. Namespace packages may have no physical representation,
942+
A :term:`package` which serves only as a container for subpackages.
943+
Namespace packages may have no physical representation,
944944
and specifically are not like a :term:`regular package` because they
945945
have no ``__init__.py`` file.
946946

947+
Namespace packages allow several individually installable packages to have a common parent package.
948+
Otherwise, it is recommended to use a :term:`regular package`.
949+
950+
For more information, see :pep:`420` and :ref:`reference-namespace-package`.
951+
947952
See also :term:`module`.
948953

949954
nested scope

Doc/library/stdtypes.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,13 +2012,19 @@ expression support in the :mod:`re` module).
20122012

20132013
.. method:: str.isprintable()
20142014

2015-
Return ``True`` if all characters in the string are printable or the string is
2016-
empty, ``False`` otherwise. Nonprintable characters are those characters defined
2017-
in the Unicode character database as "Other" or "Separator", excepting the
2018-
ASCII space (0x20) which is considered printable. (Note that printable
2019-
characters in this context are those which should not be escaped when
2020-
:func:`repr` is invoked on a string. It has no bearing on the handling of
2021-
strings written to :data:`sys.stdout` or :data:`sys.stderr`.)
2015+
Return true if all characters in the string are printable, false if it
2016+
contains at least one non-printable character.
2017+
2018+
Here "printable" means the character is suitable for :func:`repr` to use in
2019+
its output; "non-printable" means that :func:`repr` on built-in types will
2020+
hex-escape the character. It has no bearing on the handling of strings
2021+
written to :data:`sys.stdout` or :data:`sys.stderr`.
2022+
2023+
The printable characters are those which in the Unicode character database
2024+
(see :mod:`unicodedata`) have a general category in group Letter, Mark,
2025+
Number, Punctuation, or Symbol (L, M, N, P, or S); plus the ASCII space 0x20.
2026+
Nonprintable characters are those in group Separator or Other (Z or C),
2027+
except the ASCII space.
20222028

20232029

20242030
.. method:: str.isspace()

Doc/library/unittest.mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ Imagine we have a project that we want to test with the following structure::
20082008

20092009
Now we want to test ``some_function`` but we want to mock out ``SomeClass`` using
20102010
:func:`patch`. The problem is that when we import module b, which we will have to
2011-
do then it imports ``SomeClass`` from module a. If we use :func:`patch` to mock out
2011+
do when it imports ``SomeClass`` from module a. If we use :func:`patch` to mock out
20122012
``a.SomeClass`` then it will have no effect on our test; module b already has a
20132013
reference to the *real* ``SomeClass`` and it looks like our patching had no
20142014
effect.

Doc/reference/import.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Importing ``parent.one`` will implicitly execute ``parent/__init__.py`` and
123123
``parent/three/__init__.py`` respectively.
124124

125125

126+
.. _reference-namespace-package:
127+
126128
Namespace packages
127129
------------------
128130

Include/cpython/bytearrayobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ static inline char* PyByteArray_AS_STRING(PyObject *op)
2929

3030
static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
3131
PyByteArrayObject *self = _PyByteArray_CAST(op);
32+
#ifdef Py_GIL_DISABLED
33+
return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(self)->ob_size));
34+
#else
3235
return Py_SIZE(self);
36+
#endif
3337
}
3438
#define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))

Lib/mimetypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def add_type(self, type, ext, strict=True):
9090
list of standard types, else to the list of non-standard
9191
types.
9292
"""
93+
if not type:
94+
return
9395
self.types_map[strict][ext] = type
9496
exts = self.types_map_inv[strict].setdefault(type, [])
9597
if ext not in exts:

Lib/test/test_abc.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,16 @@ class B(A, metaclass=abc_ABCMeta, name="test"):
684684

685685
return TestLegacyAPI, TestABC, TestABCWithInitSubclass
686686

687-
TestLegacyAPI_Py, TestABC_Py, TestABCWithInitSubclass_Py = test_factory(abc.ABCMeta,
688-
abc.get_cache_token)
689-
TestLegacyAPI_C, TestABC_C, TestABCWithInitSubclass_C = test_factory(_py_abc.ABCMeta,
690-
_py_abc.get_cache_token)
687+
TestLegacyAPI_Py, TestABC_Py, TestABCWithInitSubclass_Py = test_factory(_py_abc.ABCMeta,
688+
_py_abc.get_cache_token)
689+
TestLegacyAPI_C, TestABC_C, TestABCWithInitSubclass_C = test_factory(abc.ABCMeta,
690+
abc.get_cache_token)
691+
692+
# gh-130095: The _py_abc tests are not thread-safe when run with
693+
# `--parallel-threads`
694+
TestLegacyAPI_Py.__unittest_thread_unsafe__ = True
695+
TestABC_Py.__unittest_thread_unsafe__ = True
696+
TestABCWithInitSubclass_Py.__unittest_thread_unsafe__ = True
691697

692698
if __name__ == "__main__":
693699
unittest.main()

0 commit comments

Comments
 (0)