@@ -33,7 +33,7 @@ Linux), or Windows.
3333On other systems, you might need to adjust some details -- for example,
3434a system command name.
3535
36- You need to have suitable C compiler and Python development headers installed.
36+ You need to have a suitable C compiler and Python development headers installed.
3737On Linux, headers are often in a package like ``python3-dev ``
3838or ``python3-devel ``.
3939
@@ -95,7 +95,7 @@ Start with the headers
9595======================
9696
9797Begin by creating a directory for this tutorial, and switching to it
98- on command line.
98+ on the command line.
9999Then, create a file named :file: `spammodule.c ` in your directory.
100100[#why-spammodule ]_
101101
@@ -254,9 +254,9 @@ The slot table
254254
255255Rather than ``NULL ``, the export hook should return the information needed to
256256create a module.
257- Let's with the basics: the name and docstring.
257+ Let's start with the basics: the name and docstring.
258258
259- The information should de defined in as ``static `` array of
259+ The information should be defined in a ``static `` array of
260260:c:type: `PyModuleDef_Slot ` entries, which are essentially key-value pairs.
261261Define this array just before your export hook:
262262
@@ -269,12 +269,12 @@ Define this array just before your export hook:
269269 };
270270
271271 For both :c:data: `Py_mod_name ` and :c:data: `Py_mod_doc `, the values are C
272- strings -- that is, NUL-terminated UTF-8 encoded byte arrays.
272+ strings -- that is, NUL-terminated, UTF-8 encoded byte arrays.
273273
274274Note the zero-filled sentinel entry at the end.
275275If you forget it, you'll trigger undefined behavior.
276276
277- The array is defined as ``static `` -- not visible outside this ``.c `` file.
277+ The array is defined as ``static `` -- that is, not visible outside this ``.c `` file.
278278This will be a common theme.
279279CPython only needs to access the export hook; all global variables
280280and all other functions should generally be ``static ``, so that they don't
@@ -299,7 +299,7 @@ Now, recompile and try it out:
299299 >>> print(spam)
300300 <module 'spam' from '/home/encukou/dev/cpython/spam.so'>
301301
302- You have a extension module!
302+ You have an extension module!
303303Try ``help(spam) `` to see the docstring.
304304
305305The next step will be adding a function.
@@ -317,7 +317,7 @@ objects to C values, and the C return value back to Python.
317317One of the simplest ways to write glue code is a ":c:data: `METH_O `" function,
318318which takes two Python objects and returns one.
319319All Python objects -- regardless of the Python type -- are represented in C
320- as pointers to the `` PyObject ` ` structure.
320+ as pointers to the :c:type: ` PyObject ` structure.
321321
322322Add such a function above the slots array::
323323
@@ -363,7 +363,7 @@ Add this array just below the ``spam_system`` function:
363363As with module slots, a zero-filled sentinel marks the end of the array.
364364
365365Next, we'll add the method to the module.
366- Add a :c:data: `Py_mod_methods ` slot to your a :c:type: `PyMethodDef ` array:
366+ Add a :c:data: `Py_mod_methods ` slot to your :c:type: `PyMethodDef ` array:
367367
368368.. literalinclude :: ../includes/capi-extension/spammodule-01.c
369369 :start-after: /// Module slot table
@@ -408,7 +408,7 @@ Eventually this will be the exit code of a system command,
408408but let's start with a fixed value, say, ``3 ``.
409409
410410The Python C API provides a function to create a Python :py:type: `int ` object
411- from a C ``int `` values : :c:func: `PyLong_FromLong `. [#why-pylongfromlong ]_
411+ from a C ``int `` value : :c:func: `PyLong_FromLong `. [#why-pylongfromlong ]_
412412
413413To call it, replace the ``Py_RETURN_NONE `` with the following 3 lines:
414414
@@ -513,7 +513,7 @@ Add an ``if`` block for this:
513513 }
514514
515515 That's it for the setup.
516- Now, all that is left is calling C library function :c:func: `system ` with
516+ Now, all that is left is calling the C library function :c:func: `system ` with
517517the ``char * `` buffer, and using its result instead of the ``3 ``:
518518
519519.. code-block :: c
0 commit comments