Skip to content

Commit 7880e64

Browse files
Merge branch 'main' into docs-resources
2 parents 814481e + 6e2b9a2 commit 7880e64

Some content is hidden

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

83 files changed

+672
-571
lines changed

Doc/library/resource.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ this module for those platforms.
5757
Previously, it could be negative, such as -1 or -3.
5858

5959

60+
.. data:: RLIM_SAVED_CUR
61+
.. data:: RLIM_SAVED_MAX
62+
63+
Constants used to represent the soft and hard limit values if they
64+
cannot be represented in the ``rlim_t`` value in C.
65+
Can be equal to :data:`RLIM_INFINITY`.
66+
67+
.. versionadded:: next
68+
69+
6070
.. function:: getrlimit(resource)
6171

6272
Returns a tuple ``(soft, hard)`` with the current soft and hard limits of
@@ -280,6 +290,45 @@ platform.
280290
.. versionadded:: 3.10
281291

282292

293+
.. data:: RLIMIT_NTHR
294+
295+
The maximum number of threads for this user id, not counting the main
296+
and kernel threads.
297+
298+
.. availability:: NetBSD >= 7.0.
299+
300+
.. versionadded:: next
301+
302+
303+
.. data:: RLIMIT_PIPEBUF
304+
305+
The maximum total size of in-kernel buffers for bi-directional pipes/fifos
306+
that this user id is allowed to consume.
307+
308+
.. availability:: FreeBSD >= 14.2.
309+
310+
.. versionadded:: next
311+
312+
313+
.. data:: RLIMIT_THREADS
314+
315+
The maximum number of threads each process can create.
316+
317+
.. availability:: AIX.
318+
319+
.. versionadded:: next
320+
321+
322+
.. data:: RLIMIT_UMTXP
323+
324+
The limit of the number of process-shared Posix thread library objects
325+
allocated by user id.
326+
327+
.. availability:: FreeBSD >= 11.
328+
329+
.. versionadded:: next
330+
331+
283332
Resource Usage
284333
--------------
285334

Doc/whatsnew/3.15.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ os.path
312312
the resulting path can be missing but it will be free of symlinks.
313313
(Contributed by Petr Viktorin for :cve:`2025-4517`.)
314314

315+
resource
316+
--------
317+
318+
* Add new constants: :data:`~resource.RLIMIT_NTHR`,
319+
:data:`~resource.RLIMIT_UMTXP`, :data:`~resource.RLIMIT_THREADS`,
320+
:data:`~resource.RLIM_SAVED_CUR`, and :data:`~resource.RLIM_SAVED_MAX`.
321+
(Contributed by Serhiy Storchaka in :gh:`137512`.)
322+
323+
315324
shelve
316325
------
317326

Lib/_pyrepl/simple_interact.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def maybe_run_command(statement: str) -> bool:
158158
input_n += 1
159159
except KeyboardInterrupt:
160160
r = _get_reader()
161+
r.cmpltn_reset()
161162
if r.input_trans is r.isearch_trans:
162163
r.do_cmd(("isearch-end", [""]))
163164
r.pos = len(r.get_unicode())

Lib/test/clinic.test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4080,13 +4080,14 @@ test_preprocessor_guarded_if_with_continuation_impl(PyObject *module)
40804080
#if CONDITION_E || CONDITION_F
40814081
#warning "different type of CPP directive"
40824082
/*[clinic input]
4083+
@permit_long_summary
40834084
test_preprocessor_guarded_if_e_or_f
40844085
Makes sure cpp.Monitor handles other directives than preprocessor conditionals.
40854086
[clinic start generated code]*/
40864087

40874088
static PyObject *
40884089
test_preprocessor_guarded_if_e_or_f_impl(PyObject *module)
4089-
/*[clinic end generated code: output=e49d24ff64ad88bc input=57b9c37f938bc4f1]*/
4090+
/*[clinic end generated code: output=e49d24ff64ad88bc input=3ca9ab4e883300ed]*/
40904091
#endif
40914092

40924093
/*[clinic input]

Lib/test/test_resource.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,23 @@ def test_pagesize(self):
200200
self.assertIsInstance(pagesize, int)
201201
self.assertGreaterEqual(pagesize, 0)
202202

203+
def test_contants(self):
204+
self.assertIsInstance(resource.RLIM_INFINITY, int)
205+
if sys.platform.startswith(('freebsd', 'solaris', 'sunos', 'aix')):
206+
self.assertHasAttr(resource, 'RLIM_SAVED_CUR')
207+
self.assertHasAttr(resource, 'RLIM_SAVED_MAX')
208+
if hasattr(resource, 'RLIM_SAVED_CUR'):
209+
self.assertIsInstance(resource.RLIM_SAVED_CUR, int)
210+
self.assertIsInstance(resource.RLIM_SAVED_MAX, int)
211+
203212
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'Linux only')
204213
def test_linux_constants(self):
205214
for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']:
206215
with contextlib.suppress(AttributeError):
207216
self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
208217

209218
def test_freebsd_contants(self):
210-
for attr in ['SWAP', 'SBSIZE', 'NPTS']:
219+
for attr in ['SWAP', 'SBSIZE', 'NPTS', 'UMTXP', 'VMEM', 'PIPEBUF']:
211220
with contextlib.suppress(AttributeError):
212221
self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
213222

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Add new constants in the :mod:`resource` module:
2+
:data:`~resource.RLIMIT_NTHR`, :data:`~resource.RLIMIT_UMTXP`,
3+
:data:`~resource.RLIMIT_PIPEBUF`, :data:`~resource.RLIMIT_THREADS`,
4+
:data:`~resource.RLIM_SAVED_CUR`, and :data:`~resource.RLIM_SAVED_MAX`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix an issue where pressing Ctrl+C during tab completion in the REPL would leave the autocompletion menu in a corrupted state.

Modules/_abc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ compute_abstract_methods(PyObject *self)
484484
#define COLLECTION_FLAGS (Py_TPFLAGS_SEQUENCE | Py_TPFLAGS_MAPPING)
485485

486486
/*[clinic input]
487+
@permit_long_summary
487488
_abc._abc_init
488489
489490
self: object
@@ -494,7 +495,7 @@ Internal ABC helper for class set-up. Should be never used outside abc module.
494495

495496
static PyObject *
496497
_abc__abc_init(PyObject *module, PyObject *self)
497-
/*[clinic end generated code: output=594757375714cda1 input=8d7fe470ff77f029]*/
498+
/*[clinic end generated code: output=594757375714cda1 input=0b3513f947736d39]*/
498499
{
499500
_abcmodule_state *state = get_abc_state(module);
500501
PyObject *data;
@@ -543,6 +544,7 @@ _abc__abc_init(PyObject *module, PyObject *self)
543544
}
544545

545546
/*[clinic input]
547+
@permit_long_summary
546548
_abc._abc_register
547549
548550
self: object
@@ -554,7 +556,7 @@ Internal ABC helper for subclasss registration. Should be never used outside abc
554556

555557
static PyObject *
556558
_abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass)
557-
/*[clinic end generated code: output=7851e7668c963524 input=ca589f8c3080e67f]*/
559+
/*[clinic end generated code: output=7851e7668c963524 input=135ab13a581b4414]*/
558560
{
559561
if (!PyType_Check(subclass)) {
560562
PyErr_SetString(PyExc_TypeError, "Can only register classes");
@@ -606,6 +608,7 @@ _abc__abc_register_impl(PyObject *module, PyObject *self, PyObject *subclass)
606608

607609

608610
/*[clinic input]
611+
@permit_long_summary
609612
_abc._abc_instancecheck
610613
611614
self: object
@@ -618,7 +621,7 @@ Internal ABC helper for instance checks. Should be never used outside abc module
618621
static PyObject *
619622
_abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
620623
PyObject *instance)
621-
/*[clinic end generated code: output=b8b5148f63b6b56f input=a4f4525679261084]*/
624+
/*[clinic end generated code: output=b8b5148f63b6b56f input=0bbc8da0ea346719]*/
622625
{
623626
PyObject *subtype, *result = NULL, *subclass = NULL;
624627
_abc_data *impl = _get_impl(module, self);
@@ -692,6 +695,7 @@ static int subclasscheck_check_registry(_abc_data *impl, PyObject *subclass,
692695
PyObject **result);
693696

694697
/*[clinic input]
698+
@permit_long_summary
695699
_abc._abc_subclasscheck
696700
697701
self: object
@@ -704,7 +708,7 @@ Internal ABC helper for subclasss checks. Should be never used outside abc modul
704708
static PyObject *
705709
_abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
706710
PyObject *subclass)
707-
/*[clinic end generated code: output=b56c9e4a530e3894 input=1d947243409d10b8]*/
711+
/*[clinic end generated code: output=b56c9e4a530e3894 input=5bf1ef712f5d3610]*/
708712
{
709713
if (!PyType_Check(subclass)) {
710714
PyErr_SetString(PyExc_TypeError, "issubclass() arg 1 must be a class");

Modules/_bz2module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ decompress(BZ2Decompressor *d, char *data, size_t len, Py_ssize_t max_length)
598598
}
599599

600600
/*[clinic input]
601+
@permit_long_docstring_body
601602
_bz2.BZ2Decompressor.decompress
602603
603604
data: Py_buffer
@@ -622,7 +623,7 @@ the unused_data attribute.
622623
static PyObject *
623624
_bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data,
624625
Py_ssize_t max_length)
625-
/*[clinic end generated code: output=23e41045deb240a3 input=52e1ffc66a8ea624]*/
626+
/*[clinic end generated code: output=23e41045deb240a3 input=3703e78f91757655]*/
626627
{
627628
PyObject *result = NULL;
628629

Modules/_codecsmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ _codecs_unregister(PyObject *module, PyObject *search_function)
9292
}
9393

9494
/*[clinic input]
95+
@permit_long_summary
9596
_codecs.lookup
9697
encoding: str
9798
/
@@ -101,7 +102,7 @@ Looks up a codec tuple in the Python codec registry and returns a CodecInfo obje
101102

102103
static PyObject *
103104
_codecs_lookup_impl(PyObject *module, const char *encoding)
104-
/*[clinic end generated code: output=9f0afa572080c36d input=3c572c0db3febe9c]*/
105+
/*[clinic end generated code: output=9f0afa572080c36d input=02227d5429491ab3]*/
105106
{
106107
return _PyCodec_Lookup(encoding);
107108
}

0 commit comments

Comments
 (0)