@@ -129,9 +129,9 @@ \section{A Simple Example
129129\end {verbatim }
130130
131131There is a straightforward translation from the argument list in
132- Python (e.g. \ the single expression \code {"ls -l"}) to the arguments
133- passed to the C function. The C function always has two arguments,
134- conventionally named \var {self} and \var {args}.
132+ Python (for example, the single expression \code {"ls -l"}) to the
133+ arguments passed to the C function. The C function always has two
134+ arguments, conventionally named \var {self} and \var {args}.
135135
136136The \var {self} argument is only used when the C function implements a
137137built-in method, not a function. In the example, \var {self} will
@@ -200,7 +200,7 @@ \section{Intermezzo: Errors and Exceptions
200200
201201When a function \var {f} that calls another function \var {g} detects
202202that the latter fails, \var {f} should itself return an error value
203- (e.g. \ \NULL {} or \code {-1}). It should \emph {not } call one of the
203+ (usually \NULL {} or \code {-1}). It should \emph {not } call one of the
204204\cfunction {PyErr_*()} functions --- one has already been called by \var {g}.
205205\var {f}'s caller is then supposed to also return an error indication
206206to \emph {its } caller, again \emph {without } calling \cfunction {PyErr_*()},
@@ -220,8 +220,8 @@ \section{Intermezzo: Errors and Exceptions
220220condition must be cleared explicitly by calling \cfunction {PyErr_Clear()}.
221221The only time C code should call \cfunction {PyErr_Clear()} is if it doesn't
222222want to pass the error on to the interpreter but wants to handle it
223- completely by itself (e.g. \ by trying something else or pretending
224- nothing happened ).
223+ completely by itself (possibly by trying something else, or pretending
224+ nothing went wrong ).
225225
226226Every failing \cfunction {malloc()} call must be turned into an
227227exception --- the direct caller of \cfunction {malloc()} (or
@@ -241,8 +241,8 @@ \section{Intermezzo: Errors and Exceptions
241241
242242The choice of which exception to raise is entirely yours. There are
243243predeclared C objects corresponding to all built-in Python exceptions,
244- e.g. \ \cdata {PyExc_ZeroDivisionError}, which you can use directly. Of
245- course, you should choose exceptions wisely --- don't use
244+ such as \cdata {PyExc_ZeroDivisionError}, which you can use directly.
245+ Of course, you should choose exceptions wisely --- don't use
246246\cdata {PyExc_TypeError} to mean that a file couldn't be opened (that
247247should probably be \cdata {PyExc_IOError}). If something's wrong with
248248the argument list, the \cfunction {PyArg_ParseTuple()} function usually
@@ -252,14 +252,14 @@ \section{Intermezzo: Errors and Exceptions
252252
253253You can also define a new exception that is unique to your module.
254254For this, you usually declare a static object variable at the
255- beginning of your file, e.g.
255+ beginning of your file:
256256
257257\begin {verbatim }
258258static PyObject *SpamError;
259259\end {verbatim }
260260
261261and initialize it in your module's initialization function
262- (\cfunction {initspam()}) with an exception object, e.g. \ (leaving out
262+ (\cfunction {initspam()}) with an exception object (leaving out
263263the error checking for now):
264264
265265\begin {verbatim }
@@ -1316,7 +1316,7 @@ \subsection{Reference Counting in Python
13161316A borrowed reference can be changed into an owned reference by calling
13171317\cfunction {Py_INCREF()}. This does not affect the status of the owner from
13181318which the reference was borrowed --- it creates a new owned reference,
1319- and gives full owner responsibilities (i.e., the new owner must
1319+ and gives full owner responsibilities (the new owner must
13201320dispose of the reference properly, as well as the previous owner).
13211321
13221322
@@ -1329,7 +1329,7 @@ \subsection{Ownership Rules
13291329
13301330Most functions that return a reference to an object pass on ownership
13311331with the reference. In particular, all functions whose function it is
1332- to create a new object, e.g. \ \cfunction {PyInt_FromLong()} and
1332+ to create a new object, such as \cfunction {PyInt_FromLong()} and
13331333\cfunction {Py_BuildValue()}, pass ownership to the receiver. Even if in
13341334fact, in some cases, you don't receive a reference to a brand new
13351335object, you still receive ownership of the reference. For instance,
@@ -1467,8 +1467,8 @@ \subsection{NULL Pointers
14671467there would be a lot of redundant tests and the code would run more
14681468slowly.
14691469
1470- It is better to test for \NULL {} only at the `` source'' , i.e. \ when a
1471- pointer that may be \NULL {} is received, e.g. \ from
1470+ It is better to test for \NULL {} only at the `` source: '' when a
1471+ pointer that may be \NULL {} is received, for example, from
14721472\cfunction {malloc()} or from a function that may raise an exception.
14731473
14741474The macros \cfunction {Py_INCREF()} and \cfunction {Py_DECREF()}
@@ -1535,11 +1535,11 @@ \section{Providing a C API for an Extension Module
15351535symbols defined in one module may not be visible to another module.
15361536The details of visibility depend on the operating system; some systems
15371537use one global namespace for the Python interpreter and all extension
1538- modules (e.g. \ Windows), whereas others require an explicit list of
1539- imported symbols at module link time (e.g. \ AIX), or offer a choice of
1540- different strategies (most Unices). And even if symbols are globally
1541- visible, the module whose functions one wishes to call might not have
1542- been loaded yet!
1538+ modules (Windows, for example ), whereas others require an explicit
1539+ list of imported symbols at module link time (AIX is one example), or
1540+ offer a choice of different strategies (most Unices). And even if
1541+ symbols are globally visible, the module whose functions one wishes to
1542+ call might not have been loaded yet!
15431543
15441544Portability therefore requires not to make any assumptions about
15451545symbol visibility. This means that all symbols in extension modules
@@ -1549,8 +1549,8 @@ \section{Providing a C API for an Extension Module
15491549means that symbols that \emph {should } be accessible from other
15501550extension modules must be exported in a different way.
15511551
1552- Python provides a special mechanism to pass C-level information (i.e.
1553- pointers) from one extension module to another one: CObjects.
1552+ Python provides a special mechanism to pass C-level information
1553+ ( pointers) from one extension module to another one: CObjects.
15541554A CObject is a Python data type which stores a pointer (\ctype {void
15551555*}). CObjects can only be created and accessed via their C API, but
15561556they can be passed around like any other Python object. In particular,
@@ -1904,7 +1904,7 @@ \section{The Basics
19041904PyObject_New(<type>, &<type object>);
19051905\end {verbatim }
19061906
1907- This allocates the memory and then initializes the object (i.e. \ sets
1907+ This allocates the memory and then initializes the object (sets
19081908the reference count to one, makes the \cdata {ob_type} pointer point at
19091909the right place and maybe some other stuff, depending on build options).
19101910You \emph {can } do these steps separately if you have some reason to
0 commit comments