Merge ~mitchburton/ubuntu/+source/landscape-client:2020064-fix-locale-error-focal into ubuntu/+source/landscape-client:ubuntu/focal-devel

Proposed by Mitch Burton
Status: Needs review
Proposed branch: ~mitchburton/ubuntu/+source/landscape-client:2020064-fix-locale-error-focal
Merge into: ubuntu/+source/landscape-client:ubuntu/focal-devel
Diff against target: 132 lines (+111/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/0002-fix-locale-error.patch (+102/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Simon Quigley (community) Approve
git-ubuntu import Pending
Review via email: mp+478635@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Simon Quigley (tsimonq2) :
review: Approve

Unmerged commits

d6b59c5... by Mitch Burton

release for focal

2b874b6... by Mitch Burton

d/p/0002-fix-locale-error.patch: revert previous fix for LP: #1827857

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 3b78974..86246ae 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+landscape-client (23.02-0ubuntu1~20.04.5) focal; urgency=medium
7+
8+ * d/p/0002-fix-locale-error.path: revert previous fix for #1827857, as
9+ it has been fixed in the dependency package python3-apt. Reverting this
10+ fix fixes package-reporter when some locales are missing. (LP: #2020064)
11+
12+ -- Mitch Burton <mitch.burton@canonical.com> Wed, 18 Dec 2024 16:06:43 -0800
13+
14 landscape-client (23.02-0ubuntu1~20.04.4) focal; urgency=medium
15
16 * d/p/add-non-filtered-interfaces-to-the-api-response.patch: include
17diff --git a/debian/patches/0002-fix-locale-error.patch b/debian/patches/0002-fix-locale-error.patch
18new file mode 100644
19index 0000000..102ff9d
20--- /dev/null
21+++ b/debian/patches/0002-fix-locale-error.patch
22@@ -0,0 +1,102 @@
23+Description: revert previous fix for LP: #1827857
24+ The fix was implemented in python3-apt >= 2.0.0. The changes in landscape-client now
25+ cause issues with package reporter on machines with certain locale configurations.
26+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/landscape-client/+bug/2020064
27+Author: Mitch Burton <mitch.burton@canonical.com>
28+Origin: backport, https://github.com/canonical/landscape-client/commit/1cbf5e0466287a9bd9acafff9c048c834328ac24
29+Applied-Upstream: 24.11
30+Last-Update: 2024-12-17
31+---
32+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
33+--- a/landscape/client/package/reporter.py
34++++ b/landscape/client/package/reporter.py
35+@@ -3,7 +3,6 @@
36+ except ImportError:
37+ import urllib.parse as urlparse
38+
39+-import locale
40+ import logging
41+ import time
42+ import os
43+@@ -867,10 +866,6 @@
44+
45+
46+ def main(args):
47+- # Force UTF-8 encoding only for the reporter, thus allowing libapt-pkg to
48+- # return unmangled descriptions.
49+- locale.setlocale(locale.LC_CTYPE, ("C", "UTF-8"))
50+-
51+ if "FAKE_GLOBAL_PACKAGE_STORE" in os.environ:
52+ return run_task_handler(FakeGlobalReporter, args)
53+ elif "FAKE_PACKAGE_STORE" in os.environ:
54+--- a/landscape/client/package/tests/test_reporter.py
55++++ b/landscape/client/package/tests/test_reporter.py
56+@@ -1,4 +1,3 @@
57+-import locale
58+ import sys
59+ import os
60+ import time
61+@@ -1232,31 +1231,6 @@
62+ self.assertEqual("RESULT", main(["ARGS"]))
63+ m.assert_called_once_with(PackageReporter, ["ARGS"])
64+
65+- def test_main_resets_locale(self):
66+- """
67+- Reporter entry point should reset encoding to utf-8, as libapt-pkg
68+- encodes description with system encoding and python-apt decodes
69+- them as utf-8 (LP: #1827857).
70+- """
71+- self._add_package_to_deb_dir(
72+- self.repository_dir, "gosa", description=u"GOsa\u00B2")
73+- self.facade.reload_channels()
74+-
75+- # Set the only non-utf8 locale which we're sure exists.
76+- # It behaves slightly differently than the bug, but fails on the
77+- # same condition.
78+- locale.setlocale(locale.LC_CTYPE, (None, None))
79+- self.addCleanup(locale.resetlocale)
80+-
81+- with mock.patch("landscape.client.package.reporter.run_task_handler"):
82+- main([])
83+-
84+- # With the actual package, the failure will occur looking up the
85+- # description translation.
86+- pkg = self.facade.get_packages_by_name("gosa")[0]
87+- skel = self.facade.get_package_skeleton(pkg, with_info=True)
88+- self.assertEqual(u"GOsa\u00B2", skel.description)
89+-
90+ def test_find_reporter_command_with_bindir(self):
91+ self.config.bindir = "/spam/eggs"
92+ command = find_reporter_command(self.config)
93+--- a/landscape/lib/apt/package/tests/test_skeleton.py
94++++ b/landscape/lib/apt/package/tests/test_skeleton.py
95+@@ -1,4 +1,3 @@
96+-import locale
97+ import unittest
98+
99+ from landscape.lib import testing
100+@@ -148,22 +147,15 @@
101+ def test_build_skeleton_with_unicode_and_non_ascii(self):
102+ """
103+ If with_unicode and with_info are passed to build_skeleton_apt,
104+- the description is decoded.
105++ the description is decoded and non-ascii chars replaced.
106+ """
107+- # Py2 used to convert to lossy ascii (thus LC_ in Makefile)
108+- # Py3 doesn't, and python3-apt assumes UTF8 (LP: #1827857).
109+- # If you revisit this test, also check reporter.main(), which
110+- # should set this globally to the reporter process.
111+- locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
112+- self.addCleanup(locale.resetlocale)
113+-
114+ self._add_package_to_deb_dir(
115+ self.skeleton_repository_dir, "pkg", description=u"T\xe9st")
116+ self.facade._cache.update(None)
117+ self.facade._cache.open(None)
118+ pkg = self.get_package("pkg")
119+ skeleton = build_skeleton_apt(pkg, with_unicode=True, with_info=True)
120+- self.assertEqual(u"T\u00E9st", skeleton.description)
121++ self.assertEqual("T?st", skeleton.description)
122+
123+ def test_build_skeleton_minimal(self):
124+ """
125diff --git a/debian/patches/series b/debian/patches/series
126index 6c61034..1d2050f 100644
127--- a/debian/patches/series
128+++ b/debian/patches/series
129@@ -1,2 +1,3 @@
130 0001-start-service-during-config.patch
131 add-non-filtered-interfaces-to-the-api-response.patch
132+0002-fix-locale-error.patch

Subscribers

People subscribed via source and target branches