summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ponomarev <igor.ponomarev@collabora.com>2022-06-02 21:18:44 +0300
committerThomas Haller <thaller@redhat.com>2022-06-03 08:26:12 +0200
commitdaecc226ee5d0b7e16b9a2c7fccf63aeecb8f000 (patch)
tree12bc290bee3543bd5591e8ad36332ee14f804d41
parent68e9f92a816ffa887528c41a11c69c1c8145519b (diff)
downloadNetworkManager-daecc226ee5d0b7e16b9a2c7fccf63aeecb8f000.tar.gz
tools: Fix generate-docs-nm-settings-docs-gir.py on Python 2
On python2 the following error is raised: `LookupError: unknown encoding: unicode` Seems like `unicode` is a correct encoding in Python 3 but not 2. Fix: 1. Change encoding to `utf-8` 2. Pass output path string instead of opening file and passing opened file object. Python2 and 3 might need different file modes, passing just path lets ElementTree select appropriate file mode. Fixes: f00e90923c8c ('tools: Use ElementTree to write XML in generate-docs-nm-settings-docs-gir.py') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1249
-rwxr-xr-xtools/generate-docs-nm-settings-docs-gir.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/generate-docs-nm-settings-docs-gir.py b/tools/generate-docs-nm-settings-docs-gir.py
index a40234efbe..75d5d013a9 100755
--- a/tools/generate-docs-nm-settings-docs-gir.py
+++ b/tools/generate-docs-nm-settings-docs-gir.py
@@ -267,12 +267,11 @@ def main(gir_path_str, output_path_str):
attrib=property_attributes,
)
- with open(output_path_str, mode="w") as outfile:
- docs_gir.write(
- outfile,
- encoding="unicode",
- xml_declaration=True,
- )
+ docs_gir.write(
+ output_path_str,
+ xml_declaration=True,
+ encoding="utf-8",
+ )
if __name__ == "__main__":