Skip to content

Commit 537c93e

Browse files
ambvAA-Turner
andauthored
[3.10] gh-93738: Disallow pre-v3 syntax in the C domain (GH-97962) (#97977)
Also, disable using invalid sphinx-lint 0.6.2. (cherry picked from commit f612565) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent e2591e4 commit 537c93e

File tree

7 files changed

+15
-38
lines changed

7 files changed

+15
-38
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ Tools/ssl/win32
139139

140140
# Artifacts generated by 3.11 lying around when switching branches:
141141
/_bootstrap_python
142+
/Modules/Setup.bootstrap
143+
/Modules/Setup.stdlib
142144
/Programs/_freeze_module
143145
/Python/deepfreeze/
144146
/Python/frozen_modules/

Doc/c-api/unicode.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ of Unicode characters while staying memory efficient. There are special cases
1717
for strings where all code points are below 128, 256, or 65536; otherwise, code
1818
points must be below 1114112 (which is the full Unicode range).
1919

20-
:c:type:`Py_UNICODE*` and UTF-8 representations are created on demand and cached
21-
in the Unicode object. The :c:type:`Py_UNICODE*` representation is deprecated
20+
:c:expr:`Py_UNICODE*` and UTF-8 representations are created on demand and cached
21+
in the Unicode object. The :c:expr:`Py_UNICODE*` representation is deprecated
2222
and inefficient.
2323

2424
Due to the transition between the old APIs and the new APIs, Unicode objects
@@ -30,7 +30,7 @@ can internally be in two states depending on how they were created:
3030

3131
* "legacy" Unicode objects have been created through one of the deprecated
3232
APIs (typically :c:func:`PyUnicode_FromUnicode`) and only bear the
33-
:c:type:`Py_UNICODE*` representation; you will have to call
33+
:c:expr:`Py_UNICODE*` representation; you will have to call
3434
:c:func:`PyUnicode_READY` on them before calling any other API.
3535

3636
.. note::
@@ -235,7 +235,7 @@ access internal read-only data of Unicode objects:
235235
returned buffer is always terminated with an extra null code point. It
236236
may also contain embedded null code points, which would cause the string
237237
to be truncated when used in most C functions. The ``AS_DATA`` form
238-
casts the pointer to :c:type:`const char *`. The *o* argument has to be
238+
casts the pointer to :c:expr:`const char *`. The *o* argument has to be
239239
a Unicode object (not checked).
240240
241241
.. versionchanged:: 3.3
@@ -707,7 +707,7 @@ Extension modules can continue using them, as they will not be removed in Python
707707
708708
Return a read-only pointer to the Unicode object's internal
709709
:c:type:`Py_UNICODE` buffer, or ``NULL`` on error. This will create the
710-
:c:type:`Py_UNICODE*` representation of the object if it is not yet
710+
:c:expr:`Py_UNICODE*` representation of the object if it is not yet
711711
available. The buffer is always terminated with an extra null code point.
712712
Note that the resulting :c:type:`Py_UNICODE` string may also contain
713713
embedded null code points, which would cause the string to be truncated when
@@ -734,7 +734,7 @@ Extension modules can continue using them, as they will not be removed in Python
734734
735735
Like :c:func:`PyUnicode_AsUnicode`, but also saves the :c:func:`Py_UNICODE`
736736
array length (excluding the extra null terminator) in *size*.
737-
Note that the resulting :c:type:`Py_UNICODE*` string
737+
Note that the resulting :c:expr:`Py_UNICODE*` string
738738
may contain embedded null code points, which would cause the string to be
739739
truncated when used in most C functions.
740740

Doc/conf.py

-25
Original file line numberDiff line numberDiff line change
@@ -234,28 +234,3 @@
234234
# Relative filename of the data files
235235
refcount_file = 'data/refcounts.dat'
236236
stable_abi_file = 'data/stable_abi.dat'
237-
238-
# Sphinx 2 and Sphinx 3 compatibility
239-
# -----------------------------------
240-
241-
# bpo-40204: Allow Sphinx 2 syntax in the C domain
242-
c_allow_pre_v3 = True
243-
244-
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
245-
# documentation is built with -W (warnings treated as errors).
246-
c_warn_on_allowed_pre_v3 = False
247-
248-
# Fix '!' not working with C domain when pre_v3 is enabled
249-
import sphinx
250-
251-
if sphinx.version_info[:2] < (5, 3):
252-
from sphinx.domains.c import CXRefRole
253-
254-
original_run = CXRefRole.run
255-
256-
def new_run(self):
257-
if self.disabled:
258-
return super(CXRefRole, self).run()
259-
return original_run(self)
260-
261-
CXRefRole.run = new_run

Doc/extending/newtypes.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ a special case, for which the new value passed to the handler is ``NULL``.
208208
Python supports two pairs of attribute handlers; a type that supports attributes
209209
only needs to implement the functions for one pair. The difference is that one
210210
pair takes the name of the attribute as a :c:expr:`char\*`, while the other
211-
accepts a :c:type:`PyObject\*`. Each type can use whichever pair makes more
211+
accepts a :c:expr:`PyObject*`. Each type can use whichever pair makes more
212212
sense for the implementation's convenience. ::
213213

214214
getattrfunc tp_getattr; /* char * version */
@@ -219,7 +219,7 @@ sense for the implementation's convenience. ::
219219

220220
If accessing attributes of an object is always a simple operation (this will be
221221
explained shortly), there are generic implementations which can be used to
222-
provide the :c:type:`PyObject\*` version of the attribute management functions.
222+
provide the :c:expr:`PyObject*` version of the attribute management functions.
223223
The actual need for type-specific attribute handlers almost completely
224224
disappeared starting with Python 2.2, though there are many examples which have
225225
not been updated to use some of the new generic mechanism that is available.
@@ -341,7 +341,7 @@ Type-specific Attribute Management
341341

342342
For simplicity, only the :c:expr:`char\*` version will be demonstrated here; the
343343
type of the name parameter is the only difference between the :c:expr:`char\*`
344-
and :c:type:`PyObject\*` flavors of the interface. This example effectively does
344+
and :c:expr:`PyObject*` flavors of the interface. This example effectively does
345345
the same thing as the generic example above, but does not use the generic
346346
support added in Python 2.2. It explains how the handler functions are
347347
called, so that if you do need to extend their functionality, you'll understand
@@ -572,7 +572,7 @@ performance-critical objects (such as numbers).
572572

573573
For an object to be weakly referencable, the extension type must do two things:
574574

575-
#. Include a :c:type:`PyObject\*` field in the C object structure dedicated to
575+
#. Include a :c:expr:`PyObject*` field in the C object structure dedicated to
576576
the weak reference mechanism. The object's constructor should leave it
577577
``NULL`` (which is automatic when using the default
578578
:c:member:`~PyTypeObject.tp_alloc`).

Doc/extending/newtypes_tutorial.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The Basics
2424
==========
2525

2626
The :term:`CPython` runtime sees all Python objects as variables of type
27-
:c:type:`PyObject\*`, which serves as a "base type" for all Python objects.
27+
:c:expr:`PyObject*`, which serves as a "base type" for all Python objects.
2828
The :c:type:`PyObject` structure itself only contains the object's
2929
:term:`reference count` and a pointer to the object's "type object".
3030
This is where the action is; the type object determines which (C) functions

Doc/whatsnew/2.2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ code, none of the changes described here will affect you very much.
11021102
* A different argument parsing function, :c:func:`PyArg_UnpackTuple`, has been
11031103
added that's simpler and presumably faster. Instead of specifying a format
11041104
string, the caller simply gives the minimum and maximum number of arguments
1105-
expected, and a set of pointers to :c:type:`PyObject\*` variables that will be
1105+
expected, and a set of pointers to :c:expr:`PyObject*` variables that will be
11061106
filled in with argument values.
11071107

11081108
* Two new flags :const:`METH_NOARGS` and :const:`METH_O` are available in method

Doc/whatsnew/2.5.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ attribute of the function object to change this::
17251725
``ctypes.pythonapi`` object. This object does *not* release the global
17261726
interpreter lock before calling a function, because the lock must be held when
17271727
calling into the interpreter's code. There's a :class:`py_object()` type
1728-
constructor that will create a :c:type:`PyObject \*` pointer. A simple usage::
1728+
constructor that will create a :c:expr:`PyObject *` pointer. A simple usage::
17291729

17301730
import ctypes
17311731

0 commit comments

Comments
 (0)