[docs] [issue18840] Tutorial recommends pickle module without any warning of insecurity
report at bugs.python.org
Wed Dec 4 13:40:38 CET 2013
Nick Coghlan added the comment:
Since this particular tutorial section was written long before the json module was part of the standard library, I think it makes sense to switch now we have the option.
pickle is definitely a useful tool, but now that JSON is available by default, it's now one to escalate to if JSON doesn't meet your needs, rather than the one to use by default.
Chris's patch looks generally good to me, although I think it could use a second paragraph in the pickle section. Perhaps something like:
"""JSON is much simpler to use safely than pickle, and offers broader interoperability with programs written in other languages. However, pickle has the advantage of supporting a much wider range of Python object types, including executable code, which means it can handle use cases that JSON can't (like sending code to another process for execution)"
This simpler/safer/less powerful API/technique vs more powerful/more dangerous API/technique trade-off is a fairly common one, so I think it's a good thing to have a concrete example of it in the tutorial rather than just dropping the reference to pickle entirely.
Python tracker <report at bugs.python.org>
More information about the docs