timknip / pyswf

A Python library to read and write SWF files

Home Page:https://github.com/timknip/pyswf/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: ord() expected a character, but string of length 0 found

tyilo opened this issue · comments

pyswf spends a lot of time parsing the file (around 10-20 mins) and then it finally fails with:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-75ab7c2ec624> in <module>()
----> 1 get_ipython().magic(u'time swf.movie.SWF(f)')

/usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2203         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2204         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2205         return self.run_line_magic(magic_name, magic_arg_s)
   2206
   2207     #-------------------------------------------------------------------------

/usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2124                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2125             with self.builtin_trap:
-> 2126                 result = fn(*args,**kwargs)
   2127             return result
   2128

/usr/local/lib/python2.7/site-packages/IPython/core/magics/execution.pyc in time(self, line, cell, local_ns)

/usr/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194
    195         if callable(arg):

/usr/local/lib/python2.7/site-packages/IPython/core/magics/execution.pyc in time(self, line, cell, local_ns)
   1123         if mode=='eval':
   1124             st = clock2()
-> 1125             out = eval(code, glob, local_ns)
   1126             end = clock2()
   1127         else:

<timed eval> in <module>()

/usr/local/lib/python2.7/site-packages/swf/movie.pyc in __init__(self, file)
     85         self._header = None
     86         if self._data is not None:
---> 87             self.parse(self._data)
     88
     89     @property

/usr/local/lib/python2.7/site-packages/swf/movie.pyc in parse(self, data)
    141             self._header._frame_rate = data.readFIXED8()
    142             self._header._frame_count = data.readUI16()
--> 143         self.parse_tags(data)
    144
    145

/usr/local/lib/python2.7/site-packages/swf/tag.pyc in parse_tags(self, data, version)
    110         tag = None
    111         while type(tag) != TagEnd:
--> 112             tag = self.parse_tag(data)
    113             if tag:
    114                 #print tag.name

/usr/local/lib/python2.7/site-packages/swf/tag.pyc in parse_tag(self, data)
    128             data.seek(raw_tag.pos_content)
    129             data.reset_bits_pending()
--> 130             tag.parse(data, raw_tag.header.content_length, tag.version)
    131             #except:
    132             #    print "=> tag_error", tag.name

/usr/local/lib/python2.7/site-packages/swf/tag.pyc in parse(self, data, length, version)
    735                     temp.read(1) # reserved, always 0
    736                 a = ord(temp.read(1)) if is_lossless2 else 0xff
--> 737                 r = ord(temp.read(1))
    738                 g = ord(temp.read(1))
    739                 b = ord(temp.read(1))

TypeError: ord() expected a character, but string of length 0 found

Here is the SWF I used: https://a.pomf.se/rhdxca.swf

FFDec can open and parse it correctly in around 2 seconds.