Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
IndexError: list index out of range
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Leo  
View profile  
 More options Oct 29 2012, 10:53 pm
From: Leo <sdl....@gmail.com>
Date: Tue, 30 Oct 2012 10:53:14 +0800
Local: Mon, Oct 29 2012 10:53 pm
Subject: IndexError: list index out of range
To reproduce this:

1. Make a new project and create a file with the following lines:

from twisted.internet import reactor
reactor.run(|

where `|' indicates current point in emacs

2. M-: (rope-get-calltip) RET

Backtrace:

Debugger entered--Lisp error: (error "Python: Traceback (most recent call last):
  File \"/emacs/share/emacs/site-lisp/etc/python/Pymacs.py\", line 268, in loop
    value = eval(text)
  File \"<string>\", line 1, in <module>
  File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/decorators.py\", line 53, in newfunc
    return func(*args, **kwds)
  File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 194, in get_calltip
    return self._base_get_doc(_get_doc)
  File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 217, in _base_get_doc
    self.resource, maxfixes)
  File \"/emacs/share/emacs/site-lisp/etc/python/ropemode/interface.py\", line 193, in _get_doc
    return codeassist.get_calltip(project, text, offset, *args, **kwds)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/codeassist.py\", line 94, in get_calltip
    pyname = fixer.pyname_at(offset)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/fixsyntax.py\", line 66, in pyname_at
    return new_pyname()
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/contrib/fixsyntax.py\", line 61, in new_pyname
    return rope.base.evaluate.eval_location(pymodule, newoffset)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 11, in eval_location
    return eval_location2(pymodule, offset)[1]
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 17, in eval_location2
    return pyname_finder.get_primary_and_pyname_at(offset)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/evaluate.py\", line 78, in get_primary_and_pyname_at
    holding_scope = self.module_scope.get_inner_scope_for_line(lineno)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 132, in get_inner_scope_for_line
    return self._scope_finder.get_holding_scope(self, lineno, indents)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 229, in get_holding_scope
    line_indents = self.get_indents(lineno)
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/pyscopes.py\", line 222, in get_indents
    self.lines.get_line(lineno))
  File \"/emacs/share/emacs/site-lisp/etc/python/rope/base/codeanalyze.py\", line 62, in get_line
    self.starts[lineno] - 1]
IndexError: list index out of range
")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Oct 30 2012, 3:35 pm
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Tue, 30 Oct 2012 23:02:59 +0330
Local: Tues, Oct 30 2012 3:32 pm
Subject: Re: IndexError: list index out of range

I remember a similar problem being fixed a long time ago.
Are you using the latest versions of rope, ropemode and
ropemacs?

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Oct 30 2012, 10:02 pm
From: Leo <sdl....@gmail.com>
Date: Wed, 31 Oct 2012 10:02:26 +0800
Local: Tues, Oct 30 2012 10:02 pm
Subject: Re: IndexError: list index out of range
On 2012-10-31 03:32 +0800, Ali Gholami Rudi wrote:
[snipped 22 lines]

> I remember a similar problem being fixed a long time ago.
> Are you using the latest versions of rope, ropemode and
> ropemacs?

>    Ali

I just updated the three components: rope/ropemode/ropemacs from
https://bitbucket.org/agr a minute ago and this bug is NOT fixed there.

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 1 2012, 10:38 am
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Thu, 01 Nov 2012 17:54:22 +0330
Local: Thurs, Nov 1 2012 10:24 am
Subject: Re: IndexError: list index out of range

Leo <sdl....@gmail.com> wrote:
> To reproduce this:

> 1. Make a new project and create a file with the following lines:

> from twisted.internet import reactor
> reactor.run(|

> where `|' indicates current point in emacs

> 2. M-: (rope-get-calltip) RET

The problem is the file does not end with a newline.  Although that's
an error in general, it may happen for code-assists, in which the
files may not compile.  Does this patch fix it?

Thanks,
Ali

--- a/rope/contrib/fixsyntax.py 2012-11-01 18:03:03.511663973 +0330
+++ b/rope/contrib/fixsyntax.py 2012-11-01 18:04:56.611829855 +0330
@@ -9,6 +9,8 @@
     def __init__(self, pycore, code, resource, maxfixes=1):
         self.pycore = pycore
         self.code = code
+        if code[-1] != '\n':
+            self.code = code + '\n'
         self.resource = resource
         self.maxfixes = maxfixes


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 1 2012, 7:35 pm
From: Leo <sdl....@gmail.com>
Date: Fri, 02 Nov 2012 07:34:45 +0800
Local: Thurs, Nov 1 2012 7:34 pm
Subject: Re: IndexError: list index out of range
On 2012-11-01 22:24 +0800, Ali Gholami Rudi wrote:

> The problem is the file does not end with a newline.  Although that's
> an error in general, it may happen for code-assists, in which the
> files may not compile.  Does this patch fix it?

I am getting the same error with the patch even if the file ends with a
newline. The problem seems to be not having a closing ')'.

Thanks.
Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 2 2012, 1:25 am
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Fri, 02 Nov 2012 08:44:04 +0330
Local: Fri, Nov 2 2012 1:14 am
Subject: Re: IndexError: list index out of range

Leo <sdl....@gmail.com> wrote:
> On 2012-11-01 22:24 +0800, Ali Gholami Rudi wrote:
> > The problem is the file does not end with a newline.  Although that's
> > an error in general, it may happen for code-assists, in which the
> > files may not compile.  Does this patch fix it?

> I am getting the same error with the patch even if the file ends with a
> newline. The problem seems to be not having a closing ')'.

fixsyntax.py tries to fix syntax errors before parsing the
input string for code-assists.

I think some of python's error messages point to invalid
line numbers.  How about this patch?

        Ali

--- a/rope/contrib/fixsyntax.py 2012-11-02 08:44:23.932012064 +0330
+++ b/rope/contrib/fixsyntax.py 2012-11-02 08:49:15.592441539 +0330
@@ -29,7 +29,10 @@
             except exceptions.ModuleSyntaxError, e:
                 if tries < self.maxfixes:
                     tries += 1
-                    self.commenter.comment(e.lineno)
+                    lineno = e.lineno
+                    if lineno >= len(self.commenter.lines):
+                        lineno = len(self.commenter.lines) - 1
+                    self.commenter.comment(lineno)
                     code = '\n'.join(self.commenter.lines)
                     errors.append('  * line %s: %s ... fixed' % (e.lineno,
                                                                  e.message_))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 2 2012, 1:43 am
From: Leo <sdl....@gmail.com>
Date: Fri, 02 Nov 2012 13:43:18 +0800
Local: Fri, Nov 2 2012 1:43 am
Subject: Re: IndexError: list index out of range
On 2012-11-02 13:14 +0800, Ali Gholami Rudi wrote:

> I think some of python's error messages point to invalid
> line numbers.  How about this patch?

No luck here. I am getting the same error.

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 2 2012, 2:05 am
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Fri, 02 Nov 2012 09:29:52 +0330
Local: Fri, Nov 2 2012 1:59 am
Subject: Re: IndexError: list index out of range

Leo <sdl....@gmail.com> wrote:
> On 2012-11-02 13:14 +0800, Ali Gholami Rudi wrote:
> > I think some of python's error messages point to invalid
> > line numbers.  How about this patch?

> No luck here. I am getting the same error.

That's odd.  The following script uses rope directly.  Does
it work in your configuration?

  from rope.base import project
  from rope.contrib import codeassist

  s = "from twisted.internet import reactor\nreactor.run("
  p = project.Project('.')
  print codeassist.code_assist(p, s, len(s))

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 2 2012, 5:01 am
From: Leo <sdl....@gmail.com>
Date: Fri, 02 Nov 2012 17:01:23 +0800
Local: Fri, Nov 2 2012 5:01 am
Subject: Re: IndexError: list index out of range
On 2012-11-02 13:59 +0800, Ali Gholami Rudi wrote:

>   from rope.base import project
>   from rope.contrib import codeassist

>   s = "from twisted.internet import reactor\nreactor.run("
>   p = project.Project('.')
>   print codeassist.code_assist(p, s, len(s))

Yes, it prints something like this: http://bpaste.net/show/55359/
without applying the patch.

The error I am getting is from running M-: (rope-get-calltip).

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 2 2012, 6:32 am
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Fri, 02 Nov 2012 13:55:22 +0330
Local: Fri, Nov 2 2012 6:25 am
Subject: Re: IndexError: list index out of range

Leo <sdl....@gmail.com> wrote:
> On 2012-11-02 13:59 +0800, Ali Gholami Rudi wrote:
> >   from rope.base import project
> >   from rope.contrib import codeassist

> >   s = "from twisted.internet import reactor\nreactor.run("
> >   p = project.Project('.')
> >   print codeassist.code_assist(p, s, len(s))

> Yes, it prints something like this: http://bpaste.net/show/55359/
> without applying the patch.

> The error I am getting is from running M-: (rope-get-calltip).

OK, fixsyntax.py cannot add the missing ')'.  This should at
least prevent the exception.

Thanks,
Ali

--- a/rope/contrib/fixsyntax.py 2012-11-02 13:54:40.000000000 +0330
+++ b/rope/contrib/fixsyntax.py 2012-11-02 13:53:40.102998269 +0330
@@ -96,8 +96,13 @@
         self._fix_incomplete_try_blocks(lineno, indents)

     def transfered_offset(self, offset):
+        """Return the new offset in the commented source"""
         lineno = self.code.count('\n', 0, offset)
         diff = sum(self.diffs[:lineno])
+        # the line containing offset was changed;
+        # assuming the change was in line indents
+        line_offset = offset - self.code.rfind('\n', 0, offset) - 1
+        diff += max(-line_offset, self.diffs[lineno])
         return offset + diff

     def _last_non_blank(self, start):


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 2 2012, 6:58 am
From: Leo <sdl....@gmail.com>
Date: Fri, 02 Nov 2012 18:57:56 +0800
Local: Fri, Nov 2 2012 6:57 am
Subject: Re: IndexError: list index out of range
On 2012-11-02 18:25 +0800, Ali Gholami Rudi wrote:

> OK, fixsyntax.py cannot add the missing ')'.  This should at
> least prevent the exception.

Yes, it does.

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 10 2012, 3:59 am
From: Leo <sdl....@gmail.com>
Date: Sat, 10 Nov 2012 16:58:55 +0800
Local: Sat, Nov 10 2012 3:58 am
Subject: Re: IndexError: list index out of range
On 2012-11-02 18:25 +0800, Ali Gholami Rudi wrote:

> OK, fixsyntax.py cannot add the missing ')'.  This should at
> least prevent the exception.

What would be the right thing to do?

BTW,

from twisted.internet import reactor
reactor.|

why no interesting completions (such as run, listenTCP etc.) at this
point?

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 10 2012, 2:37 pm
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Sat, 10 Nov 2012 22:59:15 +0330
Local: Sat, Nov 10 2012 2:29 pm
Subject: Re: IndexError: list index out of range

Leo <sdl....@gmail.com> wrote:
> What would be the right thing to do?

> BTW,

> from twisted.internet import reactor
> reactor.|

> why no interesting completions (such as run, listenTCP etc.) at this
> point?

How about completing "reactor.r" (or any other letter after dot)?

By the way, fixsyntax.py uses heuristics to fix syntax errors: it
comments lines and blocks that contain errors.  It is probably not
hard to improve it to handle more complex errors.  Patches are
welcome.

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 11 2012, 10:58 am
From: Leo <sdl....@gmail.com>
Date: Sun, 11 Nov 2012 23:58:16 +0800
Local: Sun, Nov 11 2012 10:58 am
Subject: Re: IndexError: list index out of range
On 2012-11-11 03:29 +0800, Ali Gholami Rudi wrote:

> How about completing "reactor.r" (or any other letter after dot)?

No completion for reactor.r.

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jasper St. Pierre  
View profile  
 More options Nov 11 2012, 11:28 am
From: "Jasper St. Pierre" <jstpie...@mecheye.net>
Date: Sun, 11 Nov 2012 11:28:02 -0500
Local: Sun, Nov 11 2012 11:28 am
Subject: Re: IndexError: list index out of range

The reactor is actually really fancy magic, so I doubt rope could follow it
using static analysis anyway.

http://twistedmatrix.com/trac/browser/trunk/twisted/internet/reactor.py

On Sun, Nov 11, 2012 at 10:58 AM, Leo <sdl....@gmail.com> wrote:
> On 2012-11-11 03:29 +0800, Ali Gholami Rudi wrote:
> > How about completing "reactor.r" (or any other letter after dot)?

> No completion for reactor.r.

> Leo

--
  Jasper

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ali Gholami Rudi  
View profile  
 More options Nov 11 2012, 12:08 pm
From: Ali Gholami Rudi <aligr...@gmail.com>
Date: Sun, 11 Nov 2012 20:29:22 +0330
Local: Sun, Nov 11 2012 11:59 am
Subject: Re: IndexError: list index out of range
"Jasper St. Pierre" <jstpie...@mecheye.net> wrote:

> The reactor is actually really fancy magic, so I doubt rope could follow it
> using static analysis anyway.

> http://twistedmatrix.com/trac/browser/trunk/twisted/internet/reactor.py

You're right.  But adding twisted.internet.reactor to
extension_modules would have fixed it, if rope supported non-top-level
extension modules; I'm not sure, but as far as I remember it does not.
I think it was Darren Hoo who posted patches for fixing it (I guess it
is in the thread with the title "code completion with c-extension
modules not work") but unfortunately it was not merged, IIRC.  It
would be wonderful if someone volunteers to update and test the
patches to get them merged.

        Ali


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »