DeprecationWarning: object.__init__() takes no parameters

Bug #356281 reported by Florent
36
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Python Dbus
Fix Released
Medium
dbus-python (Ubuntu)
Fix Released
Undecided
Unassigned
Jaunty
Won't Fix
Undecided
Unassigned

Bug Description

From ~/.xsession-errors:

/var/lib/python-support/python2.6/dbus/connection.py:242: DeprecationWarning: object.__init__() takes no parameters
  super(Connection, self).__init__(*args, **kwargs)

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: ath_hal
Package: python-dbus 0.83.0-1ubuntu1
ProcEnviron:
 LANG=fr_FR.UTF-8
 SHELL=/bin/bash
SourcePackage: dbus-python
Uname: Linux 2.6.28-11-generic i686

Related branches

Revision history for this message
Florent (florent.x) wrote :
Revision history for this message
dobey (dobey) wrote :

This occurs a LOT in Jaunty. The attached patch removes the unneeded line that causes these warnings. Can we please get this in a package for 9.04?

Revision history for this message
In , dobey (dobey) wrote :

Created an attachment (id=24788)
Patch to fix DeprecationWarning for object __init__

In Python 2.6 object's __init__ no longer ignores extra parameters and emits the following warning, whenever the Connection class is instantiated in Python.

DeprecationWarning: object.__init__() takes no parameters

The attached patch fixes this.

Revision history for this message
Martin Pitt (pitti) wrote :

Please report this upstream and link the upstream bug here.

Revision history for this message
Martin Pitt (pitti) wrote :

How can this be reproduced? I tested jockey (which uses dbus-python), and neither that nor my .xsession-errors brings up this error message.

Revision history for this message
Florent (florent.x) wrote :

I launch the update-manager... Then hit "Check".
It happens again.

Changed in dbus-python (Ubuntu):
status: New → Confirmed
Changed in python-dbus:
status: Unknown → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Not release critical, and too late for jaunty final, but this is fine for an SRU.

Revision history for this message
dobey (dobey) wrote :

Do I need to do anything else to get this in an SRU? Would like to get this one out in the wild. :)

Revision history for this message
Martin Olsson (mnemo) wrote :

Are you sure you can drop the call to super entirely versus calling it but not passing any params? Just double checking...

To continue with the fix I suggest get it into karmic first (nice for testing/feedback).
Start with preparing a debdiff:
https://wiki.ubuntu.com/PackagingGuide/Recipes/Debdiff

For SRU you need to do extremely thorough testing. Start here:
https://wiki.ubuntu.com/StableReleaseUpdates

Revision history for this message
Martin Pitt (pitti) wrote :

Setting to incomplete until Rodney answers the question in comment 8 (which seems weird to me as well).

Changed in dbus-python (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
dobey (dobey) wrote :

I have been using a modified python-dbus with my change since subscribing to this bug, with no adverse affects. Calling without arguments might be fine too. Either way is fine with me so long as it doesn't break stuff, and gets rid of the warnings. :)

Revision history for this message
Martin Pitt (pitti) wrote :

Thinking about it again, it makes sense. I'll sponsor this.

Changed in dbus-python (Ubuntu):
status: Incomplete → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

This does not match the SRU criteria.

Changed in dbus-python (Ubuntu Jaunty):
status: Confirmed → Won't Fix
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dbus-python - 0.83.0-1ubuntu2

---------------
dbus-python (0.83.0-1ubuntu2) karmic; urgency=low

  * Add deprecation-warning.patch: Fix deprecation warning with Python 2.6,
    thanks to Rodney Dawes for the patch! (LP: #356281)

 -- Martin Pitt <email address hidden> Wed, 06 May 2009 10:12:39 +0200

Changed in dbus-python (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
dobey (dobey) wrote :

That was a quick change of opinion. Is there no way we can get the fix backported to jaunty? It's rather annoying.

Revision history for this message
Martin Pitt (pitti) wrote :

Annoying> Really? How does a normal user see this? If it's affecting users, can you please change the description to point out the impact? (xsession-errors log spam is hardly sufficient)

Thank you!

Revision history for this message
dobey (dobey) wrote : Re: [Bug 356281] Re: DeprecationWarning: object.__init__() takes no parameters

Anyone writing python code using dbus, and wanting to test their dbus
interfaces in unit tests will find this annoying, as it will spew
several copies of this warning during unit tests. As python-dbus isn't
the only module that causes a DeprecationWarning, these can become quite
annoying if you're using several of these modules in the same code base.

On Mon, 2009-05-11 at 06:15 +0000, Martin Pitt wrote:
> Annoying> Really? How does a normal user see this? If it's affecting
> users, can you please change the description to point out the impact?
> (xsession-errors log spam is hardly sufficient)
>
> Thank you!
>

Revision history for this message
In , Simon McVittie (smcv) wrote :

*** Bug 22955 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Simon McVittie (smcv) wrote :

I don't think that's the right patch for this, but I've prepared another:

http://git.collabora.co.uk/?p=user/smcv/dbus-python-smcv.git;a=shortlog;h=refs/heads/2.6

Revision history for this message
In , David-laban (david-laban) wrote :

(In reply to comment #2)
> I don't think that's the right patch for this, but I've prepared another:
>
> http://git.collabora.co.uk/?p=user/smcv/dbus-python-smcv.git;a=shortlog;h=refs/heads/2.6
>

I'm probably not the best person to be reviewing this, but...

The "Passing arbitrary args into an __init__ and getting them silently ignored" thing deprecated in 2.6 for a reason. If we at least warn about args/kwargs we don't understand then ++. I don't know the codebase enough to be able to quickly assert whether we do or not. If someone more knowledgeable than me can assert this then ship it.

If we don't warn about unknown args, then on a scale of "completely fine" to "as messed up as overriding __getattr__" I would give this a 5.

Revision history for this message
In , Peng Huang (shawn-p-huang) wrote :

I am thinking maybe the server.c or Server.py has the same problem.

Revision history for this message
In , Simon McVittie (smcv) wrote :

Following discussion on IRC:

(In reply to comment #3)
> If we at least warn about args/kwargs we
> don't understand then ++.

These are an error in __new__; as such, __init__ doesn't need to check them again.

Revision history for this message
In , Simon McVittie (smcv) wrote :

(In reply to comment #4)
> I am thinking maybe the server.c or Server.py has the same problem.

Good thinking, but actually no: Server.__init__ doesn't chain up to _Server's tp_init (and hence object.__init__).

However, Server use will provoke the same warning whenever a Server instantiates a Connection (is that what you meant?)

Revision history for this message
In , Peng Huang (shawn-p-huang) wrote :

(In reply to comment #6)
> (In reply to comment #4)
> > I am thinking maybe the server.c or Server.py has the same problem.
>
> Good thinking, but actually no: Server.__init__ doesn't chain up to _Server's
> tp_init (and hence object.__init__).
>
> However, Server use will provoke the same warning whenever a Server
> instantiates a Connection (is that what you meant?)
>

In commnet #2, you don't think removing __init__ in connection.py is a right solution, but the Server.py does not call __init__ too, and it avoids the same problem. I mean maybe it is better to avoid the same problem by same solution.

Revision history for this message
In , Simon McVittie (smcv) wrote :

Fixed in 0.83.1

Changed in python-dbus:
status: Confirmed → Fix Released
Changed in python-dbus:
importance: Unknown → Medium
Changed in python-dbus:
importance: Medium → Unknown
Changed in python-dbus:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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