public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/_emerge/resolver/, lib/portage/util/, lib/_emerge/, ...
@ 2021-03-06  9:05 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2021-03-06  9:05 UTC (permalink / raw
  To: gentoo-commits

commit:     21c6c0c1088ded78397594bfd78102361f8d837b
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Mar  4 19:23:47 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Mar  6 09:05:16 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=21c6c0c1

lib: Remove outdated Python 2 comments

Fixes: 788c0e8bb ("Remove from __future__ import unicode_literals")
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/egencache                                   | 2 --
 lib/_emerge/Package.py                          | 9 ---------
 lib/_emerge/Scheduler.py                        | 2 --
 lib/_emerge/UseFlagDisplay.py                   | 2 --
 lib/_emerge/resolver/output.py                  | 2 --
 lib/portage/cache/flat_hash.py                  | 3 ---
 lib/portage/tests/unicode/test_string_format.py | 9 ---------
 lib/portage/util/digraph.py                     | 3 ---
 8 files changed, 32 deletions(-)

diff --git a/bin/egencache b/bin/egencache
index 9b6df2e7d..fc18b892f 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -2,8 +2,6 @@
 # Copyright 2009-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-# unicode_literals for compat with TextIOWrapper in Python 2
-
 import argparse
 import platform
 import signal

diff --git a/lib/_emerge/Package.py b/lib/_emerge/Package.py
index 995af6311..0ee25b90a 100644
--- a/lib/_emerge/Package.py
+++ b/lib/_emerge/Package.py
@@ -453,15 +453,6 @@ class Package(Task):
 		else:
 			qacat = k + ".syntax"
 
-		# For unicode safety with python-2.x we need to avoid
-		# using the string format operator with a non-unicode
-		# format string, since that will result in the
-		# PortageException.__str__() method being invoked,
-		# followed by unsafe decoding that may result in a
-		# UnicodeDecodeError. Therefore, use unicode_literals
-		# to ensure that format strings are unicode, so that
-		# PortageException.__unicode__() is used when necessary
-		# in python-2.x.
 		if not self.installed:
 			categorized_error = False
 			if e.errors:

diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py
index 465f928a0..0ed2ee530 100644
--- a/lib/_emerge/Scheduler.py
+++ b/lib/_emerge/Scheduler.py
@@ -1188,8 +1188,6 @@ class Scheduler(PollScheduler):
 				printer.eerror(line)
 			printer.eerror("")
 			for failed_pkg in self._failed_pkgs_all:
-				# Use unicode_literals to force unicode format string so
-				# that Package.__unicode__() is called in python2.
 				msg = " %s" % (failed_pkg.pkg,)
 				if failed_pkg.postinst_failure:
 					msg += " (postinst failed)"

diff --git a/lib/_emerge/UseFlagDisplay.py b/lib/_emerge/UseFlagDisplay.py
index 5e3ba400d..fffc8144a 100644
--- a/lib/_emerge/UseFlagDisplay.py
+++ b/lib/_emerge/UseFlagDisplay.py
@@ -111,8 +111,6 @@ def pkg_use_display(pkg, opts, modified_use=None):
 			flags.sort(key=UseFlagDisplay.sort_combined)
 		else:
 			flags.sort(key=UseFlagDisplay.sort_separated)
-		# Use unicode_literals to force unicode format string so
-		# that UseFlagDisplay.__unicode__() is called in python2.
 		flag_displays.append('%s="%s"' % (varname,
 			' '.join("%s" % (f,) for f in flags)))
 

diff --git a/lib/_emerge/resolver/output.py b/lib/_emerge/resolver/output.py
index 0c90abefb..dea8a4be8 100644
--- a/lib/_emerge/resolver/output.py
+++ b/lib/_emerge/resolver/output.py
@@ -554,8 +554,6 @@ class Display:
 		"""
 		writemsg_stdout('\n%s\n' % (self.counters,), noiselevel=-1)
 		if show_repos:
-			# Use unicode_literals to force unicode format string so
-			# that RepoDisplay.__unicode__() is called in python2.
 			writemsg_stdout("%s" % (self.conf.repo_display,),
 				noiselevel=-1)
 

diff --git a/lib/portage/cache/flat_hash.py b/lib/portage/cache/flat_hash.py
index 7d48bae81..25930f0a4 100644
--- a/lib/portage/cache/flat_hash.py
+++ b/lib/portage/cache/flat_hash.py
@@ -73,9 +73,6 @@ class database(fs_template.FsBased):
 				v = values.get(k)
 				if not v:
 					continue
-				# NOTE: This format string requires unicode_literals, so that
-				# k and v are coerced to unicode, in order to prevent TypeError
-				# when writing raw bytes to TextIOWrapper with Python 2.
 				myf.write("%s=%s\n" % (k, v))
 
 		self._ensure_access(fp)

diff --git a/lib/portage/tests/unicode/test_string_format.py b/lib/portage/tests/unicode/test_string_format.py
index 3b994d622..54ac038a6 100644
--- a/lib/portage/tests/unicode/test_string_format.py
+++ b/lib/portage/tests/unicode/test_string_format.py
@@ -15,9 +15,6 @@ class StringFormatTestCase(TestCase):
 	which may be either python2 or python3.
 	"""
 
-	# We need unicode_literals in order to get some unicode test strings
-	# in a way that works in both python2 and python3.
-
 	unicode_strings = (
 		'\u2018',
 		'\u2019',
@@ -31,8 +28,6 @@ class StringFormatTestCase(TestCase):
 			arg_bytes = _unicode_encode(arg_unicode, encoding=_encodings['content'])
 			dependency_arg = DependencyArg(arg=arg_unicode)
 
-			# Use unicode_literals for unicode format string so that
-			# __unicode__() is called in Python 2.
 			formatted_str = "%s" % (dependency_arg,)
 			self.assertEqual(formatted_str, arg_unicode)
 
@@ -48,8 +43,6 @@ class StringFormatTestCase(TestCase):
 			arg_bytes = _unicode_encode(arg_unicode, encoding=_encodings['content'])
 			e = PortageException(arg_unicode)
 
-			# Use unicode_literals for unicode format string so that
-			# __unicode__() is called in Python 2.
 			formatted_str = "%s" % (e,)
 			self.assertEqual(formatted_str, arg_unicode)
 
@@ -66,8 +59,6 @@ class StringFormatTestCase(TestCase):
 				for arg_unicode in self.unicode_strings:
 					e = UseFlagDisplay(arg_unicode, enabled, forced)
 
-					# Use unicode_literals for unicode format string so that
-					# __unicode__() is called in Python 2.
 					formatted_str = "%s" % (e,)
 					self.assertEqual(isinstance(formatted_str, str), True)
 

diff --git a/lib/portage/util/digraph.py b/lib/portage/util/digraph.py
index c262cddee..623f2d988 100644
--- a/lib/portage/util/digraph.py
+++ b/lib/portage/util/digraph.py
@@ -311,9 +311,6 @@ class digraph:
 	def debug_print(self):
 		def output(s):
 			writemsg(s, noiselevel=-1)
-		# Use unicode_literals to force unicode format
-		# strings for python-2.x safety, ensuring that
-		# node.__unicode__() is used when necessary.
 		for node in self.nodes:
 			output("%s " % (node,))
 			if self.nodes[node][0]:


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-06  9:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-06  9:05 [gentoo-commits] proj/portage:master commit in: lib/_emerge/resolver/, lib/portage/util/, lib/_emerge/, Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox