python 3 issues with ct.c_char

Bug #1735829 reported by Juan D'Adamo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libIM7
Fix Committed
High
Fabricio

Bug Description

Hello, I can't run the library under python3... and new ubuntu ipython works in python3...

    buf1, att1 = im7.readim7(fname)
  File "/home/juan/Documents/script_python/libim7-master/libim7_64.py", line 473, in readim7
    mylib.ReadIM7(ct.c_char_p(filename), ct.byref(mybuffer), ct.byref(att_pp))
TypeError: bytes or integer address expected instead of numpy.str_ instance

I tried by changing the line as suggested in https://stackoverflow.com/questions/23852311/different-behaviour-of-ctypes-c-char-p
 mylib.ReadIM7(ct.c_char_p(filename.encode('utf-8')), ct.byref(mybuffer), ct.byref(att_pp))

But result in an error too:

    buf1, att1 = im7.readim7(fname)
  File "/home/juan/Documents/script_python/libim7-master/libim7_64.py", line 497, in readim7
    mybuffer.get_blocks()
  File "/home/juan/Documents/script_python/libim7-master/libim7_64.py", line 268, in get_blocks
    h = self.header
  File "/home/juan/Documents/script_python/libim7-master/libim7_64.py", line 245, in __getattr__
    self.read_header()
  File "/home/juan/Documents/script_python/libim7-master/libim7_64.py", line 204, in read_header
    f = file(self.file, 'rb')
NameError: name 'file' is not defined

Merci Fabrice pour le support!!

Abrazo!

Revision history for this message
Fabricio (silva) wrote :

Fixed in https://github.com/FabricioS/libim7/commit/5ed56e8db92.
libim7 now supports python3.
I would appreciate feedbacks on python2.

Changed in libim7:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Fabricio (silva)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.