Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2210:56ce956f2e0d
Date: 2015-07-05 18:50 +0200
http://bitbucket.org/cffi/cffi/changeset/56ce956f2e0d/
Log: Expand the explanation of the hack
diff --git a/doc/source/using.rst b/doc/source/using.rst
--- a/doc/source/using.rst
+++ b/doc/source/using.rst
@@ -534,9 +534,14 @@
``onerror`` itself fails---then the value of ``error`` will be
used, if any.
- Note the following hack: in ``onerror``, you can access some of the
- original callback arguments by attempting to read
- ``traceback.tb_frame.f_locals['argname']``.
+ Note the following hack: in ``onerror``, you can access the original
+ callback arguments as follows. First check if ``traceback`` is not
+ None (it is None e.g. if the whole function ran successfully but
+ there was an error converting the value returned: this occurs after
+ the call). If ``traceback`` is not None, then ``traceback.tb_frame``
+ is the frame of the outermost function, i.e. directly the one invoked
+ by the callback handler. So you can get the value of ``argname`` in
+ that frame by reading ``traceback.tb_frame.f_locals['argname']``.
FFI Interface
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit