Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 669218 - sci-geosciences/josm with dev-lang/python-3.7 - argument must be str, not bytes in ElementTree
Summary: sci-geosciences/josm with dev-lang/python-3.7 - argument must be str, not byt...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sci-geo Project
Depends on:
Reported: 2018-10-21 16:48 UTC by Helmut Jarausch
Modified: 2018-11-08 11:58 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

file build.xml (build.xml,621 bytes, text/xml)
2018-10-21 16:48 UTC, Helmut Jarausch

Note You need to log in before you can comment on or make changes to this bug.
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