Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%paste doesn't work on py3 #1916

Closed
minrk opened this issue Jun 11, 2012 · 5 comments · Fixed by #1932
Closed

%paste doesn't work on py3 #1916

minrk opened this issue Jun 11, 2012 · 5 comments · Fixed by #1932
Labels
Milestone

Comments

@minrk
Copy link
Member

minrk commented Jun 11, 2012

.../lib/python/site-packages/ipython-0.13.dev-py3.2.egg/IPython/core/hooks.py in add(self, func, priority)
    149     def add(self, func, priority=0):
    150         """ Add a func to the cmd chain with given priority """
--> 151         bisect.insort(self.chain,(priority,func))
    152 
    153     def __iter__(self):

TypeError: unorderable types: function() < function()

Functions are no longer orderable, so sorting [(1,func), (1,funcB)] fails.

@fperez
Copy link
Member

fperez commented Jun 11, 2012

It would be good to have a test for this that doesn't require calling the actual %paste itself (we don't want GUI/clipboard issues in the test suite) but at least that exercises its internals, to detect this kind of thing automatically in the future.

@takluyver
Copy link
Member

I think a test for CommandChainDispatcher should suffice.

%paste works fine on Linux, presumably because there's only one function in the chain, so sorting is never an issue.

@minrk
Copy link
Member Author

minrk commented Jun 11, 2012

We can test it, because it's in the CommandChainDispatcher itself.

I really hate the stricter comparison rules added to Python 3.

@bfroehle
Copy link
Contributor

This also would not be an issue if bisect allowed the user to specify a key. It's easy to add a test. In fact we just added some tests for CommandChainDispatcher, but never had two functions with the same priority.

@minrk
Copy link
Member Author

minrk commented Jun 12, 2012

Since bisect can't do what's appropriate with the terrible decisions in Python 3, I think we should just skip it and implement it ourself. There's no reason we need any kind of sorting optimization for a list with single-digit length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants