howdoi icon indicating copy to clipboard operation
howdoi copied to clipboard

pickle.UnpicklingError: the STRING opcode argument must be quoted

Open jabir366 opened this issue 3 years ago • 4 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

jabir366 avatar Mar 25 '22 08:03 jabir366

I would like to contribute to fixing this issue

jabir366 avatar Mar 25 '22 08:03 jabir366

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

gleitz avatar Mar 27 '22 20:03 gleitz

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!

mbuhidar avatar May 07 '22 18:05 mbuhidar

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

gleitz avatar May 13 '22 03:05 gleitz