When trying to refactor in a file containing an except clause using the 'except ... as' syntax, Rope throws a MismatchedTokenError while parsing.
In the code sample below, attempting to extract line 3 (foo = [...]) as a method produces the given traceback.
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\ropemode\decorators.py", line 53, in newfunc
return func(*args, **kwds)
File "c:\Python27\lib\site-packages\ropemode\interface.py", line 52, in do_refactor
refactoring(self, self.env).show(initial_asking=initial_asking)
File "c:\Python27\lib\site-packages\ropemode\refactor.py", line 43, in show
changes = runtask(self.env, calculate, name=name)
File "c:\Python27\lib\site-packages\ropemode\refactor.py", line 469, in runtask
return RunTask(env, command, name, interrupts)()
File "c:\Python27\lib\site-packages\ropemode\refactor.py", line 489, in __call__
result = self.task(handle)
File "c:\Python27\lib\site-packages\ropemode\refactor.py", line 41, in calculate
return self._calculate_changes(result, handle)
File "c:\Python27\lib\site-packages\ropemode\refactor.py", line 298, in _calculate_changes
global_=global_)
File "c:\Python27\lib\site-packages\rope\refactor\extract.py", line 68, in get_changes
new_contents = _ExtractPerformer(info).extract()
File "c:\Python27\lib\site-packages\rope\refactor\extract.py", line 214, in extract
extract_info = self._collect_info()
File "c:\Python27\lib\site-packages\rope\refactor\extract.py", line 243, in _collect_info
self._find_matches(extract_collector)
File "c:\Python27\lib\site-packages\rope\refactor\extract.py", line 249, in _find_matches
finder = similarfinder.SimilarFinder(self.info.pymodule)
File "c:\Python27\lib\site-packages\rope\refactor\similarfinder.py", line 26, in __init__
pymodule.source_code, pymodule.get_ast(), self._does_match)
File "c:\Python27\lib\site-packages\rope\refactor\similarfinder.py", line 72, in __init__
self._init_using_ast(node, source)
File "c:\Python27\lib\site-packages\rope\refactor\similarfinder.py", line 81, in _init_using_ast
patchedast.patch_ast(node, source)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 33, in patch_ast
ast.call_for_nodes(node, walker)
File "c:\Python27\lib\site-packages\rope\base\ast.py", line 53, in call_for_nodes
result = callback(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 75, in __call__
return method(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 483, in _Module
self._handle(node, list(node.body), eat_spaces=True)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 103, in _handle
ast.call_for_nodes(child, self)
File "c:\Python27\lib\site-packages\rope\base\ast.py", line 53, in call_for_nodes
result = callback(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 75, in __call__
return method(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 563, in _TryExcept
self._handle(node, children)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 103, in _handle
ast.call_for_nodes(child, self)
File "c:\Python27\lib\site-packages\rope\base\ast.py", line 53, in call_for_nodes
result = callback(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 75, in __call__
return method(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 566, in _ExceptHandler
self._excepthandler(node)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 576, in _excepthandler
self._handle(node, children)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 115, in _handle
region = self.source.consume(child)
File "c:\Python27\lib\site-packages\rope\refactor\patchedast.py", line 638, in consume
(token, self._get_location()))
MismatchedTokenError: Token <,> at (9, 16) cannot be matched