Errors: Fix passing 'self' to the constructors of the superclasses

This is necessary only if the superclass name is specified explicitly instead of super() call.
This commit is contained in:
Dmitry D. Chernov 2018-02-14 17:09:22 +10:00
parent 08b9d7c4ef
commit 55bcc29ae0
3 changed files with 8 additions and 10 deletions

View File

@ -4,7 +4,7 @@
class ReadCancelledError(Exception): class ReadCancelledError(Exception):
"""Occurs when a read operation was cancelled.""" """Occurs when a read operation was cancelled."""
def __init__(self): def __init__(self):
super().__init__(self, 'The read operation was cancelled.') super().__init__('The read operation was cancelled.')
class TypeNotFoundError(Exception): class TypeNotFoundError(Exception):
@ -14,7 +14,7 @@ class TypeNotFoundError(Exception):
""" """
def __init__(self, invalid_constructor_id): def __init__(self, invalid_constructor_id):
super().__init__( super().__init__(
self, 'Could not find a matching Constructor ID for the TLObject ' 'Could not find a matching Constructor ID for the TLObject '
'that was supposed to be read with ID {}. Most likely, a TLObject ' 'that was supposed to be read with ID {}. Most likely, a TLObject '
'was trying to be read when it should not be read.' 'was trying to be read when it should not be read.'
.format(hex(invalid_constructor_id))) .format(hex(invalid_constructor_id)))
@ -29,7 +29,6 @@ class InvalidChecksumError(Exception):
""" """
def __init__(self, checksum, valid_checksum): def __init__(self, checksum, valid_checksum):
super().__init__( super().__init__(
self,
'Invalid checksum ({} when {} was expected). ' 'Invalid checksum ({} when {} was expected). '
'This packet should be skipped.' 'This packet should be skipped.'
.format(checksum, valid_checksum)) .format(checksum, valid_checksum))
@ -44,7 +43,6 @@ class BrokenAuthKeyError(Exception):
""" """
def __init__(self): def __init__(self):
super().__init__( super().__init__(
self,
'The authorization key is broken, and it must be reset.' 'The authorization key is broken, and it must be reset.'
) )
@ -56,7 +54,7 @@ class SecurityError(Exception):
def __init__(self, *args): def __init__(self, *args):
if not args: if not args:
args = ['A security check failed.'] args = ['A security check failed.']
super().__init__(self, *args) super().__init__(*args)
class CdnFileTamperedError(SecurityError): class CdnFileTamperedError(SecurityError):

View File

@ -40,7 +40,7 @@ class ForbiddenError(RPCError):
message = 'FORBIDDEN' message = 'FORBIDDEN'
def __init__(self, message): def __init__(self, message):
super().__init__(self, message) super().__init__(message)
self.message = message self.message = message
@ -52,7 +52,7 @@ class NotFoundError(RPCError):
message = 'NOT_FOUND' message = 'NOT_FOUND'
def __init__(self, message): def __init__(self, message):
super().__init__(self, message) super().__init__(message)
self.message = message self.message = message
@ -77,7 +77,7 @@ class ServerError(RPCError):
message = 'INTERNAL' message = 'INTERNAL'
def __init__(self, message): def __init__(self, message):
super().__init__(self, message) super().__init__(message)
self.message = message self.message = message
@ -121,7 +121,7 @@ class BadMessageError(Exception):
} }
def __init__(self, code): def __init__(self, code):
super().__init__(self, self.ErrorMessages.get( super().__init__(self.ErrorMessages.get(
code, code,
'Unknown error code (this should not happen): {}.'.format(code))) 'Unknown error code (this should not happen): {}.'.format(code)))

View File

@ -68,7 +68,7 @@ def write_error(f, code, name, desc, capture_name):
f.write( f.write(
"self.{} = int(kwargs.get('capture', 0))\n ".format(capture_name) "self.{} = int(kwargs.get('capture', 0))\n ".format(capture_name)
) )
f.write('super(Exception, self).__init__(self, {}'.format(repr(desc))) f.write('super(Exception, self).__init__({}'.format(repr(desc)))
if capture_name: if capture_name:
f.write('.format(self.{})'.format(capture_name)) f.write('.format(self.{})'.format(capture_name))
f.write(')\n') f.write(')\n')