8000 Merge branch 'main' into core-header-refactor · python/cpython@76b8c2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 76b8c2f

Browse files
authored
Merge branch 'main' into core-header-refactor
2 parents ae6d65f + ca1bedc commit 76b8c2f

19 files changed

+17814
-13094
lines changed

Doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
'issue_role',
3434
'lexers',
3535
'misc_news',
36-
'pydoc_topics',
3736
'pyspecific',
3837
'sphinx.ext.coverage',
3938
'sphinx.ext.doctest',

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Pending removal in Python 3.15
5757

5858
* :mod:`sysconfig`:
5959

60-
* The ``check_home`` argument of :func:`sysconfig.is_python_build` has been
60+
* The *check_home* argument of :func:`sysconfig.is_python_build` has been
6161
deprecated since Python 3.12.
6262

6363
* :mod:`threading`:

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ although there is currently no date scheduled for their removal.
111111
* ``ssl.TLSVersion.TLSv1``
112112
* ``ssl.TLSVersion.TLSv1_1``
113113

114-
* :func:`sysconfig.is_python_build` *check_home* parameter is deprecated and
115-
ignored.
116-
117114
* :mod:`threading` methods:
118115

119116
* :meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition.notify_all`.

Doc/library/cmdline.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The following modules have a command-line interface.
2525
* :ref:`json <json-commandline>`
2626
* :ref:`mimetypes <mimetypes-cli>`
2727
* :mod:`pdb`
28-
* :mod:`pickle`
28+
* :ref:`pickle <pickle-cli>`
2929
* :ref:`pickletools <pickletools-cli>`
3030
* :mod:`platform`
3131
* :mod:`poplib`

Doc/library/pickle.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,30 @@ The following example reads the resulting pickled data. ::
12101210
.. pickletools.optimize() or the gzip module).
12111211
12121212
1213+
.. _pickle-cli:
1214+
1215+
Command-line interface
1216+
----------------------
1217+
1218+
The :mod:`pickle` module can be invoked as a script from the command line,
1219+
it will display contents of the pickle files. However, when the pickle file
1220+
that you want to examine comes from an untrusted source, ``-m pickletools``
1221+
is a safer option because it does not execute pickle bytecode, see
1222+
:ref:`pickletools CLI usage <pickletools-cli>`.
1223+
1224+
.. code-block:: bash
1225+
1226+
python -m pickle pickle_file [pickle_file ...]
1227+
1228+
The following option is accepted:
1229+
1230+
.. program:: pickle
1231+
1232+
.. option:: pickle_file
1233+
1234+
A pickle file to read, or ``-`` to indicate reading from standard input.
1235+
1236+
12131237
.. seealso::
12141238

12151239
Module :mod:`copyreg`

Doc/tools/extensions/pydoc_topics.py

Lines changed: 0 additions & 188 deletions
This file was deleted.

Doc/tools/extensions/pyspecific.py

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@
1212
import re
1313
import io
1414
from os import getenv, path
15+
from time import asctime
16+
from pprint import pformat
1517

1618
from docutils import nodes
19+
from docutils.io import StringOutput
1720
from docutils.parsers.rst import directives
18-
from docutils.utils import unescape
21+
from docutils.utils import new_document, unescape
1922
from sphinx import addnodes
23+
from sphinx.builders import Builder
2024
from sphinx.domains.python import PyFunction, PyMethod, PyModule
2125
from sphinx.locale import _ as sphinx_gettext
2226
from sphinx.util.docutils import SphinxDirective
27+
from sphinx.writers.text import TextWriter, TextTranslator
28+
from sphinx.util.display import status_iterator
2329

2430
# Used in conf.py and updated here by python/release-tools/run_release.py
2531
SOURCE_URI = 'https://github.com/python/cpython/tree/main/%s'
@@ -51,6 +57,69 @@ def run(self):
5157
return PyMethod.run(self)
5258

5359

60+
# Support for building "topic help" for pydoc
61+
62+
pydoc_topic_labels = [
63+
'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers',
64+
'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await',
65+
'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
66+
'bltin-null-object', 'bltin-type-objects', 'booleans',
67+
'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound',
68+
'context-managers', 'continue', 'conversions', 'customization', 'debugger',
69+
'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel',
70+
'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global',
71+
'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers',
72+
'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types',
73+
'objects', 'operator-summary', 'pass', 'power', 'raise', 'return',
74+
'sequence-types', 'shifting', 'slicings', 'special 10000 attrs', 'specialnames',
75+
'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types',
76+
'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules',
77+
'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield'
78+
]
79+
80+
81+
class PydocTopicsBuilder(Builder):
82+
name = 'pydoc-topics'
83+
84+
default_translator_class = TextTranslator
85+
86+
def init(self):
87+
self.topics = {}
88+
self.secnumbers = {}
89+
90+
def get_outdated_docs(self):
91+
return 'all pydoc topics'
92+
93+
def get_target_uri(self, docname, typ=None):
94+
return '' # no URIs
95+
96+
def write(self, *ignored):
97+
writer = TextWriter(self)
98+
for label in status_iterator(pydoc_topic_labels,
99+
'building topics... ',
100+
length=len(pydoc_topic_labels)):
101+
if label not in self.env.domaindata['std']['labels']:
102+
self.env.logger.warning(f'label {label!r} not in documentation')
103+
continue
104+
docname, labelid, sectname = self.env.domaindata['std']['labels'][label]
105+
doctree = self.env.get_and_resolve_doctree(docname, self)
106+
document = new_document('<section node>')
107+
document.append(doctree.ids[labelid])
108+
destination = StringOutput(encoding='utf-8')
109+
writer.write(document, destination)
110+
self.topics[label] = writer.output
111+
112+
def finish(self):
113+
f = open(path.join(self.outdir, 'topics.py'), 'wb')
114+
try:
115+
f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8'))
116+
f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8'))
117+
f.write('# as part of the release process.\n'.encode('utf-8'))
118+
f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8'))
119+
finally:
120+
f.close()
121+
122+
54123
# Support for documenting Opcodes
55124

56125
opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?')
@@ -127,6 +196,7 @@ def patch_pairindextypes(app, _env) -> None:
127196

128197

129198
def setup(app):
199+
app.add_builder(PydocTopicsBuilder)
130200
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
131201
app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command)
132202
app.add_object_type('monitoring-event', 'monitoring-event', '%s (monitoring event)', parse_monitoring_event)

Include/refcount.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ static inline void _Py_DECREF_MORTAL_SPECIALIZED(const char *filename, int linen
416416
_Py_DECREF_DecRefTotal();
417417
}
418418
if (--op->ob_refcnt == 0) {
419+
#ifdef Py_TRACE_REFS
420+
_Py_ForgetReference(op);
421+
#endif
419422
destruct(op);
420423
}
421424
}
@@ -460,6 +463,9 @@ static inline void Py_DECREF_MORTAL_SPECIALIZED(PyObject *op, destructor destruc
460463
assert(!_Py_IsStaticImmortal(op));
461464
_Py_DECREF_STAT_INC();
462465
if (--op->ob_refcnt == 0) {
466+
#ifdef Py_TRACE_REFS
467+
_Py_ForgetReference(op);
468+
#endif
463469
destruct(op);
464470
}
465471
}

Lib/difflib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ def _line_pair_iterator():
16331633

16341634
_styles = """
16351635
:root {color-scheme: light dark}
1636-
table.diff {font-family:Courier; border:medium;}
1636+
table.diff {font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; border:medium}
16371637
.diff_header {background-color:#e0e0e0}
16381638
td.diff_header {text-align:right}
16391639
.diff_next {background-color:#c0c0c0}

0 commit comments

Comments
 (0)
0