abingham / traad

An JSON+HTTP server for the rope Python refactoring library
MIT License
107 stars 20 forks source link

AttributeError: 'Call' object has no attribute 'starargs' #91

Open shackra opened 7 years ago

shackra commented 7 years ago

Calling traad-extract-method inside any random portion of Python code cause this error without making the user aware something wrong happened.

DEBUG:pykka:Registered Project (urn:uuid:8e29cd98-5777-4df8-9e91-1eb8411e4014)
DEBUG:pykka:Starting Project("/home/jorge/proyectos/bitbucket.org/esavara/thmdl/")
DEBUG:pykka:Registered State (urn:uuid:9d4f62f4-ff7a-4f45-ae54-577243612efd)
DEBUG:pykka:Starting State (urn:uuid:9d4f62f4-ff7a-4f45-ae54-577243612efd)
INFO:traad.server:Python version: 3.6.1 (default, Mar 27 2017, 01:39:26) 
[GCC 6.3.1 20170306]
INFO:traad.server:Running traad server for app "<traad.app.ProjectApp object at 0xb6e93acc>" at localhost:0
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://localhost:34875/
Hit Ctrl-C to quit.

127.0.0.1 - - [16/Jun/2017 22:34:30] "GET /protocol_version HTTP/1.1" 200 23
INFO:traad.app:<pykka.proxy._CallableProxy object at 0xb5c7c6ec>: ('asdads', '/home/jorge/proyectos/bitbucket.org/esavara/thmdl/thomann.py', 1171, 1476)
INFO:traad.app:<pykka.proxy._CallableProxy object at 0xb5c7c6ec>: success
INFO:traad.trace:extract_method(Project("/hom...avara/thmdl/"), <traad.state....at 0xb5c83b2c>, 'asdads', '/home/jorge/...dl/thomann.py', 1171, 1476)
INFO:traad.trace:_extract(Project("/hom...avara/thmdl/"), <traad.state....at 0xb5c83b2c>, <class 'rope....xtractMethod'>, 'asdads', '/home/jorge/...dl/thomann.py', 1171, 1476)
INFO:rope_interface:Validating
INFO:rope_interface:Done validating
127.0.0.1 - - [16/Jun/2017 22:36:12] "POST /refactor/extract_method HTTP/1.1" 200 35
ERROR:traad.trace:Exception in _extract: Traceback (most recent call last):
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/trace.py", line 30, in trace
    return f(*args, **kw)
  File "<decorator-gen-15>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/validate.py", line 13, in validate
    return f(self, *args, **kwargs)
  File "<decorator-gen-14>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/state.py", line 91, in task_state_monitor
    r = f(self, task_state, *args, **kwargs)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/extract.py", line 23, in _extract
    change = ref.get_change(name)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 90, in get_change
    return Change(self.rope_ref, *args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 53, in __init__
    self.changes = self.refactoring.get_all_changes(*args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/multiproject.py", line 49, in get_all_changes
    result.append((project, refactoring.get_changes(*args, **kwds)))
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 68, in get_changes
    new_contents = _ExtractPerformer(info).extract()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 214, in extract
    extract_info = self._collect_info()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 242, in _collect_info
    self._find_definition(extract_collector)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 296, in _find_definition
    collector.body_pattern = parts.get_body_pattern()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 430, in get_body_pattern
    return similarfinder.make_pattern(self._get_body(), variables)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 344, in make_pattern
    finder = RawSimilarFinder(code, does_match=does_match)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 72, in __init__
    self._init_using_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 81, in _init_using_ast
    patchedast.patch_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 33, in patch_ast
    ast.call_for_nodes(node, walker)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 489, in _Module
    self._handle(node, list(node.body), eat_spaces=True)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 240, in _Assign
    self._handle(node, children)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 266, in _Call
    if node.starargs is not None:
AttributeError: 'Call' object has no attribute 'starargs'

ERROR:traad.trace:Exception in extract_method: Traceback (most recent call last):
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/trace.py", line 30, in trace
    return f(*args, **kw)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/extract.py", line 52, in extract_method
    end_offset)
  File "<decorator-gen-16>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/trace.py", line 30, in trace
    return f(*args, **kw)
  File "<decorator-gen-15>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/validate.py", line 13, in validate
    return f(self, *args, **kwargs)
  File "<decorator-gen-14>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/state.py", line 91, in task_state_monitor
    r = f(self, task_state, *args, **kwargs)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/extract.py", line 23, in _extract
    change = ref.get_change(name)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 90, in get_change
    return Change(self.rope_ref, *args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 53, in __init__
    self.changes = self.refactoring.get_all_changes(*args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/multiproject.py", line 49, in get_all_changes
    result.append((project, refactoring.get_changes(*args, **kwds)))
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 68, in get_changes
    new_contents = _ExtractPerformer(info).extract()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 214, in extract
    extract_info = self._collect_info()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 242, in _collect_info
    self._find_definition(extract_collector)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 296, in _find_definition
    collector.body_pattern = parts.get_body_pattern()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 430, in get_body_pattern
    return similarfinder.make_pattern(self._get_body(), variables)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 344, in make_pattern
    finder = RawSimilarFinder(code, does_match=does_match)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 72, in __init__
    self._init_using_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 81, in _init_using_ast
    patchedast.patch_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 33, in patch_ast
    ast.call_for_nodes(node, walker)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 489, in _Module
    self._handle(node, list(node.body), eat_spaces=True)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 240, in _Assign
    self._handle(node, children)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 266, in _Call
    if node.starargs is not None:
AttributeError: 'Call' object has no attribute 'starargs'

DEBUG:pykka:Exception returned from Project("/home/jorge/proyectos/bitbucket.org/esavara/thmdl/") to caller:
Traceback (most recent call last):
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/pykka/actor.py", line 201, in _actor_loop
    response = self._handle_receive(message)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/pykka/actor.py", line 295, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "<decorator-gen-17>", line 2, in extract_method
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/trace.py", line 30, in trace
    return f(*args, **kw)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/extract.py", line 52, in extract_method
    end_offset)
  File "<decorator-gen-16>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/trace.py", line 30, in trace
    return f(*args, **kw)
  File "<decorator-gen-15>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/validate.py", line 13, in validate
    return f(self, *args, **kwargs)
  File "<decorator-gen-14>", line 2, in _extract
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/state.py", line 91, in task_state_monitor
    r = f(self, task_state, *args, **kwargs)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/extract.py", line 23, in _extract
    change = ref.get_change(name)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 90, in get_change
    return Change(self.rope_ref, *args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/traad/rope/project.py", line 53, in __init__
    self.changes = self.refactoring.get_all_changes(*args)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/multiproject.py", line 49, in get_all_changes
    result.append((project, refactoring.get_changes(*args, **kwds)))
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 68, in get_changes
    new_contents = _ExtractPerformer(info).extract()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 214, in extract
    extract_info = self._collect_info()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 242, in _collect_info
    self._find_definition(extract_collector)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 296, in _find_definition
    collector.body_pattern = parts.get_body_pattern()
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/extract.py", line 430, in get_body_pattern
    return similarfinder.make_pattern(self._get_body(), variables)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 344, in make_pattern
    finder = RawSimilarFinder(code, does_match=does_match)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 72, in __init__
    self._init_using_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/similarfinder.py", line 81, in _init_using_ast
    patchedast.patch_ast(node, source)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 33, in patch_ast
    ast.call_for_nodes(node, walker)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 489, in _Module
    self._handle(node, list(node.body), eat_spaces=True)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 240, in _Assign
    self._handle(node, children)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 107, in _handle
    ast.call_for_nodes(child, self)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/base/ast.py", line 54, in call_for_nodes
    result = callback(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 75, in __call__
    return method(node)
  File "/home/jorge/ENTORNOSVIRTUALES/traad/lib/python3.6/site-packages/rope/refactor/patchedast.py", line 266, in _Call
    if node.starargs is not None:
AttributeError: 'Call' object has no attribute 'starargs'
abingham commented 7 years ago

Yeah, we don't handle these cases very well. Whenever rope barfs like this, we should bundle up the error information into the response to the client. And the client should do something helpful with it.

Could you attach a snippet of code that shows this problem, along with the location at which you're calling extract?

abingham commented 7 years ago

@shackra I've just pushed up a new version of traad that and emacs-traad that should help with this issue. The traad changes don't directly address the diagnostics issue you raised; they're really just an improvement in the internal implementation.

However, the better-progress-reporting branch on emacs-traad should better information when things go bad. Could you try these out and let me know if they work for you?

shackra commented 7 years ago

Sure, will try it this Friday and I will come back with much feedback as possible

abingham commented 7 years ago

Did you ever try this again?