summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
author= <=>2015-03-28 13:08:54 -0600
committer= <=>2015-03-28 13:46:01 -0600
commit7c180c36ec3b3e5c79ae82f79f35be7b91f237e7 (patch)
tree8f30a94638c4e4f6280786abb24860f6ec8cc6b6 /README.rst
parentd3e56d10d17d06223fe26f48259bbe6977614e11 (diff)
Add to_dict method and from_dict classmethod on Tracebacks
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst33
1 files changed, 33 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index d9aa30f..cd0f14c 100644
--- a/README.rst
+++ b/README.rst
@@ -199,6 +199,39 @@ It is used by the ``pickling_support``. You can use it too if you want more flex
raise Exception('fail')
Exception: fail
+
+You can use the ``to_dict`` method and the ``from_dict`` classmethod to
+convert a Traceback into and from a dictionary serializable by the stdlib
+json.JSONDecoder::
+
+ >>> import json
+ >>> from tblib import Traceback
+ >>> try:
+ ... inner_2()
+ ... except:
+ ... et, ev, tb = sys.exc_info()
+ ... tb = Traceback(tb)
+ ... tb_json = json.dumps(tb.to_dict())
+ ... tb_2 = Traceback.from_dict(json.loads(tb_json))
+ ... reraise(et, ev, tb.as_traceback())
+ ...
+ Traceback (most recent call last):
+ ...
+ File "<doctest README.rst[21]>", line 6, in <module>
+ reraise(et, ev, tb.as_traceback())
+ File "<doctest README.rst[21]>", line 2, in <module>
+ inner_2()
+ File "<doctest README.rst[5]>", line 2, in inner_2
+ inner_1()
+ File "<doctest README.rst[4]>", line 2, in inner_1
+ inner_0()
+ File "<doctest README.rst[3]>", line 2, in inner_0
+ raise Exception('fail')
+ Exception: fail
+
+
+
+
Decorators
==========