Skip to content

Commit 367ccf0

Browse files
committed
Merge branch 'gh-117435-semlock' into nogil-integration
2 parents 9da617e + dcdff0d commit 367ccf0

File tree

8 files changed

+93
-16
lines changed

8 files changed

+93
-16
lines changed

Doc/library/subprocess.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ underlying :class:`Popen` interface can be used directly.
5252

5353
If *capture_output* is true, stdout and stderr will be captured.
5454
When used, the internal :class:`Popen` object is automatically created with
55-
``stdout=PIPE`` and ``stderr=PIPE``. The *stdout* and *stderr* arguments may
56-
not be supplied at the same time as *capture_output*. If you wish to capture
57-
and combine both streams into one, use ``stdout=PIPE`` and ``stderr=STDOUT``
58-
instead of *capture_output*.
55+
*stdout* and *stdin* both set to :data:`~subprocess.PIPE`.
56+
The *stdout* and *stderr* arguments may not be supplied at the same time as *capture_output*.
57+
If you wish to capture and combine both streams into one,
58+
set *stdout* to :data:`~subprocess.PIPE`
59+
and *stderr* to :data:`~subprocess.STDOUT`,
60+
instead of using *capture_output*.
5961

6062
A *timeout* may be specified in seconds, it is internally passed on to
6163
:meth:`Popen.communicate`. If the timeout expires, the child process will be
@@ -69,7 +71,8 @@ underlying :class:`Popen` interface can be used directly.
6971
subprocess's stdin. If used it must be a byte sequence, or a string if
7072
*encoding* or *errors* is specified or *text* is true. When
7173
used, the internal :class:`Popen` object is automatically created with
72-
``stdin=PIPE``, and the *stdin* argument may not be used as well.
74+
*stdin* set to :data:`~subprocess.PIPE`,
75+
and the *stdin* argument may not be used as well.
7376

7477
If *check* is true, and the process exits with a non-zero exit code, a
7578
:exc:`CalledProcessError` exception will be raised. Attributes of that

Doc/library/xml.etree.elementtree.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ and its sub-elements are done on the :class:`Element` level.
4949
Parsing XML
5050
^^^^^^^^^^^
5151

52-
We'll be using the following XML document as the sample data for this section:
52+
We'll be using the fictive :file:`country_data.xml` XML document as the sample data for this section:
5353

5454
.. code-block:: xml
5555

Doc/whatsnew/3.13.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ Deprecated
813813
translation was not found.
814814
(Contributed by Serhiy Storchaka in :gh:`88434`.)
815815

816+
* :mod:`glob`: The undocumented :func:`!glob.glob0` and :func:`!glob.glob1`
817+
functions are deprecated. Use :func:`glob.glob` and pass a directory to its
818+
*root_dir* argument instead.
819+
(Contributed by Barney Gale in :gh:`117337`.)
820+
816821
* :mod:`http.server`: :class:`http.server.CGIHTTPRequestHandler` now emits a
817822
:exc:`DeprecationWarning` as it will be removed in 3.15. Process-based CGI
818823
HTTP servers have been out of favor for a very long time. This code was

Lib/glob.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,19 @@ def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False):
119119
return [basename]
120120
return []
121121

122-
# Following functions are not public but can be used by third-party code.
122+
_deprecated_function_message = (
123+
"{name} is deprecated and will be removed in Python {remove}. Use "
124+
"glob.glob and pass a directory to its root_dir argument instead."
125+
)
123126

124127
def glob0(dirname, pattern):
128+
import warnings
129+
warnings._deprecated("glob.glob0", _deprecated_function_message, remove=(3, 15))
125130
return _glob0(dirname, pattern, None, False)
126131

127132
def glob1(dirname, pattern):
133+
import warnings
134+
warnings._deprecated("glob.glob1", _deprecated_function_message, remove=(3, 15))
128135
return _glob1(dirname, pattern, None, False)
129136

130137
# This helper function recursively yields relative pathnames inside a literal

Lib/test/test_glob.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shutil
55
import sys
66
import unittest
7+
import warnings
78

89
from test.support.os_helper import (TESTFN, skip_unless_symlink,
910
can_symlink, create_empty_file, change_cwd)
@@ -382,6 +383,36 @@ def test_glob_many_open_files(self):
382383
for it in iters:
383384
self.assertEqual(next(it), p)
384385

