Commit e2799435 authored by Vincent A's avatar Vincent A Committed by Romain Bignon

Really fix super-constructor call for ReplApplication

In Python2, Cmd did not inherit object, so it appeared after object in
ReplApplication.mro(), so its __init__ was never called if only super()
was used.
parent 28571c26
......@@ -142,6 +142,7 @@ class Application(object):
# ------ Application methods -------------------------------
def __init__(self, option_parser=None):
super(Application, self).__init__()
self.encoding = self.guess_encoding()
self.logger = getLogger(self.APPNAME)
self.weboob = self.create_weboob()
......@@ -94,7 +94,7 @@ class ConsoleApplication(Application):
NC = '' # no color
def __init__(self, option_parser=None):
Application.__init__(self, option_parser)
super(ConsoleApplication, self).__init__(option_parser)
self.weboob.requests.register('login', self.login_cb)
self.enabled_backends = set()
......@@ -27,7 +27,6 @@ import re
from optparse import OptionGroup, OptionParser, IndentedHelpFormatter
from datetime import datetime
import os
import sys
from weboob.capabilities.base import FieldNotFound, BaseObject, UserError
from weboob.core import CallErrors
......@@ -93,7 +92,12 @@ def defaultcount(default_count=10):
return deco
class ReplApplication(Cmd, ConsoleApplication):
class MyCmd(Cmd, object):
# Hack for Python 2, because Cmd doesn't inherit object, so its __init__ was not called when using super only
class ReplApplication(ConsoleApplication, MyCmd):
Base application class for Repl applications.
......@@ -113,8 +117,7 @@ class ReplApplication(Cmd, ConsoleApplication):
hidden_commands = set(['EOF'])
def __init__(self):
ConsoleApplication.__init__(self, ReplOptionParser(self.SYNOPSIS, version=self._get_optparse_version()))
super(ReplApplication, self).__init__(ReplOptionParser(self.SYNOPSIS, version=self._get_optparse_version()))
copyright = self.COPYRIGHT.replace('YEAR', '%d' %
self.intro = '\n'.join(('Welcome to %s%s%s v%s' % (self.BOLD, self.APPNAME, self.NC, self.VERSION),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment