ouilles / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

PyScripter Crashes with slice(numpy.int32) object #597

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Dear all, 

PyScripter crashes when accessing a slice object from numpy.int32-objects 
(instead of ordanary int-values)
Python can deal with these kind of slice-objects, but the object-introspection 
of PyScripter creashes when typing the following code:

import numpy
class test:
    def __init__(self):
        pass
a = test()
a.numpy_slice = slice(numpy.int32(2),None,None)

When i type
a.
or when i open the Variables-Window, PyScripter crashes.

with a.numpy_slice = slice(2,None,None) there is no problem.

As a workaround i modified my code and replace all input from numpy-arrays into 
the slice()-function with int()-objects.

What version of the product are you using? On what operating system?

PyScripter 2.4.3.0
The bug appeares in Python 2.6-3.2

Maybe the chrash behaviour i decribed in my comment on Issue 579
http://code.google.com/p/pyscripter/issues/detail?id=579&colspec=ID%20Type%20Sta
tus%20Priority%20Milestone%20Owner%20Summary%20Stars
could be related to this error.

Cheers,

Max

Original issue reported on code.google.com by bohnet....@googlemail.com on 2 Jan 2012 at 4:08

GoogleCodeExporter commented 9 years ago
The built-in rpyc library used for communication with the remote python server, 
makes the incorrect assumption that the slice object would have as start, stop 
and step built-in types.  Hence, the crash.

I will correct this.

Just a question: is there any reason for using 
a.numpy_slice = slice(numpy.int32(2),None,None)
instead of 
a.numpy_slice = slice(2,None,None)

Original comment by pyscripter on 2 Jan 2012 at 7:37

GoogleCodeExporter commented 9 years ago
Thanks for the quick reply!

The reason for using a numpy.int32-objects is, that in my code in a loop over a 
numpy.array of dtype='<i4' the members of that array are taken as arguments of 
the slice-function.

for example:
indices = numpy.array([0,3,5,10,20,25])
for i in indices[:-1]
    mySlice = slice(indices[i], indices[i+1], None)
    resultArray = anotherArray[mySlice]
    newObject = MyClass(resultArray, mySlice)

the newObject needs to know the slice the resultArray was created from
MyClass:
    def __init__(self, array, mySlice):
        self.array = array
        self.mySlice = mySlice
typing "newObject." crashes PyScripter.

indices = numpy.array([0,3,5,10,20,25])
for i in indices[:-1]
    i = int(i)
    mySlice = slice(indices[i], indices[i+1], None)
    resultArray = anotherArray[mySlice]
    newObject = MyClass(resultArray, mySlice)

is my workaround so far.

Original comment by bohnet....@googlemail.com on 3 Jan 2012 at 6:07

GoogleCodeExporter commented 9 years ago
Fixed in version control.

Original comment by pyscripter on 28 Feb 2012 at 7:17