Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: super() argument 1 must be type, not classobj #2

Closed
rob-b opened this issue Sep 19, 2012 · 2 comments
Closed

TypeError: super() argument 1 must be type, not classobj #2

rob-b opened this issue Sep 19, 2012 · 2 comments
Assignees

Comments

@rob-b
Copy link

rob-b commented Sep 19, 2012

Because logging.Formatter is an old style class (on py26 at least) calling super(Formatter)[1] doesn't work.

  1. https://github.com/rspivak/logsna/blob/master/logsna/__init__.py#L36
@rob-b
Copy link
Author

rob-b commented Sep 19, 2012

--- original.py   2012-09-19 16:05:14.000000000 +0100
+++ __init__.py 2012-09-19 16:02:04.000000000 +0100
@@ -33,14 +33,14 @@
 class Formatter(logging.Formatter):

     def __init__(self, fmt=None, datefmt=None):
-        super(Formatter, self).__init__(fmt or _DEFAULT_FMT, datefmt)
+        logging.Formatter.__init__(self, fmt or _DEFAULT_FMT, datefmt)
         # A user-configurable function to convert the creation time to a tuple.
         # It's used by Format.formatTime method and default is time.localtime()
         # We set it to convert time to a struct_time in UTC
         self.converter = time.gmtime

     def formatException(self, exc_info):
-        text = super(Formatter, self).formatException(exc_info)
+        text = logging.Formatter.formatException(self, exc_info)
         # Prepend ! mark to every line
         text = '\n'.join(('! %s' % line) for line in text.splitlines())
         return text

The above patch makes logsna.Formatter work in python2.6

@ghost ghost assigned rspivak Oct 2, 2012
@rspivak
Copy link
Owner

rspivak commented Oct 2, 2012

Thanks a lot. I've added the code and released a new version of logsna 1.2

@rspivak rspivak closed this as completed Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants