signed char is greater than maximum

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

signed char is greater than maximum

GRAMPS - Dev mailing list
Dev,


I played a little bit with an addon.
Looking at some built-in python functions or made
some custom cooking, but still not far away from the
primary ideas. So, nothing very dangerous.

Now, someone reported this issue:

"140135: ERROR: tool.py: line 256: Failed to start tool.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gramps/gui/plug/tool.py", line 252,
in gui_tool
    callback = callback)
  File "/home/zed/.gramps/gramps42/plugins/RelID/Relation_tab.py", line
270, in __init__
    line = (iterator, array('b', new_list))
OverflowError: signed char is greater than maximum"

I suppose there is a type or an encoding issue, but the error
sounds rather like a memory limitation or a synchronization/timing
issue.

My current solution is to comment the related line[1]
as it was only a debug test. So, it can be removed too.

I am not able to reproduce it, but as this issue exists,
I suppose that I missed something or did something wrong
during plugin extensions. A loop? An optimization? I have
no idea. Any help or tip might be welcome.

The code[1] is something like:

from array import array

                # sometimes 'iterator' (generator) is more faster
                #handle_list = map(handle, filtered_list)
                iterator = (handle for handle in filtered_list)

               new_list=[int(kekule), int(Ga), int(Gb), int(mra), int(rank)]
               line = (iterator, array('b', new_list))


[1] https://github.com/gramps-project/addons-source/blob/maintenance/gramps42/RelID/Relation_tab.py#L270


regards,
Jérôme

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: signed char is greater than maximum

John Ralls-2


> On Jul 1, 2017, at 2:49 AM, jerome via Gramps-devel <[hidden email]> wrote:
>
> Dev,
>
>
> I played a little bit with an addon.
> Looking at some built-in python functions or made
> some custom cooking, but still not far away from the
> primary ideas. So, nothing very dangerous.
>
> Now, someone reported this issue:
>
> "140135: ERROR: tool.py: line 256: Failed to start tool.
> Traceback (most recent call last):
>  File "/usr/lib/python3/dist-packages/gramps/gui/plug/tool.py", line 252,
> in gui_tool
>    callback = callback)
>  File "/home/zed/.gramps/gramps42/plugins/RelID/Relation_tab.py", line
> 270, in __init__
>    line = (iterator, array('b', new_list))
> OverflowError: signed char is greater than maximum"
>
> I suppose there is a type or an encoding issue, but the error
> sounds rather like a memory limitation or a synchronization/timing
> issue.
>
> My current solution is to comment the related line[1]
> as it was only a debug test. So, it can be removed too.
>
> I am not able to reproduce it, but as this issue exists,
> I suppose that I missed something or did something wrong
> during plugin extensions. A loop? An optimization? I have
> no idea. Any help or tip might be welcome.
>
> The code[1] is something like:
>
> from array import array
>
>                # sometimes 'iterator' (generator) is more faster
>                #handle_list = map(handle, filtered_list)
>                iterator = (handle for handle in filtered_list)
>
>               new_list=[int(kekule), int(Ga), int(Gb), int(mra), int(rank)]
>               line = (iterator, array('b', new_list))
>
>
> [1] https://github.com/gramps-project/addons-source/blob/maintenance/gramps42/RelID/Relation_tab.py#L270

Jérôme,

The error that you’re trying to stuff an int into a byte (“char” is the C type name for an 8-bit int). That works as long as the int is between -127 and 128 but will raise that error if it’s larger.

What do you have in mind for “line”? It seems unlikely that smooshing 4 ints into a single byte array is going to be useful.

Regards,
John Ralls
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: signed char is greater than maximum

GRAMPS - Dev mailing list
In reply to this post by GRAMPS - Dev mailing list

--------------------------------------------
En date de : Sam 1.7.17, John Ralls <[hidden email]> a écrit :

 Objet: Re: [Gramps-devel] signed char is greater than maximum
 À: "jerome" <[hidden email]>
 Cc: "[hidden email]" <[hidden email]>
 Date: Samedi 1 juillet 2017, 17h14
 

> > The
 code[1] is something like:
> >
> > from array import array
> >
> >             
   # sometimes 'iterator' (generator) is more
 faster
> >               
 #handle_list = map(handle, filtered_list)
> >                iterator = (handle
 for handle in filtered_list)
> >
> >             
 new_list=[int(kekule), int(Ga), int(Gb), int(mra),
 int(rank)]
> >               line =
 (iterator, array('b', new_list))
> >
> >
> > [1] https://github.com/gramps-project/addons-source/blob/maintenance/gramps42/RelID/Relation_tab.py#L270
 
> Jérôme,
 

> The error that you’re trying
> to stuff an int into a byte (“char” is the C type name
> for an 8-bit int). That works as long as the int is between
> -127 and 128 but will raise that error if it’s larger.
>
> What do you have in mind for
> “line”? It seems unlikely that smooshing 4 ints into a
> single byte array is going to be useful.
>
> Regards,
> John
> Ralls

John,

Thank you.

Yes, it seems my bad, I did extra (not need) security with the int() and
did not know that there was such limited range of values...
Just a little bit strange that it does not raise an error on my data set.

"line" was just for a pseudo-resume like a print statement.
It seems I would like to print the content with byte array in
addition with handle for pseudo anonymization.
i.e., specific to user data and its DB via handles

I need to exactly remember my first idea for line, but could be
like using zip() for lists. And maybe a simple bridge between pseudo
plain text content and binary. Yes, a lazy matrix: rows, columns ...

Anyway, it was an extension and this section was the last step
for going further (tests).


Thanks.
Jérôme

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Loading...