@@ -94,7 +94,7 @@ def remove(*args, **kwargs):
94
94
#{ compatibility stuff ...
95
95
96
96
97
- class _RandomAccessBytesIO ( object ) :
97
+ class _RandomAccessBytesIO :
98
98
99
99
"""Wrapper to provide required functionality in case memory maps cannot or may
100
100
not be used. This is only really required in python 2.4"""
@@ -131,7 +131,7 @@ def byte_ord(b):
131
131
#{ Routines
132
132
133
133
134
- def make_sha (source = '' . encode ( "ascii" ) ):
134
+ def make_sha (source = b'' ):
135
135
"""A python2.4 workaround for the sha/hashlib module fiasco
136
136
137
137
**Note** From the dulwich project """
@@ -151,7 +151,7 @@ def allocate_memory(size):
151
151
152
152
try :
153
153
return mmap .mmap (- 1 , size ) # read-write by default
154
- except EnvironmentError :
154
+ except OSError :
155
155
# setup real memory instead
156
156
# this of course may fail if the amount of memory is not available in
157
157
# one chunk - would only be the case in python 2.4, being more likely on
@@ -174,7 +174,7 @@ def file_contents_ro(fd, stream=False, allow_mmap=True):
174
174
# supports stream and random access
175
175
try :
176
176
return mmap .mmap (fd , 0 , access = mmap .ACCESS_READ )
177
- except EnvironmentError :
177
+ except OSError :
178
178
# python 2.4 issue, 0 wants to be the actual size
179
179
return mmap .mmap (fd , os .fstat (fd ).st_size , access = mmap .ACCESS_READ )
180
180
# END handle python 2.4
@@ -234,7 +234,7 @@ def to_bin_sha(sha):
234
234
235
235
#{ Utilities
236
236
237
- class LazyMixin ( object ) :
237
+ class LazyMixin :
238
238
239
239
"""
240
240
Base class providing an interface to lazily retrieve attribute values upon
@@ -266,7 +266,7 @@ def _set_cache_(self, attr):
266
266
pass
267
267
268
268
269
- class LockedFD ( object ) :
269
+ class LockedFD :
270
270
271
271
"""
272
272
This class facilitates a safe read and write operation to a file on disk.
@@ -327,7 +327,7 @@ def open(self, write=False, stream=False):
327
327
self ._fd = fd
328
328
# END handle file descriptor
329
329
except OSError as e :
330
- raise IOError ("Lock at %r could not be obtained" % self ._lockfilepath ()) from e
330
+ raise OSError ("Lock at %r could not be obtained" % self ._lockfilepath ()) from e
331
331
# END handle lock retrieval
332
332
333
333
# open actual file if required
0 commit comments