Skip to content

Commit 7069412

Browse files
committed
Move signature check up
1 parent 27af529 commit 7069412

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Doc/extending/first-extension-module.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ You should now be able to call the function:
334334
Note that our ``spam.system`` does not yet run the ``whoami`` command;
335335
it only returns ``None``.
336336

337+
Check that the function accepts exactly one argument, as specified by
338+
the :c:data:`METH_O` flag:
339+
340+
.. code-block:: pycon
341+
342+
>>> print(spam.system('too', 'many', 'arguments'))
343+
Traceback (most recent call last):
344+
...
345+
TypeError: spam.system() takes exactly one argument (3 given)
346+
337347
338348
Returning an integer
339349
====================
@@ -495,11 +505,6 @@ You might also want to test error cases:
495505
...
496506
TypeError: bad argument type for built-in operation
497507
498-
>>> print(spam.system('too', 'many', 'arguments'))
499-
Traceback (most recent call last):
500-
...
501-
TypeError: spam.system() takes exactly one argument (3 given)
502-
503508
504509
The result
505510
==========

0 commit comments

Comments
 (0)