summaryrefslogtreecommitdiffstats
path: root/pym/portage/xpak.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-21 19:51:02 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-21 19:51:02 +0000
commitcade65d7ebc054a89f2d6b92b26dff8b748a8fbd (patch)
treed48d9211429220347c0564148e7d8eac5404acbd /pym/portage/xpak.py
parent105d77cd158b396dec900d4568dbed46696cdc82 (diff)
downloadportage-cade65d7ebc054a89f2d6b92b26dff8b748a8fbd.tar.gz
portage-cade65d7ebc054a89f2d6b92b26dff8b748a8fbd.tar.bz2
portage-cade65d7ebc054a89f2d6b92b26dff8b748a8fbd.zip
Fix decodeint() for py3k compat, since bytes are a sequence of integers
instead of characters. svn path=/main/trunk/; revision=14361
Diffstat (limited to 'pym/portage/xpak.py')
-rw-r--r--pym/portage/xpak.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py
index b5878befb..8838891ca 100644
--- a/pym/portage/xpak.py
+++ b/pym/portage/xpak.py
@@ -19,6 +19,7 @@
import array
import errno
import shutil
+import sys
from portage import os
from portage import normalize_path
@@ -65,11 +66,13 @@ def encodeint(myint):
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):