diff options
author | Hossein <hossein@libreoffice.org> | 2021-09-04 00:35:38 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-09-06 08:58:34 +0200 |
commit | 684a25f0b19723337b9aedd765565b72ede89e91 (patch) | |
tree | d52869b4155164b30693233b4e53625b040caa7d /msodumper | |
parent | 0ffc7eac2596ff590eb7c7612940c7d785fea167 (diff) |
Fix code to work with Python 3.8 and 3.9
* env python2 → python3
* Fixed problems with concatenation of str and bytes
* Removed \x00 from font names, so that the 'make check' tests pass
* Improved Makefile to work without {} that lead to 'file not found'
in some situations
* 'make check' passes for Python 3.8 and 3.9
This is the error before the fix:
$ python3.8 ./doc-dump.py test/doc/fonts.doc
Traceback (most recent call last):
File "./doc-dump.py", line 43, in <module>
main(sys.argv)
File "./doc-dump.py", line 39, in main
dumper.dump()
File "./doc-dump.py", line 23, in dump
strm = docstream.createDOCFile(file.read(), self.params)
File "mso-dumper/msodumper/docstream.py", line 131, in createDOCFile
return GsfDOCFile(chars, params, gsf)
File "mso-dumper/msodumper/docstream.py", line 75, in __init__
DOCFile.__init__(self, chars, params)
File "mso-dumper/msodumper/docstream.py", line 29, in __init__
self.initWW8()
File "mso-dumper/msodumper/docstream.py", line 107, in initWW8
childData += ctypes.string_at(self.gsf.gsf_input_read(child, bufSize, None), bufSize)
TypeError: can only concatenate str (not "bytes") to str
Change-Id: I804e2973b283a435a03ab55b258b7db5b9372693
Reviewed-on: https://gerrit.libreoffice.org/c/mso-dumper/+/121617
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'msodumper')
-rw-r--r-- | msodumper/binarystream.py | 2 | ||||
-rw-r--r-- | msodumper/docrecord.py | 6 | ||||
-rw-r--r-- | msodumper/docsprm.py | 2 | ||||
-rw-r--r-- | msodumper/docstream.py | 4 | ||||
-rw-r--r-- | msodumper/emfrecord.py | 2 | ||||
-rw-r--r-- | msodumper/msometa.py | 2 | ||||
-rwxr-xr-x | msodumper/oletool.py | 2 | ||||
-rw-r--r-- | msodumper/vsdstream.py | 2 | ||||
-rw-r--r-- | msodumper/wmfrecord.py | 2 | ||||
-rwxr-xr-x | msodumper/xmlpp.py | 2 |
10 files changed, 13 insertions, 13 deletions
diff --git a/msodumper/binarystream.py b/msodumper/binarystream.py index 4946a45..1bca906 100644 --- a/msodumper/binarystream.py +++ b/msodumper/binarystream.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/docrecord.py b/msodumper/docrecord.py index 37ad734..d7df861 100644 --- a/msodumper/docrecord.py +++ b/msodumper/docrecord.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -792,7 +792,7 @@ class DefTableShd80Operand(BinaryStream): def dump(self): print('<defTableShd80Operand type="DefTableShd80Operand" offset="%d">' % self.pos) self.printAndSet("cb", self.readuInt8()) - for i in range(self.cb / Shd80.size): + for i in range(round(self.cb / Shd80.size)): Shd80(self, i).dump() print('</defTableShd80Operand>') @@ -2992,7 +2992,7 @@ class FFN(BinaryStream): self.pos += 10 FontSignature(self.bytes, self.pos).dump() self.pos += 24 - print('<xszFfn value="%s"/>' % self.readString()) + print('<xszFfn value="%s"/>' % self.readString().replace('\\x00', '')) print('</ffn>') diff --git a/msodumper/docsprm.py b/msodumper/docsprm.py index 892ce3d..bd3cefe 100644 --- a/msodumper/docsprm.py +++ b/msodumper/docsprm.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/docstream.py b/msodumper/docstream.py index c44271b..2b99016 100644 --- a/msodumper/docstream.py +++ b/msodumper/docstream.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -96,7 +96,7 @@ class GsfDOCFile(DOCFile): child = self.gsf.gsf_infile_child_by_index(gsfInfile, i) childName = ctypes.string_at(self.gsf.gsf_infile_name_by_index(gsfInfile, i)) childSize = self.gsf.gsf_input_size(child) - childData = "" + childData = bytes() while True: bufSize = 1024 pos = self.gsf.gsf_input_tell(child) diff --git a/msodumper/emfrecord.py b/msodumper/emfrecord.py index 61b7eb6..7d7be0a 100644 --- a/msodumper/emfrecord.py +++ b/msodumper/emfrecord.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/msometa.py b/msodumper/msometa.py index 6d79ea9..385dfef 100644 --- a/msodumper/msometa.py +++ b/msodumper/msometa.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/oletool.py b/msodumper/oletool.py index e4e03ce..12ae8ee 100755 --- a/msodumper/oletool.py +++ b/msodumper/oletool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/vsdstream.py b/msodumper/vsdstream.py index b4653ec..03950fc 100644 --- a/msodumper/vsdstream.py +++ b/msodumper/vsdstream.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/wmfrecord.py b/msodumper/wmfrecord.py index 85a8bac..1d7b1fa 100644 --- a/msodumper/wmfrecord.py +++ b/msodumper/wmfrecord.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/msodumper/xmlpp.py b/msodumper/xmlpp.py index 6a3758c..a09fdd8 100755 --- a/msodumper/xmlpp.py +++ b/msodumper/xmlpp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 """Pretty print an XML document. LICENCE: |