Write temporary XML file as UTF-8 in pom_editor

This commit is contained in:
Michael Simacek 2015-02-16 18:46:18 +01:00
parent c4deeb0e07
commit 06282ff448
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From 4374dc79828c75820d119ce221e95b74900afc52 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Mon, 16 Feb 2015 17:32:03 +0100
Subject: [PATCH] [pom_editor] Write temporary XML file as UTF-8
---
java-utils/pom_editor.py | 2 +-
test/data/pom_macros/pom_unicode.xml | 16 ++++++++++++++++
test/data/pom_macros/pom_unicode.xml-want | 16 ++++++++++++++++
test/pom_macros_test.py | 7 +++++++
4 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 test/data/pom_macros/pom_unicode.xml
create mode 100644 test/data/pom_macros/pom_unicode.xml-want
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
index 1c30878..201ccf1 100644
--- a/java-utils/pom_editor.py
+++ b/java-utils/pom_editor.py
@@ -212,7 +212,7 @@ class XmlFile(object):
raw_xml = self._preprocess_raw(raw_xml)
self.xml_declaration = re.match(r'\<\?xml\s[^?]*\?\>', raw_xml)
tmpfile = self.xmlpath + '.tmp'
- with io.open(tmpfile, 'w') as prepared:
+ with io.open(tmpfile, 'w', encoding='UTF-8') as prepared:
prepared.write(raw_xml)
self.document = etree.parse(tmpfile)
self.tab = get_indent(self.root)

View File

@ -9,7 +9,7 @@
Name: javapackages-tools
Version: 4.4.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Macros and scripts for Java packaging support
@ -17,6 +17,8 @@ License: BSD
URL: https://git.fedorahosted.org/git/javapackages.git
Source0: https://fedorahosted.org/released/javapackages/javapackages-%{version}.tar.xz
Patch0: 0001-pom_editor-Write-temporary-XML-file-as-UTF-8.patch
BuildArch: noarch
%if 0%{?with_python3}
@ -174,6 +176,8 @@ This package provides non-essential macros and scripts to support Java packaging
%prep
%setup -q -n javapackages-%{version}
%patch0 -p1
%build
%if 0%{?with_python3}
%configure --pyinterpreter=%{__python3}
@ -227,6 +231,9 @@ popd
%doc LICENSE
%changelog
* Mon Feb 16 2015 Michael Simacek <msimacek@redhat.com> - 4.4.0-2
- Write temporary XML file as UTF-8 in pom_editor
* Mon Feb 16 2015 Michal Srb <msrb@redhat.com> - 4.4.0-1
- Update to upstream version 4.4.0