Failing to import module breaks logging configurability and adds noise

Bug #1333512 reported by Christopher Lee
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pygobject
Fix Released
Medium
pygobject (Ubuntu)
Fix Released
Low
Martin Pitt
Trusty
Fix Released
Undecided
Unassigned
Utopic
Fix Released
Low
Martin Pitt

Bug Description

When failing to import a module the gi.repository import.py module logs an error with `logging.error(..)` causing a logging handler to be added.
This basically breaks the ability to configure the logging as it happens so early (i.e. at the import stage before an authors code is executed).

To reproduce/Example:

Run this script: http://pastebin.ubuntu.com/7698632/

Expected outcome:
No output to stdout or stderr and the text "log message" in the file "/tmp/example.log

Actual outcome:
No log file, and this text output to stderr:
  ERROR:root:Could not find any typelib for rubbish
  ERROR:root:log message

Upstream fix: https://git.gnome.org/browse/pygobject/commit/?id=ac8b59e

Regression potential:
- The behaviour of raising ImportError on a nonexisting name does not change, but its text changes.
  Old: ImportError: cannot import name 'foo'
  New: ImportError: cannot import name foo, introspection typelib not found

  It's unlikely, however theoretically possible that a program matches on the precise error message.

- It's theoretically possible that a program watches for the logged error message and ignores the ImportError. However, that would be extremely bad design, un-Pythonic and brittle as the logging format/destination can be changed arbitrarily.

In summary the regression potential is very low.

Ubuntu Version:
Description: Ubuntu 14.04 LTS
Release: 14.04

Package Version:
python3-gi 3.12.0-1

description: updated
Martin Pitt (pitti)
description: updated
description: updated
Changed in pygobject (Ubuntu Utopic):
assignee: nobody → Martin Pitt (pitti)
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

The upstream fix indeed removes the "ERROR:root:Could not find any typelib for rubbish". But I can't reproduce the logging level change to INFO, i. e. I never see the "INFO:something-not-root:You shouldn't see this". I tried with python 2 and 3 on trusty and utopic.

Changed in pygobject (Ubuntu Trusty):
status: New → Incomplete
Revision history for this message
Martin Pitt (pitti) wrote :

The "ERROR" log is removed upstream with the fix, so I'll upload 3.13.3 to utopic (which we want anyway).

Changed in pygobject (Ubuntu Utopic):
status: In Progress → Fix Committed
importance: Undecided → Low
Changed in pygobject:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygobject - 3.13.3-0ubuntu1

---------------
pygobject (3.13.3-0ubuntu1) utopic; urgency=medium

  * New upstream release:
    - Fixes logging on import errors. (LP: #1333512)
  * debian/control.in: Bump g-i dependencies to >= 1.39 according to upstream
    configure.ac.
  * Adjust 01_cairo_region.patch to new upstream version.
 -- Martin Pitt <email address hidden> Tue, 24 Jun 2014 06:38:21 +0200

Changed in pygobject (Ubuntu Utopic):
status: Fix Committed → Fix Released
description: updated
Martin Pitt (pitti)
Changed in pygobject (Ubuntu Trusty):
status: Incomplete → Triaged
Martin Pitt (pitti)
summary: - Failing to import module adds noise to the logging stream
+ Failing to import module breaks logging configurability and adds noise
Revision history for this message
Martin Pitt (pitti) wrote :

Trusty fix uploaded to SRU review queue.

description: updated
Changed in pygobject (Ubuntu Trusty):
status: Triaged → In Progress
Revision history for this message
Adam Conrad (adconrad) wrote : Please test proposed package

Hello Christopher, or anyone else affected,

Accepted pygobject into trusty-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/pygobject/3.12.0-1ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in pygobject (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Christopher Lee (veebers) wrote :

Hi Adam, sorry for the delay.

Installing python3-gi (and python3-gi-cairo) version 3.12.0-1ubuntu1 fixed the issue for me.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygobject - 3.12.0-1ubuntu1

---------------
pygobject (3.12.0-1ubuntu1) trusty-proposed; urgency=medium

  * Add 00upstream-importerror-logging.patch: Raise ImportError when importing
    modules not found in repository, instead of logging to stderr. The former
    matches the behaviour of "import" in general, and the latter breaks the
    possibility of configuring "logging" in your program, as any call to
    basicConfig() would happen after the import statements. (LP: #1333512)
 -- Martin Pitt <email address hidden> Wed, 25 Jun 2014 08:14:43 +0200

Changed in pygobject (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for pygobject has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.