[tor-commits] [bridgedb/master] Replace zope implements with implementer
phw at torproject.org
phw at torproject.org
Wed Feb 19 18:26:37 UTC 2020
commit c86157c8ec59bc04de27f5262e928aaba341d37c
Author: Damian Johnson <atagar at torproject.org>
Date: Fri Jan 10 15:43:50 2020 -0800
Replace zope implements with implementer
Personally I've never used zope, but these exceptions seem pretty clear...
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/twisted/trial/runner.py", line 823, in loadByName
return self.suiteFactory([self.findByName(name, recurse=recurse)])
...
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distribute.py", line 163, in Distributor
implements(IDistribute)
File "/usr/local/lib/python3.5/dist-packages/zope/interface/declarations.py", line 483, in implements
raise TypeError(_ADVICE_ERROR % 'implementer')
builtins.TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead.
Test results changed as follows...
before: FAILED (skips=2, failures=7, errors=144, successes=321)
after: FAILED (skips=2, failures=7, errors=143, successes=324)
---
bridgedb/captcha.py | 4 ++--
bridgedb/distribute.py | 4 ++--
bridgedb/distributors/email/server.py | 8 ++++----
bridgedb/txrecaptcha.py | 4 ++--
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/bridgedb/captcha.py b/bridgedb/captcha.py
index 49cf838..b758c09 100644
--- a/bridgedb/captcha.py
+++ b/bridgedb/captcha.py
@@ -67,7 +67,7 @@ import urllib.request
from BeautifulSoup import BeautifulSoup
-from zope.interface import Interface, Attribute, implements
+from zope.interface import Interface, Attribute, implementer
from bridgedb import crypto
from bridgedb import schedule
@@ -101,6 +101,7 @@ class ICaptcha(Interface):
"""Retrieve a new CAPTCHA image."""
+ at implementer(ICaptcha)
class Captcha(object):
"""A generic CAPTCHA base class.
@@ -117,7 +118,6 @@ class Captcha(object):
:ivar secretKey: A private key used for decrypting challenge strings during
CAPTCHA solution verification.
"""
- implements(ICaptcha)
def __init__(self, publicKey=None, secretKey=None):
"""Obtain a new CAPTCHA for a client."""
diff --git a/bridgedb/distribute.py b/bridgedb/distribute.py
index ec8fb26..42706c9 100644
--- a/bridgedb/distribute.py
+++ b/bridgedb/distribute.py
@@ -108,7 +108,7 @@ import math
from zope import interface
from zope.interface import Attribute
-from zope.interface import implements
+from zope.interface import implementer
# from bridgedb.hashring import IHashring
from bridgedb.interfaces import IName
@@ -155,12 +155,12 @@ class IDistribute(IName):
"""Get bridges based on a client's **bridgeRequest**."""
+ at implementer(IDistribute)
class Distributor(Named):
"""A :class:`Distributor` distributes bridges to clients.
Inherit from me to create a new type of ``Distributor``.
"""
- implements(IDistribute)
_bridgesPerResponseMin = 1
_bridgesPerResponseMax = 3
diff --git a/bridgedb/distributors/email/server.py b/bridgedb/distributors/email/server.py
index 5a1ffc0..051ce74 100644
--- a/bridgedb/distributors/email/server.py
+++ b/bridgedb/distributors/email/server.py
@@ -62,7 +62,7 @@ from twisted.mail import smtp
from twisted.mail.smtp import rfc822date
from twisted.python import failure
-from zope.interface import implements
+from zope.interface import implementer
from bridgedb import __version__
from bridgedb import safelog
@@ -165,6 +165,7 @@ class MailServerContext(object):
return canon
+ at implementer(smtp.IMessage)
class SMTPMessage(object):
"""Plugs into the Twisted Mail and receives an incoming message.
@@ -186,7 +187,6 @@ class SMTPMessage(object):
:meth:`~bridgedb.distributors.email.autoresponder.SMTPAutoresponder.reply` email
and :meth:`~bridgedb.distributors.email.autoresponder.SMTPAutoresponder.send` it.
"""
- implements(smtp.IMessage)
def __init__(self, context, canonicalFromSMTP=None):
"""Create a new SMTPMessage.
@@ -258,6 +258,7 @@ class SMTPMessage(object):
return rfc822.Message(rawMessage)
+ at implementer(smtp.IMessageDelivery)
class SMTPIncomingDelivery(smtp.SMTP):
"""Plugs into :class:`SMTPIncomingServerFactory` and handles SMTP commands
for incoming connections.
@@ -272,7 +273,6 @@ class SMTPIncomingDelivery(smtp.SMTP):
:var fromCanonicalSMTP: If set, this is the canonicalized domain name of
the address we received from incoming connection's ``MAIL FROM:``.
"""
- implements(smtp.IMessageDelivery)
context = None
deferred = defer.Deferred()
@@ -395,6 +395,7 @@ class SMTPIncomingDelivery(smtp.SMTP):
return lambda: SMTPMessage(self.context, self.fromCanonicalSMTP)
+ at implementer(smtp.IMessageDeliveryFactory)
class SMTPIncomingDeliveryFactory(object):
"""Factory for :class:`SMTPIncomingDelivery` s.
@@ -408,7 +409,6 @@ class SMTPIncomingDeliveryFactory(object):
:var delivery: A :class:`SMTPIncomingDelivery` to deliver incoming
SMTP messages to.
"""
- implements(smtp.IMessageDeliveryFactory)
context = None
delivery = SMTPIncomingDelivery
diff --git a/bridgedb/txrecaptcha.py b/bridgedb/txrecaptcha.py
index fc4ca2f..885b40d 100644
--- a/bridgedb/txrecaptcha.py
+++ b/bridgedb/txrecaptcha.py
@@ -41,7 +41,7 @@ from twisted.web import client
from twisted.web.http_headers import Headers
from twisted.web.iweb import IBodyProducer
-from zope.interface import implements
+from zope.interface import implementer
from bridgedb.crypto import SSLVerifyingContextFactory
@@ -209,9 +209,9 @@ class RecaptchaResponseProtocol(protocol.Protocol):
self.finished.callback(result)
+ at implementer(IBodyProducer)
class _BodyProducer(object):
"""I write a string into the HTML body of an open request."""
- implements(IBodyProducer)
def __init__(self, body):
self.body = body
More information about the tor-commits
mailing list