Repository: ipython/ipython

Issue:
TypeError: super() argument 1 must be type, not classobj (Python 2.6.6)
When starting the ipython notebook I get the following error

```
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj
Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj
```

strangely enough the notebook works and can be used, however nbconvert does not produce any output and cannot be used. The IPython terminal does not invoke this error.

Looks like it is related to LevelFormatter.

System info:
{'codename': 'An Afternoon Hack',
 'commit_hash': '02da31c',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython',
 'ipython_version': '1.0.0',
 'os_name': 'posix',
 'platform': 'Linux-2.6.32-358.2.1.el6.x86_64-x86_64-with-redhat-6.4-Carbon',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.6.6 (r266:84292, Feb 21 2013, 19:26:11) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]'}

Update: 
I forgot to mention that using a VM (Ubuntu 12.04) and Python 2.7.3 this error does not appear!



Discussion:
I believe classobj means an old style class. Super() only works with new
style classes.
On Aug 9, 2013 2:54 AM, "Jakob Gager" notifications@github.com wrote:

> When starting the ipython notebook I get the following error
> 
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/logging/**init**.py", line 776, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.6/logging/**init**.py", line 654, in format
>     return fmt.format(record)
>   File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
>     return super(LevelFormatter, self).format(record)
> TypeError: super() argument 1 must be type, not classobj
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/logging/**init**.py", line 776, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.6/logging/**init**.py", line 654, in format
>     return fmt.format(record)
>   File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
>     return super(LevelFormatter, self).format(record)
> TypeError: super() argument 1 must be type, not classobj
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/logging/**init**.py", line 776, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.6/logging/**init**.py", line 654, in format
>     return fmt.format(record)
>   File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
>     return super(LevelFormatter, self).format(record)
> TypeError: super() argument 1 must be type, not classobj
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/logging/**init**.py", line 776, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.6/logging/**init**.py", line 654, in format
>     return fmt.format(record)
>   File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
>     return super(LevelFormatter, self).format(record)
> TypeError: super() argument 1 must be type, not classobj
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/logging/**init**.py", line 776, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.6/logging/**init**.py", line 654, in format
>     return fmt.format(record)
>   File "/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython/config/application.py", line 119, in format
>     return super(LevelFormatter, self).format(record)
> TypeError: super() argument 1 must be type, not classobj
> 
> strangely enough the notebook works and can be used, however nbconvert
> does not produce any output and cannot be used. The IPython terminal does
> not invoke this error.
> 
> Looks like it is related to LevelFormatter.
> 
> System info:
> {'codename': 'An Afternoon Hack',
> 'commit_hash': '02da31c',
> 'commit_source': 'installation',
> 'default_encoding': 'UTF-8',
> 'ipython_path':
> '/usr2/gager/usr/lib/python2.6/site-packages/ipython-1.0.0-py2.6.egg/IPython',
> 'ipython_version': '1.0.0',
> 'os_name': 'posix',
> 'platform':
> 'Linux-2.6.32-358.2.1.el6.x86_64-x86_64-with-redhat-6.4-Carbon',
> 'sys_executable': '/usr/bin/python',
> 'sys_platform': 'linux2',
> 'sys_version': '2.6.6 (r266:84292, Feb 21 2013, 19:26:11) \n[GCC 4.4.7
> 20120313 (Red Hat 4.4.7-3)]'}
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/3968
> .


Resolving patch:
diff --git a/IPython/config/application.py b/IPython/config/application.py
--- a/IPython/config/application.py
+++ b/IPython/config/application.py
@@ -115,8 +115,10 @@ def format(self, record):
             record.highlevel = self.highlevel_format % record.__dict__
         else:
             record.highlevel = ""
-        
-        return super(LevelFormatter, self).format(record)
+        if sys.version_info[:2] > (2,6):
+            return super(LevelFormatter, self).format(record)
+        else:
+            return logging.Formatter.format(self, record)
             
 
 class Application(SingletonConfigurable):


Test patch:
diff --git a/IPython/config/tests/test_application.py b/IPython/config/tests/test_application.py
--- a/IPython/config/tests/test_application.py
+++ b/IPython/config/tests/test_application.py
@@ -18,8 +18,11 @@
 #-----------------------------------------------------------------------------
 
 import logging
+from io import StringIO
 from unittest import TestCase
 
+import nose.tools as nt
+
 from IPython.config.configurable import Configurable
 from IPython.config.loader import Config
 
@@ -80,6 +83,16 @@ def init_bar(self):
 
 class TestApplication(TestCase):
 
+    def test_log(self):
+        stream = StringIO()
+        app = MyApp(log_level=logging.INFO)
+        handler = logging.StreamHandler(stream)
+        # trigger reconstruction of the log formatter
+        app.log.handlers = [handler]
+        app.log_format = "%(message)s"
+        app.log.info("hello")
+        nt.assert_in("hello", stream.getvalue())
+
     def test_basic(self):
         app = MyApp()
         self.assertEqual(app.name, u'myapp')