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   
Whiteboard:
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

Hi,
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

#!/usr/bin/python
import xml.etree.cElementTree as et
tree= et.ElementTree(file='build.xml')
gcp_str='${gentoo.classpath}'
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:
   tree.write(f)


This gives

# Traceback (most recent call last):
#   File "Test.py", line 16, in <module>
#     tree.write(f)
#   File "/usr/lib/python3.7/xml/etree/ElementTree.py", line 777, in write
#     short_empty_elements=short_empty_elements)
#   File "/usr/lib/python3.7/contextlib.py", line 119, in __exit__
#     next(self.gen)
#   File "/usr/lib/python3.7/xml/etree/ElementTree.py", line 836, in _get_writer
#     yield file.write
#   File "/usr/lib/python3.7/contextlib.py", line 511, in __exit__
#     raise exc_details[1]
#   File "/usr/lib/python3.7/contextlib.py", line 496, in __exit__
#     if cb(*exc_details):
#   File "/usr/lib/python3.7/contextlib.py", 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