Skip to content
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

pitivi fails to build with itstool/py3 #19

Open
DimStar77 opened this issue Nov 3, 2017 · 2 comments
Open

pitivi fails to build with itstool/py3 #19

DimStar77 opened this issue Nov 3, 2017 · 2 comments
Milestone

Comments

@DimStar77
Copy link

I switched our itstool package over to be py3 based - and most things work (after a few hiccups)

One package constantly failing is pitivi, which fails with an error like this:

[   79s] [4/220] /usr/bin/itstool -m help/cs/cs.mo ../help/cs/../C/about.page --output help/cs/about.page
[   79s] FAILED: help/cs/about.page 
[   79s] /usr/bin/itstool -m help/cs/cs.mo ../help/cs/../C/about.page --output help/cs/about.page
[   79s] Traceback (most recent call last):
[   79s]   File "/usr/bin/itstool", line 1605, in <module>
[   79s]     fout.write(serialized)
[   79s] TypeError: write() argument must be str, not bytes
[   79s] [5/220] /usr/bin/itstool -m help/de/de.mo ../help/de/../C/about.page --output help/de/about.page
[   79s] FAILED: help/de/about.page 
[   79s] /usr/bin/itstool -m help/de/de.mo ../help/de/../C/about.page --output help/de/about.page
[   79s] Traceback (most recent call last):
[   79s]   File "/usr/bin/itstool", line 1605, in <module>
[   79s]     fout.write(serialized)
[   79s] TypeError: write() argument must be str, not bytes

Interestingly enough, just a couple lines before the error reported, itstool does this:

            if PY3:
                # For some reason, under py3, our serialized data is returns as a str.
                # Let's encode it to bytes
                serialized = serialized.encode('utf-8')

Skipping the encode works for cs merge, but fails on other languages

@shaunix
Copy link
Contributor

shaunix commented Nov 3, 2017

I can't reproduce itstool erroring out. But I can confirm that type(serialized) is str before the encode, and bytes after the encode. Maybe some more recent version of python3 got strict about what gets handed to write? Strange.

@aleb
Copy link

aleb commented Nov 3, 2017

I can reproduce with:

$ rm -f help/cs/cs.mo help/cs/about.page; /usr/bin/msgfmt help/cs/cs.po --output-file help/cs/cs.mo && python3 /usr/bin/itstool -m help/cs/cs.mo help/cs/../C/about.page --output help/cs/about.page && /usr/bin/itstool --version
1111 <class 'str'>
1112 <class 'bytes'>
Traceback (most recent call last):
  File "/usr/bin/itstool", line 1607, in <module>
    fout.write(serialized)
TypeError: write() argument must be str, not bytes

The following section prints 1111 and 1112:

            serialized = doc._doc.serialize('utf-8')
            if PY3:
                print(1111, type(serialized))
                # For some reason, under py3, our serialized data is returns as a str.
                # Let's encode it to bytes
                serialized = serialized.encode('utf-8')
                print(1112, type(serialized))

Maybe fout sometimes wants bytes and sometimes str.

cs.po

msgid "Creative Commons Share Alike 3.0x"
msgstr "Creative Commons Share Alike 3.0"

about.page:

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:e="http://projectmallard.org/experimental/" type="topic" id="about">
</page>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants