public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/, pym/_emerge/
@ 2013-06-20 10:15 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2013-06-20 10:15 UTC (permalink / raw
  To: gentoo-commits

commit:     a636c88eb998c562bfa8310862caa36315335aae
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 20 10:11:37 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jun 20 10:11:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a636c88e

Decode sys.argv with surrogateescape for Python 3

With Python 3, the surrogateescape encoding error handler makes it
possible to access the original argv bytes, which can be useful
if their actual encoding does no match the filesystem encoding.

---
 bin/portageq            |  3 +--
 bin/repoman             |  3 +--
 pym/_emerge/main.py     |  6 ++----
 pym/portage/__init__.py | 13 +++++++++++++
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index 1ae1fe1..4be9f88 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1148,8 +1148,7 @@ else:
 
 def main(argv):
 
-	if argv and isinstance(argv[0], bytes):
-		argv = [portage._unicode_decode(x) for x in argv]
+	argv = portage._decode_argv(argv)
 
 	nocolor = os.environ.get('NOCOLOR')
 	if nocolor in ('yes', 'true'):

diff --git a/bin/repoman b/bin/repoman
index c4a5a22..ff481d7 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -156,8 +156,7 @@ def ParseArgs(argv, qahelp):
 	  (opts, args), just like a call to parser.parse_args()
 	"""
 
-	if argv and isinstance(argv[0], bytes):
-		argv = [portage._unicode_decode(x) for x in argv]
+	argv = portage._decode_argv(argv)
 
 	modes = {
 		'commit' : 'Run a scan then commit changes',

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index b26ce30..fe9fb29 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -981,10 +981,6 @@ def parse_opts(tmpcmdline, silent=False):
 	if myaction is None and myoptions.deselect is True:
 		myaction = 'deselect'
 
-	if myargs and isinstance(myargs[0], bytes):
-		for i in range(len(myargs)):
-			myargs[i] = portage._unicode_decode(myargs[i])
-
 	myfiles += myargs
 
 	return myaction, myopts, myfiles
@@ -1014,6 +1010,8 @@ def emerge_main(args=None):
 	if args is None:
 		args = sys.argv[1:]
 
+	args = portage._decode_argv(args)
+
 	# Disable color until we're sure that it should be enabled (after
 	# EMERGE_DEFAULT_OPTS has been parsed).
 	portage.output.havecolor = 0

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 7656c6e..d6da9f7 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -174,6 +174,15 @@ _encodings = {
 }
 
 if sys.hexversion >= 0x3000000:
+
+	def _decode_argv(argv):
+		# With Python 3, the surrogateescape encoding error handler makes it
+		# possible to access the original argv bytes, which can be useful
+		# if their actual encoding does no match the filesystem encoding.
+		fs_encoding = sys.getfilesystemencoding()
+		return [_unicode_decode(x.encode(fs_encoding, 'surrogateescape'))
+			for x in argv]
+
 	def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):
 		if isinstance(s, str):
 			s = s.encode(encoding, errors)
@@ -186,6 +195,10 @@ if sys.hexversion >= 0x3000000:
 
 	_native_string = _unicode_decode
 else:
+
+	def _decode_argv(argv):
+		return [_unicode_decode(x) for x in argv]
+
 	def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):
 		if isinstance(s, unicode):
 			s = s.encode(encoding, errors)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/, pym/_emerge/
@ 2018-03-11 11:44 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2018-03-11 11:44 UTC (permalink / raw
  To: gentoo-commits

commit:     a5e02c92fd72aad6eb9031cdc04f634543ebdd15
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 21 09:54:18 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Mar 11 11:43:41 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a5e02c92

Support ENV_UNSET for EAPI 7

Bug: https://bugs.gentoo.org/499288

 bin/eapi.sh            | 4 ++++
 bin/ebuild.sh          | 6 ++++++
 pym/_emerge/actions.py | 4 ++--
 pym/portage/const.py   | 3 ++-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 1d5ea802d..569b8a0de 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -215,3 +215,7 @@ ___eapi_bash_3_2() {
 ___eapi_bash_4_2() {
 	! ___eapi_bash_3_2 "$@"
 }
+
+___eapi_has_ENV_UNSET() {
+	[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-progress|6)$ ]]
+}

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index d63b0a0ba..67d255f78 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -137,6 +137,12 @@ shift $#
 
 # Unset some variables that break things.
 unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
+if ___eapi_has_ENV_UNSET; then
+	for x in ${ENV_UNSET}; do
+		unset "${x}"
+	done
+	unset x
+fi
 
 [[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
 

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 97df9f716..2293560c1 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import division, print_function, unicode_literals
@@ -1817,7 +1817,7 @@ def action_info(settings, trees, myopts, myfiles):
 		myvars = list(settings)
 	else:
 		myvars = ['GENTOO_MIRRORS', 'CONFIG_PROTECT', 'CONFIG_PROTECT_MASK',
-		          'DISTDIR', 'PKGDIR', 'PORTAGE_TMPDIR',
+		          'DISTDIR', 'ENV_UNSET', 'PKGDIR', 'PORTAGE_TMPDIR',
 		          'PORTAGE_BUNZIP2_COMMAND',
 		          'PORTAGE_BZIP2_COMMAND',
 		          'USE', 'CHOST', 'CFLAGS', 'CXXFLAGS',

diff --git a/pym/portage/const.py b/pym/portage/const.py
index 655be82b1..16922a5e6 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -1,5 +1,5 @@
 # portage: Constants
-# Copyright 1998-2014 Gentoo Foundation
+# Copyright 1998-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -89,6 +89,7 @@ INCREMENTALS             = (
 	"ACCEPT_KEYWORDS",
 	"CONFIG_PROTECT",
 	"CONFIG_PROTECT_MASK",
+	"ENV_UNSET",
 	"FEATURES",
 	"IUSE_IMPLICIT",
 	"PRELINK_PATH",


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-11 11:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-11 11:44 [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/, pym/_emerge/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20 10:15 Zac Medico

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