Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40097b8

Browse filesBrowse files
authored
Merge branch 'python:main' into check-signals-without-gil
2 parents c021340 + 9434709 commit 40097b8
Copy full SHA for 40097b8

Some content is hidden

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

53 files changed

+1271
-237
lines changed

‎Doc/c-api/object.rst

Copy file name to clipboardExpand all lines: Doc/c-api/object.rst
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,21 @@ Object Protocol
737737
caller must hold a :term:`strong reference` to *obj* when calling this.
738738
739739
.. versionadded:: 3.14
740+
741+
.. c:function:: int PyUnstable_Object_IsUniquelyReferenced(PyObject *op)
742+
743+
Determine if *op* only has one reference.
744+
745+
On GIL-enabled builds, this function is equivalent to
746+
:c:expr:`Py_REFCNT(op) == 1`.
747+
748+
On a :term:`free threaded <free threading>` build, this checks if *op*'s
749+
:term:`reference count` is equal to one and additionally checks if *op*
750+
is only used by this thread. :c:expr:`Py_REFCNT(op) == 1` is **not**
751+
thread-safe on free threaded builds; prefer this function.
752+
753+
The caller must hold an :term:`attached thread state`, despite the fact
754+
that this function doesn't call into the Python interpreter. This function
755+
cannot fail.
756+
757+
.. versionadded:: 3.14

‎Doc/c-api/refcounting.rst

Copy file name to clipboardExpand all lines: Doc/c-api/refcounting.rst
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ of Python objects.
2323
2424
Use the :c:func:`Py_SET_REFCNT()` function to set an object reference count.
2525
26-
See also the function :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary()`.
26+
.. note::
27+
28+
On :term:`free threaded <free threading>` builds of Python, returning 1
29+
isn't sufficient to determine if it's safe to treat *o* as having no
30+
access by other threads. Use :c:func:`PyUnstable_Object_IsUniquelyReferenced`
31+
for that instead.
32+
33+
See also the function :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary()`.
2734
2835
.. versionchanged:: 3.10
2936
:c:func:`Py_REFCNT()` is changed to the inline static function.

‎Doc/whatsnew/3.14.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.14.rst
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,11 @@ pdb
14431443
fill in a 4-space indentation now, instead of inserting a ``\t`` character.
14441444
(Contributed by Tian Gao in :gh:`130471`.)
14451445

1446+
* Auto-indent is introduced in :mod:`pdb` multi-line input. It will either
1447+
keep the indentation of the last line or insert a 4-space indentation when
1448+
it detects a new code block.
1449+
(Contributed by Tian Gao in :gh:`133350`.)
1450+
14461451
* ``$_asynctask`` is added to access the current asyncio task if applicable.
14471452
(Contributed by Tian Gao in :gh:`124367`.)
14481453

@@ -2464,6 +2469,10 @@ New features
24642469
be used in some cases as a replacement for checking if :c:func:`Py_REFCNT`
24652470
is ``1`` for Python objects passed as arguments to C API functions.
24662471

2472+
* Add :c:func:`PyUnstable_Object_IsUniquelyReferenced` as a replacement for
2473+
``Py_REFCNT(op) == 1`` on :term:`free threaded <free threading>` builds.
2474+
(Contributed by Peter Bierma in :gh:`133140`.)
2475+
24672476

24682477
Limited C API changes
24692478
---------------------

‎Include/cpython/funcobject.h

Copy file name to clipboardExpand all lines: Include/cpython/funcobject.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
9797
}
9898
#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
9999

100+
static inline PyObject* PyFunction_GET_BUILTINS(PyObject *func) {
101+
return _PyFunction_CAST(func)->func_builtins;
102+
}
103+
#define PyFunction_GET_BUILTINS(func) PyFunction_GET_BUILTINS(_PyObject_CAST(func))
104+
100105
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
101106
return _PyFunction_CAST(func)->func_module;
102107
}

‎Include/cpython/object.h

