Project

General

Profile

Bug #106

"Visualize binary" not working due to a type error

Added by Francisco Falcon about 5 years ago. Updated almost 3 years ago.

Status:
In Progress
Priority:
Normal
Category:
Bokken Pyew core
Target version:
Start date:
26/12/2011
Due date:
% Done:

0%

Severity:
Normal

Description

Description of the bug

When using pyew as the backend, the "Visualize binary" feature does not work due to a type error. No visualization of the binary is shown, and the following Python traceback appears in the console:

Traceback (most recent call last):
  File "/opt/bokken/ui/pyew_toolbar.py", line 469, in execute
    self.uicore.execute_plugin(plugin)
  File "/opt/bokken/ui/core.py", line 513, in execute_plugin
    self.core.plugins[plg[0]](self.core)
  File "/opt/bokken/plugins/graphs.py", line 110, in showBinaryImage
    img = Image.new("RGB", (size, size), "red")
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1763, in new
    return Image()._new(core.fill(mode, size, color))
TypeError: integer argument expected, got float

Steps to reproduce the bug

  1. Launch Bokken.
  2. Select pyew as the backend. Choose any binary to analyze, then click Ok to load it.
  3. Click the "Visualize binary" icon in the toolbar.

Additional comments

The bug is located in the showBinaryImage function, which belongs to the file plugins/graphs.py of pyew 2.0. (Maybe I should open this ticket in the pyew issue tracker instead of Bokken's one?)

At line 109/110, the size of the image to be created is calculated and then passed as an argument to Image.new:

    size = len(buf)**(1./3)+1
    img = Image.new("RGB", (size, size), "red")

The problem is that size will be of type float, while Image.new expects an int parameter.

The bug was reproduced on Ubuntu 11.10 (x86), with Python 2.7, Pyew 2.0, using the up-to-date version of Bokken from the repository (revision 300:952267e5b159)

Proposed fix

Cast size to int in the showBinaryImage function:

    size = int(len(buf)**(1./3)+1)

After that casting, the following casts in the same function will become unnecessary:

    for y in range(int(size)):
        for x in range(int(size)):

Related issues

Blocked by Bug #210: Update pyew to 2.2. Closed 27/08/2013

History

#1 Updated by Hugo Teso Torío about 5 years ago

May be this bug was already fixed in the new Pyew version that Joxean is cooking?:

http://code.google.com/p/pyew/source/detail?r=8f67d85091649d44b7be28b336cc5e301641b2b7

#2 Updated by Francisco Falcon about 5 years ago

Hugo Teso Torío wrote:

May be this bug was already fixed in the new Pyew version that Joxean is cooking?:

http://code.google.com/p/pyew/source/detail?r=8f67d85091649d44b7be28b336cc5e301641b2b7

Ooops, my bad...I should have also checked the development version in the pyew repository instead of just checking the latest available download of pyew (version 2.0).

#3 Updated by David Martínez Moreno about 5 years ago

  • Target version set to 2.0

Francisco, I'm going to close this bug, as it has nothing to do with Bokken, really. I'm tempted to fix it in the Debian packages for pyew, though. Do you use them?

#4 Updated by David Martínez Moreno over 3 years ago

  • Status changed from New to In Progress
  • Assignee changed from Hugo Teso Torío to David Martínez Moreno
  • Target version changed from 2.0 to 1.7

I'm updating pyew to 2.2 and thus this bug will go away (see #210).

#5 Updated by David Martínez Moreno almost 3 years ago

  • Target version changed from 1.7 to 2.0

Also available in: Atom PDF