#8431 enhancement closed duplicate (duplicate)

From zope.interface , change implements() to @implementer decorator in twisted/names

Reported by: Craig Rodrigues Owned by:
Priority: normal Milestone: Python-3.x
Component: names Keywords:
Cc: Branch:
Author:

Description

zope.interface.implements() was deprecated in Python 2.x, and raises a hard error in Python 3.x. I am choosing this example at random, but here is an example error:

Traceback (most recent call last):
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/twisted/trial/runner.py", line 784, in loadByName
    return self.suiteFactory([self.findByName(name, recurse=recurse)])
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/twisted/trial/runner.py", line 682, in findByName
    __import__(name)
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/twisted/words/test/test_xpath.py", line 7, in <module>
    from twisted.words.xish.domish import Element
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/twisted/words/xish/domish.py", line 287, in <module>
    class Element(object):
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/twisted/words/xish/domish.py", line 386, in Element
    implements(IElement)
  File "/Users/crodrigues/twisted3/build/py36-tests-posix/lib/python3.6/site-packages/zope/interface/declarations.py", line 412, in implements
    raise TypeError(_ADVICE_ERROR % 'implementer')
builtins.TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.

In the zope.interface 3.6 documentation, it mentions that the @implementer decorator can be used in Python 2.6 and up: https://pypi.python.org/pypi/zope.interface/3.6.0

Barry Warsaw also recommended using the @implementer decorator:

https://twistedmatrix.com/pipermail/twisted-python/2013-January/026414.html

Change History (3)

comment:2 Changed 19 months ago by Craig Rodrigues

Keywords: review added

comment:3 Changed 18 months ago by Adi Roiban

Keywords: review removed
Resolution: duplicate
Status: newclosed

I think that this change was already made as part of the full port in #8262

Note: See TracTickets for help on using tickets.