In the current situation, iterating over `self.data.keys()` is OK only when
the dictionary is not modified, as `self.data.keys()` is lazily generated,
at least in Python 3.
Unfortunately, as we intend to change the dictionary with the `--purge`
option, we get a runtime exception when iterating the loop.
This commit fixes it by making the generation of the list of keys occur only
once, so that the dictionary itself can be modified in the body of the loop.
Tested with both Python 2.7 and Python 3.3.
Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
exporting the prompt seems to be too harsh and breaks the shell in Emacs as the PROMPT_COMMAND for xterm (say) overwrites the 'dumb' PROMPT_COMMAND, which now is 'contaminated' with ASCII escape strings.
`path` is decoded already (coming from `db`) and this caused the
following error:
Traceback (most recent call last):
File "/home/user/.autojump/bin/autojump", line 460, in <module>
if not shell_utility(): sys.exit(1)
File "/home/user/.autojump/bin/autojump", line 429, in shell_utility
results = find_matches(db, patterns, max_matches, False)
File "/home/user/.autojump/bin/autojump", line 374, in find_matches
if current_dir == decode(os.path.realpath(path)) :
File "/home/user/.autojump/bin/autojump", line 277, in decode
return text.decode(encoding, errors)
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb4' in
position 52: ordinal not in range(128)
This regression bug was introduced when adding the KEEP_SYMLINKS option. The
current_dir was always set to '.' which would never match any database entries.
Even though the previous version works fine on OS X 10.6.8, it seems to be
causing problems for other Mac users on 10.8.x. Unfortunately I do not have
access to a newer Mac to test on.
The previous test condition would cause errors because even though brew didn't
exist, the directory /share/zsh/site-functions did and it would throw error
messages on non-homebrew systems.