for x in args]
if kwargs:
wrapped_kwargs = dict(
- (_unicode_encode(k, encoding=encoding, errors='strict'),
- _unicode_encode(v, encoding=encoding, errors='strict'))
+ (k, _unicode_encode(v, encoding=encoding, errors='strict'))
for k, v in kwargs.items())
else:
wrapped_kwargs = {}
else:
_disable_openpty = False
+if sys.hexversion >= 0x3000000:
+ # This is a temporary workaround for http://bugs.python.org/issue5380.
+ _disable_openpty = True
+
def _create_pty_or_pipe(copy_term_size=None):
"""
Try to create a pty and if then fails then create a normal
writemsg("%s\n" % e)
writemsg(_("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n") % \
(mysettings["PORTAGE_WORKDIR_MODE"], oct(workdir_mode)))
- mysettings["PORTAGE_WORKDIR_MODE"] = oct(workdir_mode)
+ mysettings["PORTAGE_WORKDIR_MODE"] = oct(workdir_mode).replace('o', '')
try:
apply_secpass_permissions(mysettings["WORKDIR"],
uid=portage_uid, gid=portage_gid, mode=workdir_mode)
keys.sort()
self._writepkgindex(pkgfile, [(k, self.header[k]) \
for k in keys if self.header[k]])
- for metadata in sorted(self.packages, _cmp_cpv):
+ for metadata in sorted(self.packages,
+ key=portage.util.cmp_sort_key(_cmp_cpv)):
metadata = metadata.copy()
cpv = metadata["CPV"]
if self._inherited_keys:
if isinstance(mycommand, basestring):
mycommand = mycommand.split()
- # Avoid a potential UnicodeEncodeError from os.execve().
- env_bytes = {}
- for k, v in env.items():
- env_bytes[_unicode_encode(k, encoding=_encodings['content'])] = \
- _unicode_encode(v, encoding=_encodings['content'])
- env = env_bytes
- del env_bytes
+ if sys.hexversion < 0x3000000:
+ # Avoid a potential UnicodeEncodeError from os.execve().
+ env_bytes = {}
+ for k, v in env.items():
+ env_bytes[_unicode_encode(k, encoding=_encodings['content'])] = \
+ _unicode_encode(v, encoding=_encodings['content'])
+ env = env_bytes
+ del env_bytes
# If an absolute path to an executable file isn't given
# search for it unless we've been told not to.
if pre_exec:
pre_exec()
- # Decode all keys for compatibility with Python 3.
- env_decoded = {}
- for k, v in env.items():
- env_decoded[_unicode_decode(k)] = v
-
# And switch to the new process.
- os.execve(binary, myargs, env_decoded)
+ os.execve(binary, myargs, env)
def find_binary(binary):
"""
@rtype: None or string
@returns: full path to binary or None if the binary could not be located.
"""
-
- for path in os.getenv("PATH", "").split(":"):
+ for path in os.environ.get("PATH", "").split(":"):
filename = "%s/%s" % (path, binary)
if os.access(filename, os.X_OK) and os.path.isfile(filename):
return filename
import array
import errno
import shutil
+import sys
from portage import os
from portage import normalize_path
def decodeint(mystring):
"""Takes a 4 byte string and converts it into a 4 byte integer.
Returns an integer."""
- myint=0
- myint=myint+ord(mystring[3])
- myint=myint+(ord(mystring[2]) << 8)
- myint=myint+(ord(mystring[1]) << 16)
- myint=myint+(ord(mystring[0]) << 24)
+ if sys.hexversion < 0x3000000:
+ mystring = [ord(x) for x in mystring]
+ myint = 0
+ myint += mystring[3]
+ myint += mystring[2] << 8
+ myint += mystring[1] << 16
+ myint += mystring[0] << 24
return myint
def xpak(rootdir,outfile=None):
def searchindex(myindex,myitem):
"""(index,item) -- Finds the offset and length of the file 'item' in the
datasegment via the index 'index' provided."""
+ myitem = _unicode_encode(myitem,
+ encoding=_encodings['repo.content'], errors='backslashreplace')
mylen=len(myitem)
myindexlen=len(myindex)
startpos=0
datapos=decodeint(self.index[startpos+4+namelen:startpos+8+namelen]);
datalen=decodeint(self.index[startpos+8+namelen:startpos+12+namelen]);
myname=self.index[startpos+4:startpos+4+namelen]
+ myname = _unicode_decode(myname,
+ encoding=_encodings['repo.content'], errors='replace')
dirname=os.path.dirname(myname)
if dirname:
if not os.path.exists(dirname):