You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/02/25 11:50:16 UTC
[GitHub] [cordova-ios] knight9999 commented on issue #769: Add Python 3
compatibility to bin/cordova_plist_to_config_xml
knight9999 commented on issue #769: Add Python 3 compatibility to bin/cordova_plist_to_config_xml
URL: https://github.com/apache/cordova-ios/pull/769#issuecomment-590828824
I tried this PR with Python 3.6.4. But I got the following error.
```
TypeError: string argument expected, got 'bytes'
```
I feel it is better to use `BytesIO` with `ElementTree.write` in place of `StringIO` as follows.
```
diff --git a/bin/cordova_plist_to_config_xml b/bin/cordova_plist_to_config_xml
index f6c47505..94fe3371 100755
--- a/bin/cordova_plist_to_config_xml
+++ b/bin/cordova_plist_to_config_xml
@@ -38,6 +38,7 @@ try: # Python 2
except ImportError: # Python 3
from io import StringIO
+from io import BytesIO
def Usage():
sys.stderr.write(__doc__)
@@ -93,10 +94,11 @@ def ConvertPlist(src_path, dst_path):
root.append(ElementTree.Element('access', attrib={'origin':value}))
tree = ElementTree.ElementTree(root)
- s = StringIO()
+ # s = StringIO()
+ s = BytesIO()
tree.write(s, encoding='UTF-8')
mini_dom = minidom.parseString(s.getvalue())
- with open(dst_path, 'w') as out:
+ with open(dst_path, 'wb') as out:
out.write(mini_dom.toprettyxml(encoding='UTF-8'))
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org