EmbodiedCognition / py-c3d

Read & write C3D mocap files
http://c3d.rtfd.org
MIT License
104 stars 47 forks source link

AttributeError: 'str' object has no attribute 'decode' #5

Closed peterjkirby closed 7 years ago

peterjkirby commented 7 years ago

The read method in the Param class contains the following:

class Param(object):
    ...
    def read(self, handle):
        ...
        self.bytes = ''
        if self.total_bytes:
            self.bytes = handle.read(self.total_bytes)
        ...

If self.total_bytes is 0, then self.bytes is of type str not bytes.

A subsequent call to Param.string_value will raise an AttributeError:

File "lib/python3.6/site-packages/c3d.py", line 500, in get_string return self.params[key.upper()].string_value File "lib/python3.6/site-packages/c3d.py", line 323, in string_value return self.bytes.decode('utf-8') AttributeError: 'str' object has no attribute 'decode'

lmjohns3 commented 7 years ago

Cool, thanks for the report, and great catch!