[Python-checkins] Fix inaccuracies in "Assorted Topics" section of "Defining Extension Types" tutorial (#104969)

kumaraditya303 webhook-mailer at python.org
Fri Jun 16 03:11:02 EDT 2023


https://github.com/python/cpython/commit/0d0963737a0f4b7cadedfae7e8fd33ed18269289
commit: 0d0963737a0f4b7cadedfae7e8fd33ed18269289
branch: main
author: chgnrdv <52372310+chgnrdv at users.noreply.github.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2023-06-16T07:10:59Z
summary:

Fix inaccuracies in "Assorted Topics" section of "Defining Extension Types" tutorial (#104969)

files:
M Doc/extending/newtypes.rst

diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index 6852a385f0c63..7f8f8ddaaaccd 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -168,7 +168,7 @@ representation of the instance for which it is called.  Here is a simple
 example::
 
    static PyObject *
-   newdatatype_repr(newdatatypeobject * obj)
+   newdatatype_repr(newdatatypeobject *obj)
    {
        return PyUnicode_FromFormat("Repr-ified_newdatatype{{size:%d}}",
                                    obj->obj_UnderlyingDatatypePtr->size);
@@ -188,7 +188,7 @@ used instead.
 Here is a simple example::
 
    static PyObject *
-   newdatatype_str(newdatatypeobject * obj)
+   newdatatype_str(newdatatypeobject *obj)
    {
        return PyUnicode_FromFormat("Stringified_newdatatype{{size:%d}}",
                                    obj->obj_UnderlyingDatatypePtr->size);
@@ -338,7 +338,7 @@ Here is an example::
 
        PyErr_Format(PyExc_AttributeError,
                     "'%.100s' object has no attribute '%.400s'",
-                    tp->tp_name, name);
+                    Py_TYPE(obj)->tp_name, name);
        return NULL;
    }
 
@@ -379,7 +379,7 @@ Here is a sample implementation, for a datatype that is considered equal if the
 size of an internal pointer is equal::
 
    static PyObject *
-   newdatatype_richcmp(PyObject *obj1, PyObject *obj2, int op)
+   newdatatype_richcmp(newdatatypeobject *obj1, newdatatypeobject *obj2, int op)
    {
        PyObject *result;
        int c, size1, size2;
@@ -478,7 +478,7 @@ This function takes three arguments:
 Here is a toy ``tp_call`` implementation::
 
    static PyObject *
-   newdatatype_call(newdatatypeobject *self, PyObject *args, PyObject *kwds)
+   newdatatype_call(newdatatypeobject *obj, PyObject *args, PyObject *kwds)
    {
        PyObject *result;
        const char *arg1;



More information about the Python-checkins mailing list