Issue547

This is my proposed fix for a very old issue: https://github.com/ipython/ipython/issues/547