tcalmant / ipopo

iPOPO: a Service-Oriented Component Model for Python
https://ipopo.readthedocs.io/
Apache License 2.0
69 stars 28 forks source link

Extending component creates warning with python 2.7 #52

Closed gattazr closed 8 years ago

gattazr commented 8 years ago

When a module containing a component extending another component in another module is installed, warnings are raised on the redefinition of the functions annoted with @Validate and @Invalidate.

$ python -m pelix.shell
** Pelix Shell prompt **
$ install pelix.shell.tlsremote
WARNING:ipopo.decorators:Redefining the callback INVALIDATE in class 'IPopoTLSRemoteShell'.
    Previous callback : 'invalidate' (pelix/shell/remote.py:337)
    New callback : 'invalidate' (pelix/shell/remote.py:337)
WARNING:ipopo.decorators:Redefining the callback VALIDATE in class 'IPopoTLSRemoteShell'.
    Previous callback : 'validate' (pelix/shell/remote.py:311)
    New callback : 'validate' (pelix/shell/remote.py:311)
Bundle ID: 11

I have access to both python2 and python3 on my system. The warnings however only appears when I start the IPOPO shell with python2.

$ python --version
Python 2.7.10
$ python3 --version
Python 3.4.3

The module pelix.shell.tlsremote I am using in the example is available here.

tcalmant commented 8 years ago

This issue won't be fixed, as it is harmless and due to the way methods declaration works in Python 2.

In Python 3, methods can be compared using the "is" operator: if a class A inherits a method from another class B, the comparison A.foo is B.foo will return True. In Python 2, this check will return False.

We can't use the == operator, as the A.foo == B.foo will return True even if A overrides B.foo.