Backport PR #4086: fix missing errno import

trivial fix, this import was missing, but it's only triggered when there's a
race condition, which is why this hasn't come up.
Backport PR #4115: Update docs on declaring a magic function

The extension docs were telling people to use `define_magic()`, but the docstring says it is deprecated, and it only supports line magics.

The replacement seems to be `register_magic_function()`. This directs people to that, and ensures that it is documented.
Backport PR #4096: minor docs changes

the parallel_task_old.rst file hasn't been changed in 5 years, probably time
to scrap it?

pining @ellisonbg who wrote that document originally
Backport PR #4054: use unicode for HTML export

not utf8-encoded bytes

should close #3807
Backport PR #4118: ZMQ heartbeat channel: catch EINTR exceptions and continue.

The zmq heartbeat channel exits when it encounters an
"Interrupted system call", thereby causing the qtconsole to
report that it is not responding, despite the console working
perfectly fine. Observed in a large Qt application embedding
the ipython qtconsole in KDE desktop.
Fixes #2310
Inspired by #501