Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit40097b8

Browse files
authored
Merge branch 'python:main' into check-signals-without-gil
2 parentsc021340 +9434709 commit40097b8

File tree

53 files changed

+1271
-237
lines changed

Some content is hidden

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

53 files changed

+1271
-237
lines changed

‎Doc/c-api/object.rst

Lines 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::intPyUnstable_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

Lines 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

Lines 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

Lines 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
#definePyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
9999

100+
staticinlinePyObject*PyFunction_GET_BUILTINS(PyObject*func) {
101+
return_PyFunction_CAST(func)->func_builtins;
102+
}
103+
#definePyFunction_GET_BUILTINS(func) PyFunction_GET_BUILTINS(_PyObject_CAST(func))
104+
100105
staticinlinePyObject*PyFunction_GET_MODULE(PyObject*func) {
101106
return_PyFunction_CAST(func)->func_module;
102107
}

‎Include/cpython/object.h

Lines 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

Lines 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+
typedefstruct {
574+
inttotal;
575+
structco_locals_counts {
576+
inttotal;
577+
struct {
578+
inttotal;
579+
intnumposonly;
580+
intnumposorkw;
581+
intnumkwonly;
582+
intvarargs;
583+
intvarkwargs;
584+
}args;
585+
intnumpure;
586+
struct {
587+
inttotal;
588+
// numargs does not contribute to locals.total.
589+
intnumargs;
590+
intnumothers;
591+
}cells;
592+
struct {
593+
inttotal;
594+
intnumpure;
595+
intnumcells;
596+
}hidden;
597+
}locals;
598+
intnumfree;// nonlocal
599+
structco_unbound_counts {
600+
inttotal;
601+
struct {
602+
inttotal;
603+
intnumglobal;
604+
intnumbuiltin;
605+
intnumunknown;
606+
}globals;
607+
intnumattrs;
608+
intnumunknown;
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def main(args=None):
630630
importargparse
631631
importsys
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def timegm(tuple):
810810

811811
defmain(args=None):
812812
importargparse
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

Lines 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
importargparse
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def main():
317317
importargparse
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ def dis(self):
11311131
defmain(args=None):
11321132
importargparse
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ def get(self):
28702870
def_test():
28712871
importargparse
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

Lines 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
importargparse
208-
parser=argparse.ArgumentParser()
208+
parser=argparse.ArgumentParser(color=True)
209209
parser.add_argument(
210210
"--version",
211211
action="version",

‎Lib/gzip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ def main():
667667
fromargparseimportArgumentParser
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ def test(HandlerClass=BaseHTTPRequestHandler,
13401340
importargparse
13411341
importcontextlib
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,7 @@ def _main():
33433343
importargparse
33443344
importimportlib
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _colorize_json(json_str):
4444
defmain():
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

Lines 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
fromargparseimportArgumentParser
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)

[8]ページ先頭

©2009-2025 Movatter.jp