gleitz / howdoi

instant coding answers via the command line

Home Page:http://blog.gleitzman.com/post/43330157197/howdoi-instant-coding-answers-via-the-command-line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pickle.UnpicklingError: the STRING opcode argument must be quoted

jabir366 opened this issue · comments

What happened:

While querrying using howdoi, the program crashed . the query i used is howdoi get current branch git

What you expected to happen:

A simple one lined answer for my obvious query

Output with --explain

$ howdoi YOUR_COMMAND --explain
root@jjabir ~/j/bb# howdoi get current branch git --explain
INFO: Version: 2.0.19
INFO: Fetching answers for query: get current branch git
INFO: Searching google with URL: https://www.google.com/search?q=site:stackoverflow.com%20get%20current%20branch%20git&hl=en
Traceback (most recent call last):
  File "/usr/local/bin/howdoi", line 11, in <module>
    sys.exit(command_line_runner())
  File "/usr/local/lib/python3.6/dist-packages/howdoi/howdoi.py", line 815, in command_line_runner
    utf8_result = howdoi(args).encode('utf-8', 'ignore')
  File "/usr/local/lib/python3.6/dist-packages/howdoi/howdoi.py", line 633, in howdoi
    res = _get_answers(args)
  File "/usr/local/lib/python3.6/dist-packages/howdoi/howdoi.py", line 433, in _get_answers
    question_links = _get_links_with_cache(args['query'])
  File "/usr/local/lib/python3.6/dist-packages/howdoi/howdoi.py", line 417, in _get_links_with_cache
    cache.set(cache_key, question_links or CACHE_EMPTY_VAL)
  File "/usr/local/lib/python3.6/dist-packages/cachelib/file.py", line 215, in set
    self._prune()
  File "/usr/local/lib/python3.6/dist-packages/cachelib/file.py", line 152, in _prune
    self._remove_expired(now)
  File "/usr/local/lib/python3.6/dist-packages/cachelib/file.py", line 99, in _remove_expired
    expires = pickle.load(f)
_pickle.UnpicklingError: the STRING opcode argument must be quoted

I would like to contribute to fixing this issue

Looks interesting. Any idea why you think it's happening?

I had the same error after upgrading to Python 3.10. Clearing the cache using howdoi -C fixed it for me.
Great tool btw - thank you!

@jabir366 one solution here would be to catch that error and to offer a message suggesting the user clear the cache.