mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-15 01:56:17 +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:
|
if e.errno == 19:
|
||||||
sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \
|
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))
|
'\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:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class Ar:
|
|||||||
else:
|
else:
|
||||||
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||||
except EnvironmentError, e:
|
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'
|
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
@ -144,8 +144,8 @@ class Cpio:
|
|||||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
||||||
else:
|
else:
|
||||||
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||||
except EnvironmentError, e:
|
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, failing back to default'
|
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
Loading…
Reference in New Issue
Block a user