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...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sci-geo Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
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: ---


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

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

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