Bug #106

"Visualize binary" not working due to a type error

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

In Progress
Bokken Pyew core
Target version:
Start date:
Due date:
% Done:




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/", line 469, in execute
  File "/opt/bokken/ui/", line 513, in execute_plugin
  File "/opt/bokken/plugins/", line 110, in showBinaryImage
    img ="RGB", (size, size), "red")
  File "/usr/lib/python2.7/dist-packages/PIL/", 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/ 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

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

The problem is that size will be of type float, while 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


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

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

#2 Updated by Francisco Falcon over 5 years ago

Hugo Teso Torío wrote:

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

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 over 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 almost 4 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 about 3 years ago

  • Target version changed from 1.7 to 2.0

Also available in: Atom PDF