summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gentoo.org>2006-02-08 17:51:52 +0000
committerBrian Harring <ferringb@gentoo.org>2006-02-08 17:51:52 +0000
commitedd47ff474c5a1fce57ea0b274014476d129f075 (patch)
treeb07334bd3945cb00dff33f0bdb8b95b236c4bca7
parent3b56aa98fef2104b458777f611a5ee4ebc551a31 (diff)
downloadportage-edd47ff474c5a1fce57ea0b274014476d129f075.tar.gz
portage-edd47ff474c5a1fce57ea0b274014476d129f075.tar.bz2
portage-edd47ff474c5a1fce57ea0b274014476d129f075.zip
cPickle import protection; fall back to pickle if cPickle is unavailable.
svn path=/main/trunk/; revision=2679
-rw-r--r--pym/getbinpkg.py7
-rw-r--r--pym/portage.py6
-rw-r--r--pym/portage_util.py9
3 files changed, 18 insertions, 4 deletions
diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py
index ccffc1dd2..d9c9810f5 100644
--- a/pym/getbinpkg.py
+++ b/pym/getbinpkg.py
@@ -5,7 +5,12 @@
from output import *
-import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,cPickle,base64
+import htmllib,HTMLParser,string,formatter,sys,os,xpak,time,tempfile,base64
+
+try:
+ import cPickle
+except ImportError:
+ import pickle as cPickle
try:
import ftplib
diff --git a/pym/portage.py b/pym/portage.py
index 0849841ae..0018ab914 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -20,9 +20,13 @@ except:
try:
import os,string,types,signal,fcntl
- import time,cPickle,traceback,copy
+ import time,traceback,copy
import re,pwd,grp,commands
import shlex,shutil
+ try:
+ import cPickle
+ except ImportError:
+ import pickle as cPickle
import stat
import commands
diff --git a/pym/portage_util.py b/pym/portage_util.py
index ef155b5db..ddb1426ad 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -4,6 +4,11 @@
import sys,string,shlex,os.path
+try:
+ import cPickle
+except ImportError:
+ import pickle as cPickle
+
if not hasattr(__builtins__, "set"):
from sets import Set as set
@@ -365,7 +370,7 @@ def varexpand(mystring,mydict={}):
return newstring[1:]
def pickle_write(data,filename,debug=0):
- import cPickle,os
+ import os
try:
myf=open(filename,"w")
cPickle.dump(data,myf,-1)
@@ -381,7 +386,7 @@ def pickle_write(data,filename,debug=0):
return 1
def pickle_read(filename,default=None,debug=0):
- import cPickle,os
+ import os
if not os.access(filename, os.R_OK):
writemsg("pickle_read(): File not readable. '"+filename+"'\n",1)
return default