Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 669218

Summary: sci-geosciences/josm with dev-lang/python-3.7 - argument must be str, not bytes in ElementTree
Product: Gentoo Linux Reporter: Helmut Jarausch <jarausch>
Component: Current packagesAssignee: Sci-geo Project <sci-geosciences>
Status: UNCONFIRMED ---    
Severity: normal CC: sci-geosciences
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Attachments: file build.xml

Description Helmut Jarausch 2018-10-21 16:48:25 UTC
Created attachment 552148 [details]
file build.xml

I hope someone can help locating the following bug - at least, the error message
isn't very helpful

The following script is an excerpt of build-xml-rewrite ;
the file build.xml is attached

import xml.etree.cElementTree as et
tree= et.ElementTree(file='build.xml')
gcp_sub= et.Element('classpath', path=gcp_str)
changes= [(['javadoc', 'javac', 'xjavac', 'javac.preset'], 'source', '1.8'), 
(['javac', 'xjavac', 'javac.preset'], 'target','1.8')]
for c in changes:
    elems, attr, value = c
    for elem in elems:
        for e in tree.getiterator(elem):
            e.attrib[attr] = value

with open('build_new.xml', 'w') as f:

This gives

# Traceback (most recent call last):
#   File "", line 16, in <module>
#     tree.write(f)
#   File "/usr/lib/python3.7/xml/etree/", line 777, in write
#     short_empty_elements=short_empty_elements)
#   File "/usr/lib/python3.7/", line 119, in __exit__
#     next(self.gen)
#   File "/usr/lib/python3.7/xml/etree/", line 836, in _get_writer
#     yield file.write
#   File "/usr/lib/python3.7/", line 511, in __exit__
#     raise exc_details[1]
#   File "/usr/lib/python3.7/", line 496, in __exit__
#     if cb(*exc_details):
#   File "/usr/lib/python3.7/", line 383, in _exit_wrapper
#     callback(*args, **kwds)
# TypeError: write() argument must be str, not bytes

Many thanks for your help.
P.S.  this break emerge sci-geosciences/josm