Copy file name to clipboardExpand all lines: Include/cpython/object.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,5 @@ PyAPI_FUNC(int) PyUnstable_IsImmortal(PyObject *);
501501
// before calling this function in order to avoid spurious failures.
502502
PyAPI_FUNC(int) PyUnstable_TryIncRef(PyObject *);
503503
PyAPI_FUNC(void) PyUnstable_EnableTryIncRef(PyObject *);
504+
505+
PyAPI_FUNC(int) PyUnstable_Object_IsUniquelyReferenced(PyObject *);

‎Include/internal/pycore_code.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_code.h
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,57 @@ extern int _Py_ClearUnusedTLBC(PyInterpreterState *interp);
570570
#endif
571571

572572

573+
typedef struct {
574+
int total;
575+
struct co_locals_counts {
576+
int total;
577+
struct {
578+
int total;
579+
int numposonly;
580+
int numposorkw;
581+
int numkwonly;
582+
int varargs;
583+
int varkwargs;
584+
} args;
585+
int numpure;
586+
struct {
587+
int total;
588+
// numargs does not contribute to locals.total.
589+
int numargs;
590+
int numothers;
591+
} cells;
592+
struct {
593+
int total;
594+
int numpure;
595+
int numcells;
596+
} hidden;
597+
} locals;
598+
int numfree; // nonlocal
599+
struct co_unbound_counts {
600+
int total;
601+
struct {
602+
int total;
603+
int numglobal;
604+
int numbuiltin;
605+
int numunknown;
606+
} globals;
607+
int numattrs;
608+
int numunknown;
609+
} unbound;
610+
} _PyCode_var_counts_t;
611+
612+
PyAPI_FUNC(void) _PyCode_GetVarCounts(
613+
PyCodeObject *,
614+
_PyCode_var_counts_t *);
615+
PyAPI_FUNC(int) _PyCode_SetUnboundVarCounts(
616+
PyThreadState *,
617+
PyCodeObject *,
618+
_PyCode_var_counts_t *,
619+
PyObject *globalnames,
620+
PyObject *attrnames,
621+
PyObject *globalsns,
622+
PyObject *builtinsns);
623+
573624
PyAPI_FUNC(int) _PyCode_ReturnsOnlyNone(PyCodeObject *);
574625

575626

‎Lib/ast.py

Copy file name to clipboardExpand all lines: Lib/ast.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def main(args=None):
630630
import argparse
631631
import sys
632632

