mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-14 09:36:21 +01:00
add more checks when working with mmap.mmap
This commit is contained in:
parent
5f19030580
commit
e97c1de936
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user