-
Notifications
You must be signed in to change notification settings - Fork 475
TypeError: Struct() argument 1 must be string, not unicode #993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Humm. I suspect e853036#diff-31a4f6d5cfe6b730aa7a52f036df840dR3, but why does it not fail in our continuous testing? |
maybe my font (SourceHanSansCN-Normal.otf) have some magic triggered this exception. |
Before python 2.7.7 the struct module didn't support unicode strings, but required a nativ str (bytes). We don't run tests on such old pythons on our CI. |
sgtm |
Hi, |
It turns out some fonttools users are still stuck with pythons older than 2.7.7. I wouldn't like to add another Travis build to check for such old python, it's slow enough already. |
for this specific issue with the py27 struct module, fonttools devs should remember to explicitly use bytes for the |
properly fixes issue with struct module in python < 2.7.7 #993
We install python 2.7.6 using pyenv. This should help us catch issues like this earlier #993
I have ttx via pip install fonttools, and use it to convert SourceHanSans.
but it give me an exception like this:
Dumping "SourceHanSansCN-Normal.otf" to "SourceHanSansCN-Normal.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
ERROR: Unhandled exception has occurred
Traceback (most recent call last):
File "f:\python27\lib\site-packages\fontTools\ttx.py", line 387, in main
process(jobs, options)
File "f:\python27\lib\site-packages\fontTools\ttx.py", line 361, in process
action(input, output, options)
File "f:\python27\lib\site-packages\fontTools\misc\loggingTools.py", line 372, in wrapper
return func(*args, **kwds)
File "f:\python27\lib\site-packages\fontTools\ttx.py", line 258, in ttDump
newlinestr=options.newlinestr)
File "f:\python27\lib\site-packages\fontTools\ttLib_init_.py", line 311, in saveXML
self.tableToXML(tableWriter, tag, progress)
File "f:\python27\lib\site-packages\fontTools\ttLib_init.py", line 329, in tableToXML
table = self[tag]
File "f:\python27\lib\site-packages\fontTools\ttLib_init.py", line 419, in getitem
tableClass = getTableClass(tag)
File "f:\python27\lib\site-packages\fontTools\ttLib_init_.py", line 825, in getTableClass
module = getTableModule(tag)
File "f:\python27\lib\site-packages\fontTools\ttLib_init_.py", line 807, in getTableModule
import("fontTools.ttLib.tables." + pyTag)
File "f:\python27\lib\site-packages\fontTools\ttLib\tables_n_a_m_e.py", line 26, in
nameRecordSize = sstruct.calcsize(nameRecordFormat)
File "f:\python27\lib\site-packages\fontTools\misc\sstruct.py", line 108, in calcsize
return struct.calcsize(formatstring)
TypeError: Struct() argument 1 must be string, not unicode
(Hit any key to exit)
python version is 2.7.3, os is windows 7 x64 sp1.
The text was updated successfully, but these errors were encountered: