From 55bcc29ae0834e202a0040dd72c1116cb4a9f5c7 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Wed, 14 Feb 2018 17:09:22 +1000 Subject: [PATCH] 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. --- telethon/errors/common.py | 8 +++----- telethon/errors/rpc_base_errors.py | 8 ++++---- telethon_generator/error_generator.py | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/telethon/errors/common.py b/telethon/errors/common.py index 46b0b52e..0c03aee6 100644 --- a/telethon/errors/common.py +++ b/telethon/errors/common.py @@ -4,7 +4,7 @@ class ReadCancelledError(Exception): """Occurs when a read operation was cancelled.""" def __init__(self): - super().__init__(self, 'The read operation was cancelled.') + super().__init__('The read operation was cancelled.') class TypeNotFoundError(Exception): @@ -14,7 +14,7 @@ class TypeNotFoundError(Exception): """ def __init__(self, invalid_constructor_id): 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 ' 'was trying to be read when it should not be read.' .format(hex(invalid_constructor_id))) @@ -29,7 +29,6 @@ class InvalidChecksumError(Exception): """ def __init__(self, checksum, valid_checksum): super().__init__( - self, 'Invalid checksum ({} when {} was expected). ' 'This packet should be skipped.' .format(checksum, valid_checksum)) @@ -44,7 +43,6 @@ class BrokenAuthKeyError(Exception): """ def __init__(self): super().__init__( - self, 'The authorization key is broken, and it must be reset.' ) @@ -56,7 +54,7 @@ class SecurityError(Exception): def __init__(self, *args): if not args: args = ['A security check failed.'] - super().__init__(self, *args) + super().__init__(*args) class CdnFileTamperedError(SecurityError): diff --git a/telethon/errors/rpc_base_errors.py b/telethon/errors/rpc_base_errors.py index 9e6eed1a..467b256c 100644 --- a/telethon/errors/rpc_base_errors.py +++ b/telethon/errors/rpc_base_errors.py @@ -40,7 +40,7 @@ class ForbiddenError(RPCError): message = 'FORBIDDEN' def __init__(self, message): - super().__init__(self, message) + super().__init__(message) self.message = message @@ -52,7 +52,7 @@ class NotFoundError(RPCError): message = 'NOT_FOUND' def __init__(self, message): - super().__init__(self, message) + super().__init__(message) self.message = message @@ -77,7 +77,7 @@ class ServerError(RPCError): message = 'INTERNAL' def __init__(self, message): - super().__init__(self, message) + super().__init__(message) self.message = message @@ -121,7 +121,7 @@ class BadMessageError(Exception): } def __init__(self, code): - super().__init__(self, self.ErrorMessages.get( + super().__init__(self.ErrorMessages.get( code, 'Unknown error code (this should not happen): {}.'.format(code))) diff --git a/telethon_generator/error_generator.py b/telethon_generator/error_generator.py index a56d4b91..73fb5c5a 100644 --- a/telethon_generator/error_generator.py +++ b/telethon_generator/error_generator.py @@ -68,7 +68,7 @@ def write_error(f, code, name, desc, capture_name): f.write( "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: f.write('.format(self.{})'.format(capture_name)) f.write(')\n')