Better handling of `__file__` when running scripts.

* Set `__file__` when running `ipython filename.ipy`
* Avoid leaking `__file__` back into the main namespace when using `%run`.
Add test for `__file__` behavior in `%run`.
Add test for `__file__` behavior in `ipython <file>`
cast unicode in oinspect.find_file
fix %edit foo for interactively defined variables

Effectively handles cases such as:

    In [1]: def foo(): return 5
    In [2]: %edit foo

Where `%edit foo` effectively turns into `%edit 1` by parsing the `<ipython-input-NN-…>` fake filename.
test %edit magic on interactively defined objects
Reset readline delimiters after loading rmagic.

Closes gh-2759
Merge pull request #2460 from bfroehle/ipy_file_inject

Better handling of `__file__` when running scripts.
Merge pull request #2763 from takluyver/rmagic-readline

Reset readline delimiters after loading rmagic.
ensure linen is defined in find_source_lines
cleanup warning/error messages when nothing is found to %edit
Define __file__ when we %edit a real file.

Closes gh-2765.
Merge pull request #2476 from minrk/editmagic

allow %edit <variable> to work for some interactively defined objects

interactively defined classes still don't work
Merge pull request #2766 from bfroehle/edit_file_attribute

Define __file__ when we %edit a real file.
Allow shutdown when no engines are registered.
Added missing quotes.
Merge pull request #2769 from dhirschfeld/clean-shutdown2

Allow shutdown when no engines are registered