386+
def test_glob0(self):
387+
with self.assertWarns(DeprecationWarning):
388+
glob.glob0(self.tempdir, 'a')
389+
390+
with warnings.catch_warnings():
391+
warnings.simplefilter('ignore')
392+
eq = self.assertSequencesEqual_noorder
393+
eq(glob.glob0(self.tempdir, 'a'), ['a'])
394+
eq(glob.glob0(self.tempdir, '.bb'), ['.bb'])
395+
eq(glob.glob0(self.tempdir, '.b*'), [])
396+
eq(glob.glob0(self.tempdir, 'b'), [])
397+
eq(glob.glob0(self.tempdir, '?'), [])
398+
eq(glob.glob0(self.tempdir, '*a'), [])
399+
eq(glob.glob0(self.tempdir, 'a*'), [])
400+
401+
def test_glob1(self):
402+
with self.assertWarns(DeprecationWarning):
403+
glob.glob1(self.tempdir, 'a')
404+
405+
with warnings.catch_warnings():
406+
warnings.simplefilter('ignore')
407+
eq = self.assertSequencesEqual_noorder
408+
eq(glob.glob1(self.tempdir, 'a'), ['a'])
409+
eq(glob.glob1(self.tempdir, '.bb'), ['.bb'])
410+
eq(glob.glob1(self.tempdir, '.b*'), ['.bb'])
411+
eq(glob.glob1(self.tempdir, 'b'), [])
412+
eq(glob.glob1(self.tempdir, '?'), ['a'])
413+
eq(glob.glob1(self.tempdir, '*a'), ['a', 'aaa'])
414+
eq(glob.glob1(self.tempdir, 'a*'), ['a', 'aaa', 'aab'])
415+
385416
def test_translate_matching(self):
386417
match = re.compile(glob.translate('*')).match
387418
self.assertIsNotNone(match('foo'))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Deprecate undocumented :func:`!glob.glob0` and :func:`!glob.glob1`
2+
functions. Use :func:`glob.glob` and pass a directory to its
3+
*root_dir* argument instead.

Modules/_multiprocessing/clinic/semaphore.c.h

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

Modules/_multiprocessing/semaphore.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ _GetSemaphoreValue(HANDLE handle, long *value)
8181
}
8282

8383
/*[clinic input]
84+
@critical_section
8485
_multiprocessing.SemLock.acquire
8586
8687
block as blocking: bool = True
@@ -92,7 +93,7 @@ Acquire the semaphore/lock.
9293
static PyObject *
9394
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
9495
PyObject *timeout_obj)
95-
/*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
96+
/*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
9697
{
9798
double timeout;
9899
DWORD res, full_msecs, nhandles;
@@ -172,14 +173,15 @@ _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
172173
}
173174

174175
/*[clinic input]
176+
@critical_section
175177
_multiprocessing.SemLock.release
176178
177179
Release the semaphore/lock.
178180
[clinic start generated code]*/
179181

180182
static PyObject *
181183
_multiprocessing_SemLock_release_impl(SemLockObject *self)
182-
/*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
184+
/*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
183185
{
184186
if (self->kind == RECURSIVE_MUTEX) {
185187
if (!ISMINE(self)) {
@@ -297,6 +299,7 @@ sem_timedwait_save(sem_t *sem, struct timespec *deadline, PyThreadState *_save)
297299
#endif /* !HAVE_SEM_TIMEDWAIT */
298300

299301
/*[clinic input]
302+
@critical_section
300303
_multiprocessing.SemLock.acquire
301304
302305
block as blocking: bool = True
@@ -308,7 +311,7 @@ Acquire the semaphore/lock.
308311
static PyObject *
309312
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
310313
PyObject *timeout_obj)
311-
/*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
314+
/*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
312315
{
313316
int res, err = 0;
314317
struct timespec deadline = {0};
@@ -382,14 +385,15 @@ _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
382385
}
383386

384387
/*[clinic input]
388+
@critical_section
385389
_multiprocessing.SemLock.release
386390
387391
Release the semaphore/lock.
388392
[clinic start generated code]*/
389393

390394
static PyObject *
391395
_multiprocessing_SemLock_release_impl(SemLockObject *self)
392-
/*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
396+
/*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
393397
{
394398
if (self->kind == RECURSIVE_MUTEX) {
395399
if (!ISMINE(self)) {
@@ -583,14 +587,15 @@ semlock_dealloc(SemLockObject* self)
583587
}
584588

585589
/*[clinic input]
590+
@critical_section
586591
_multiprocessing.SemLock._count
587592
588593
Num of `acquire()`s minus num of `release()`s for this process.
589594
[clinic start generated code]*/
590595

591596
static PyObject *
592597
_multiprocessing_SemLock__count_impl(SemLockObject *self)
593-
/*[clinic end generated code: output=5ba8213900e517bb input=36fc59b1cd1025ab]*/
598+
/*[clinic end generated code: output=5ba8213900e517bb input=9fa6e0b321b16935]*/
594599
{
595600
return PyLong_FromLong((long)self->count);
596601
}

0 commit comments

Comments
 (0)