llvm.org GIT mirror llvm / ed38195
Python compat - portable way of raising exceptions Differential Revision: https://reviews.llvm.org/D56256 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350311 91177308-0d34-0410-b5e6-96231b3b80d8 Serge Guelton 1 year, 4 months ago
1 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
4343
4444 # Not supported (Enums are immutable).
4545 def __setattr__(self, name, value):
46 raise NotSupportedException, self.__setattr__
46 raise NotSupportedException(self.__setattr__)
4747
4848 # Not supported (Enums are immutable).
4949 def __delattr__(self, name):
50 raise NotSupportedException, self.__delattr__
50 raise NotSupportedException(self.__delattr__)
5151
5252 # Gets the enum symbol for the specified value.
5353 def __getitem__(self, value):
5454 symbol = self._map.get(value)
5555 if symbol is None:
56 raise KeyError, value
56 raise KeyError(value)
5757 return symbol
5858
5959 # Gets the enum symbol for the specified value or none.
6363
6464 # Not supported (Enums are immutable).
6565 def __setitem__(self, value, symbol):
66 raise NotSupportedException, self.__setitem__
66 raise NotSupportedException(self.__setitem__)
6767
6868 # Not supported (Enums are immutable).
6969 def __delitem__(self, value):
70 raise NotSupportedException, self.__delitem__
70 raise NotSupportedException(self.__delitem__)
7171
7272 def entries(self):
7373 # sort by (value, name)
100100 def read(self, N):
101101 data = self.file.read(N)
102102 if len(data) != N:
103 raise ValueError, "Out of data!"
103 raise ValueError("Out of data!")
104104 return data
105105
106106 def int8(self):
266266 elif fileclass == 2:
267267 f.is64Bit = True
268268 else:
269 raise ValueError, "Unknown file class %x" % fileclass
269 raise ValueError("Unknown file class %x" % fileclass)
270270
271271 byteordering = f.uint8()
272272 if byteordering == 1:
274274 elif byteordering == 2:
275275 f.isLSB = False
276276 else:
277 raise ValueError, "Unknown byte ordering %x" % byteordering
277 raise ValueError("Unknown byte ordering %x" % byteordering)
278278
279279 f.seek(18)
280280 e_machine = f.uint16()
375375 elif magic == '\xCF\xFA\xED\xFE':
376376 f.isLSB, f.is64Bit = True, True
377377 else:
378 raise ValueError,"Not a Mach-O object file: %r (bad magic)" % path
378 raise ValueError("Not a Mach-O object file: %r (bad magic)" % path)
379379
380380 cputype = f.uint32()
381381 cpusubtype = f.uint32()
392392 patchMachoLoadCommand(f, relocs)
393393
394394 if f.tell() - start != loadCommandsSize:
395 raise ValueError,"%s: warning: invalid load commands size: %r" % (
396 sys.argv[0], loadCommandsSize)
395 raise ValueError("%s: warning: invalid load commands size: %r" % (
396 sys.argv[0], loadCommandsSize))
397397
398398 def patchMachoLoadCommand(f, relocs):
399399 start = f.tell()
408408 f.read(cmdSize - 8)
409409
410410 if f.tell() - start != cmdSize:
411 raise ValueError,"%s: warning: invalid load command size: %r" % (
412 sys.argv[0], cmdSize)
411 raise ValueError("%s: warning: invalid load command size: %r" % (
412 sys.argv[0], cmdSize))
413413
414414 def patchMachoSegmentLoadCommand(f, relocs):
415415 segment_name = f.read(16)