twisted.python.log.PythonLoggingObserver is broken on Ubuntu 20.04

Bug #1961455 reported by Colin Watson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
twisted (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
New
Undecided
Unassigned

Bug Description

On up-to-date focal with python3-twisted 18.9.0-11ubuntu0.20.04.1, following https://twistedmatrix.com/documents/current/core/howto/logging.html#using-the-standard-library-logging-module:

  $ python3
  Python 3.8.10 (default, Nov 26 2021, 20:14:08)
  [GCC 9.3.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import logging
  >>> from twisted.python import log
  >>> logging.basicConfig(level=logging.INFO)
  >>> observer = log.PythonLoggingObserver()
  >>> observer.start()
  >>> log.msg('test')
  Temporarily disabling observer LegacyLogObserverWrapper(<bound method PythonLoggingObserver.emit of <twisted.python.log.PythonLoggingObserver object at 0x7f962dbc1130>>) due to exception: [Failure instance: Traceback: <class 'TypeError'>: _findCaller() takes from 1 to 2 positional arguments but 3 were given
  <stdin>:1:<module>
  /usr/lib/python3/dist-packages/twisted/python/threadable.py:53:sync
  /usr/lib/python3/dist-packages/twisted/python/log.py:286:msg
  /usr/lib/python3/dist-packages/twisted/logger/_legacy.py:154:publishToNewObserver
  --- <exception caught here> ---
  /usr/lib/python3/dist-packages/twisted/logger/_observer.py:131:__call__
  /usr/lib/python3/dist-packages/twisted/logger/_legacy.py:93:__call__
  /usr/lib/python3/dist-packages/twisted/python/log.py:595:emit
  /usr/lib/python3/dist-packages/twisted/logger/_legacy.py:154:publishToNewObserver
  /usr/lib/python3/dist-packages/twisted/logger/_stdlib.py:115:__call__
  /usr/lib/python3.8/logging/__init__.py:1512:log
  /usr/lib/python3.8/logging/__init__.py:1577:_log
  ]
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>

    File "/usr/lib/python3/dist-packages/twisted/python/threadable.py", line 53, in sync
      return function(self, *args, **kwargs)
    File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 286, in msg
      _publishNew(self._publishPublisher, actualEventDict, textFromEventDict)
    File "/usr/lib/python3/dist-packages/twisted/logger/_legacy.py", line 154, in publishToNewObserver
      observer(eventDict)
  --- <exception caught here> ---
    File "/usr/lib/python3/dist-packages/twisted/logger/_observer.py", line 131, in __call__
      observer(event)
    File "/usr/lib/python3/dist-packages/twisted/logger/_legacy.py", line 93, in __call__
      self.legacyObserver(event)
    File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 595, in emit
      _publishNew(self._newObserver, eventDict, textFromEventDict)
    File "/usr/lib/python3/dist-packages/twisted/logger/_legacy.py", line 154, in publishToNewObserver
      observer(eventDict)
    File "/usr/lib/python3/dist-packages/twisted/logger/_stdlib.py", line 115, in __call__
      self.logger.log(
    File "/usr/lib/python3.8/logging/__init__.py", line 1512, in log
      self._log(level, msg, args, **kwargs)
    File "/usr/lib/python3.8/logging/__init__.py", line 1577, in _log
      fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
  builtins.TypeError: _findCaller() takes from 1 to 2 positional arguments but 3 were given

This is https://twistedmatrix.com/trac/ticket/9668; the fix should be a trivial backport.

This caused test failures in launchpad-buildd on focal (though I may look for a workaround).

Colin Watson (cjwatson)
Changed in twisted (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.