1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-14 01:26:23 +01:00

add more checks when working with mmap.mmap

This commit is contained in:
Pavol Rusnak 2009-05-22 14:43:39 +00:00
parent 5f19030580
commit e97c1de936
3 changed files with 6 additions and 3 deletions

View File

@ -1545,6 +1545,9 @@ def http_request(method, url, headers={}, data=None, file=None, timeout=100):
if e.errno == 19:
sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \
'\non a filesystem which does not support this.' % (e, file))
elif hasattr(e, 'winerror') and e.winerror == 5:
# falling back to the default io
data = open(file).read()
else:
raise

View File

@ -152,7 +152,7 @@ class Ar:
else:
self.__file = mmap.mmap(self.__file.fileno(), 0)
except EnvironmentError, e:
if e.errno == 19:
if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ):
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
else:
raise e

View File

@ -144,8 +144,8 @@ class Cpio:
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
else:
self.__file = mmap.mmap(self.__file.fileno(), 0)
except EnvironmentError, e:
if e.errno == 19:
except: EnvironmentError, e:
if e.errno == 19 or ( hasattr(e, 'winerror') and e.winerror == 5 ):
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
else:
raise e