633-
parser = argparse.ArgumentParser()
633+
parser = argparse.ArgumentParser(color=True)
634634
parser.add_argument('infile', nargs='?', default='-',
635635
help='the file to parse; defaults to stdin')
636636
parser.add_argument('-m', '--mode', default='exec',

‎Lib/calendar.py

Copy file name to clipboardExpand all lines: Lib/calendar.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def timegm(tuple):
810810

811811
def main(args=None):
812812
import argparse
813-
parser = argparse.ArgumentParser()
813+
parser = argparse.ArgumentParser(color=True)
814814
textgroup = parser.add_argument_group('text only arguments')
815815
htmlgroup = parser.add_argument_group('html only arguments')
816816
textgroup.add_argument(

‎Lib/code.py

Copy file name to clipboardExpand all lines: Lib/code.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=Fa
385385
if __name__ == "__main__":
386386
import argparse
387387

388-
parser = argparse.ArgumentParser()
388+
parser = argparse.ArgumentParser(color=True)
389389
parser.add_argument('-q', action='store_true',
390390
help="don't print version and copyright messages")
391391
args = parser.parse_args()

‎Lib/compileall.py

Copy file name to clipboardExpand all lines: Lib/compileall.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def main():
317317
import argparse
318318

319319
parser = argparse.ArgumentParser(
320-
description='Utilities to support installing Python libraries.')
320+
description='Utilities to support installing Python libraries.',
321+
color=True,
322+
)
321323
parser.add_argument('-l', action='store_const', const=0,
322324
default=None, dest='maxlevels',
323325
help="don't recurse into subdirectories")

‎Lib/dis.py

Copy file name to clipboardExpand all lines: Lib/dis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ def dis(self):
11311131
def main(args=None):
11321132
import argparse
11331133

1134-
parser = argparse.ArgumentParser()
1134+
parser = argparse.ArgumentParser(color=True)
11351135
parser.add_argument('-C', '--show-caches', action='store_true',
11361136
help='show inline caches')
11371137
parser.add_argument('-O', '--show-offsets', action='store_true',

‎Lib/doctest.py

Copy file name to clipboardExpand all lines: Lib/doctest.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ def get(self):
28702870
def _test():
28712871
import argparse
28722872

2873-
parser = argparse.ArgumentParser(description="doctest runner")
2873+
parser = argparse.ArgumentParser(description="doctest runner", color=True)
28742874
parser.add_argument('-v', '--verbose', action='store_true', default=False,
28752875
help='print very verbose output for all tests')
28762876
parser.add_argument('-o', '--option', action='append',

‎Lib/ensurepip/__init__.py

Copy file name to clipboardExpand all lines: Lib/ensurepip/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _uninstall_helper(*, verbosity=0):
205205

206206
def _main(argv=None):
207207
import argparse
208-
parser = argparse.ArgumentParser()
208+
parser = argparse.ArgumentParser(color=True)
209209
parser.add_argument(
210210
"--version",
211211
action="version",

‎Lib/gzip.py

Copy file name to clipboardExpand all lines: Lib/gzip.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ def main():
667667
from argparse import ArgumentParser
668668
parser = ArgumentParser(description=
669669
"A simple command line interface for the gzip module: act like gzip, "
670-
"but do not delete the input file.")
670+
"but do not delete the input file.",
671+
color=True,
672+
)
671673
group = parser.add_mutually_exclusive_group()
672674
group.add_argument('--fast', action='store_true', help='compress faster')
673675
group.add_argument('--best', action='store_true', help='compress better')

‎Lib/http/server.py

Copy file name to clipboardExpand all lines: Lib/http/server.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ def test(HandlerClass=BaseHTTPRequestHandler,
13401340
import argparse
13411341
import contextlib
13421342

1343-
parser = argparse.ArgumentParser()
1343+
parser = argparse.ArgumentParser(color=True)
13441344
parser.add_argument('--cgi', action='store_true',
13451345
help='run as CGI server')
13461346
parser.add_argument('-b', '--bind', metavar='ADDRESS',

‎Lib/inspect.py

Copy file name to clipboardExpand all lines: Lib/inspect.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,7 @@ def _main():
33433343
import argparse
33443344
import importlib
33453345

3346-
parser = argparse.ArgumentParser()
3346+
parser = argparse.ArgumentParser(color=True)
33473347
parser.add_argument(
33483348
'object',
33493349
help="The object to be analysed. "

‎Lib/json/tool.py

Copy file name to clipboardExpand all lines: Lib/json/tool.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _colorize_json(json_str):
4444
def main():
4545
description = ('A simple command line interface for json module '
4646
'to validate and pretty-print JSON objects.')
47-
parser = argparse.ArgumentParser(description=description)
47+
parser = argparse.ArgumentParser(description=description, color=True)
4848
parser.add_argument('infile', nargs='?',
4949
help='a JSON file to be validated or pretty-printed',
5050
default='-')

‎Lib/mimetypes.py

Copy file name to clipboardExpand all lines: Lib/mimetypes.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,9 @@ def _default_mime_types():
698698
def _parse_args(args):
699699
from argparse import ArgumentParser
700700

701-
parser = ArgumentParser(description='map filename extensions to MIME types')
701+
parser = ArgumentParser(
702+
description='map filename extensions to MIME types', color=True
703+
)
702704
parser.add_argument(
703705
'-e', '--extension',
704706
action='store_true',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.