From 6b0fa9551ed9294f40c4f8b82fe82432a959a64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 28 Dec 2018 17:40:35 +0100 Subject: [PATCH] Opens services file as utf-8 even in edge cases In edge cases (usually when system locale is not installed) Gtk falls back to 'C' (not C.utf-8 ...) locale. Fixed that to enforce utf-8 always. fixes QubesOS/qubes-issues#4475 --- qubesmanager/firewall.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesmanager/firewall.py b/qubesmanager/firewall.py index d0a5f1e..8e2f8f2 100644 --- a/qubesmanager/firewall.py +++ b/qubesmanager/firewall.py @@ -138,6 +138,7 @@ class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg): if checked: self.serviceComboBox.setEnabled(False) + class QubesFirewallRulesModel(QtCore.QAbstractItemModel): def __init__(self, parent=None): QtCore.QAbstractItemModel.__init__(self, parent) @@ -148,7 +149,7 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): r"(?P[a-z][a-z0-9-]+)\s+(?P[0-9]+)/" r"(?P[a-z]+)", re.IGNORECASE) - with open('/etc/services', 'r') as file: + with open('/etc/services', 'r', encoding='utf-8') as file: for line in file: match = pattern.match(line) if match is not None: