Some fixes from running pyflakes on latest ipython master branch

Some relatively minor bug fixes caught by pyflakes on ipython master branch.