make CORS configurable

allows setting CORS headers.

- cors_origin sets Access-Control-Allow-Origin directly
- cors_origin_pat allows setting Access-Control-Allow-Origin via regular expression, since the header spec itself doesn’t support complex access[1]
- cors_credentials sets Access-Control-Allow-Credentials: true

To allow CORS from everywhere:

    ipython notebook —NotebookApp.cors_origin='*'
s/cors_/allow_/

add notes about Tornado 4, and comments, updates per review
Fix NaN warnings and failures in test_serialize

don't use empty, which can create a bunch of NaNs,
causing equality tests to fail.
allow unicode keys in dicts in json_clean
don’t modify dict keys while iterating through them

in jsonutil.rekey
Remove some unhelpful info from IPython.core.completer
Add docstring for dict_key_matches
test rekey modify-in-place
persist notebook server cookie secret in security dir

prevents loss of login after relaunching the notebook server

closes #6075
Update bundled copy of pexpect to 3.3

Closes gh-6086
Merge pull request #6083 from takluyver/completer-docstrings

Some docstring improvements in completer
Merge pull request #6081 from minrk/rekey-inplace

don’t modify dict keys while iterating through them
Merge pull request #6076 from minrk/cookie-secret

persist notebook server cookie secret in security dir
remove doctests from jsonutil.json_clean

because doctests are not worth the trouble
Merge pull request #6061 from minrk/cors

make CORS configurable
Merge pull request #6077 from minrk/json-unicode-keys

allow unicode keys in dicts in json_clean
Merge pull request #6071 from minrk/serialize-nan

Fix NaN warnings and failures in test_serialize
i1673 PEP8 formatting in `ultratab.py`
i1673 implementation of py3 proper error handling

I refactored ultratab.py a bit. `structured_traceback`
function was much too long. I extracted some of the code
to separate methods.

I added support for py3
exceptions which store information about previous
exceptions in their `__context__`.
i1673 some DRY refactoring