summaryrefslogtreecommitdiffstats
path: root/pym/portage/checksum.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage/checksum.py')
-rw-r--r--pym/portage/checksum.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py
index f640fd9f1..eeb5995bb 100644
--- a/pym/portage/checksum.py
+++ b/pym/portage/checksum.py
@@ -29,8 +29,19 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"):
@type filename: String
@return: The hash and size of the data
"""
- f = open(_unicode_encode(filename,
- encoding=_encodings['fs'], errors='strict'), 'rb')
+ try:
+ f = open(_unicode_encode(filename,
+ encoding=_encodings['fs'], errors='strict'), 'rb')
+ except IOError as e:
+ func_call = "open('%s')" % filename
+ if e.errno == errno.EPERM:
+ raise portage.exception.OperationNotPermitted(func_call)
+ elif e.errno == errno.EACCES:
+ raise portage.exception.PermissionDenied(func_call)
+ elif e.errno == errno.ENOENT:
+ raise portage.exception.FileNotFound(filename)
+ else:
+ raise
blocksize = HASHING_BLOCKSIZE
data = f.read(blocksize)
size = 0