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

Crash during todo list due to sort comparison #24

Closed
jlbribeiro opened this issue Apr 22, 2016 · 2 comments
Closed

Crash during todo list due to sort comparison #24

jlbribeiro opened this issue Apr 22, 2016 · 2 comments
Labels

Comments

@jlbribeiro
Copy link
Contributor

jlbribeiro commented Apr 22, 2016

I installed todoman yesterday (version 1.6.0); after getting it to read my vdir the list command fails to list my todos; it throws

Traceback (most recent call last):
  File "/usr/local/bin/todo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/todoman/cli.py", line 64, in cli
    ctx.invoke(cli.commands["list"])
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/todoman/cli.py", line 232, in list
    reverse=reverse
TypeError: other argument must be K instance

By printing the value of rv (main.py#L82) we get

[0, False, inf, <functools.KeyWrapper object at 0x7fd9f2cd1970>]
[0, False, inf, <functools.KeyWrapper object at 0x7fd9f2cd18f0>]
...
[<functools.KeyWrapper object at 0x7fd9f2cd19b0>, False, inf, <functools.KeyWrapper object at 0x7fd9f2cd1990>]

which causes the comparison to fail when the first and last todos are compared, since the first element is of a different type. The first element is for the priority field (main.py#L40); because it is a "negative" field it enters the main.py#L73 condition. I believe the fix should be to change the condition to if neg, in order to allow the comparison to occur. I've PR'd in #25, please check it and see if I'm understanding this correctly. Tell me if you need any sample data or more info.

And thank you very much for developing and maintaining todoman, I was looking for a CLI todo manager for a while!

@WhyNotHugo
Copy link
Member

WhyNotHugo commented Apr 22, 2016

Thanks for tracking down the issue. I recently added a unit test, that exposes this bug (currently, master is failing due to it), but failed horribly to track down what was causing it.

WhyNotHugo pushed a commit that referenced this issue Apr 22, 2016
Fix #24: return a KeyWrapper when negating values
@WhyNotHugo
Copy link
Member

Ah, and thanks for the kind words regarding todoman. It's nice to know it's of use to others! :)

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

No branches or pull requests

3 participants