Skip to content

Commit

Permalink
Merge pull request #86 from zopefoundation/only-new-style
Browse files Browse the repository at this point in the history
Make all classes new-style. This is especially good for PyPy
  • Loading branch information
Jim Fulton authored Apr 17, 2017
2 parents 0218f62 + db54799 commit a4af74b
Show file tree
Hide file tree
Showing 32 changed files with 69 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ matrix:
include:
- os: linux
python: 2.7
- os: linux
python: pypy-5.4.1
- os: linux
python: 3.4
- os: linux
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
5.1.1 (unreleased)
------------------

- Nothing changed yet.
- All classes are new-style classes on Python 2 (they were already
new-style on Python 3). This improves performance on PyPy. See
`issue 86 <<https://github.com/zopefoundation/ZEO/pull/86>`_.


5.1.0 (2017-04-03)
Expand Down
12 changes: 6 additions & 6 deletions src/ZEO/StorageServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class StorageServerError(StorageError):
'iterator_next', 'iterator_record_start', 'iterator_record_next',
'iterator_gc', 'server_status', 'set_client_label', 'ping'))

class ZEOStorage:
class ZEOStorage(object):
"""Proxy to underlying storage for a single remote client."""

connected = connection = stats = storage = storage_id = transaction = None
Expand Down Expand Up @@ -616,7 +616,7 @@ def ruok(self):
def ping(self):
pass

class StorageServerDB:
class StorageServerDB(object):
"""Adapter from StorageServerDB to ZODB.interfaces.IStorageWrapper
This is used in a ZEO fan-out situation, where a storage server
Expand All @@ -642,7 +642,7 @@ def invalidateCache(self):

transform_record_data = untransform_record_data = lambda self, data: data

class StorageServer:
class StorageServer(object):

"""The server side implementation of ZEO.
Expand Down Expand Up @@ -952,7 +952,7 @@ def ruok(self):
return dict((storage_id, self.server_status(storage_id))
for storage_id in self.storages)

class StubTimeoutThread:
class StubTimeoutThread(object):

def begin(self, client):
pass
Expand Down Expand Up @@ -1067,7 +1067,7 @@ def _addr_label(addr):
host, port = addr
return str(host) + ":" + str(port)

class CommitLog:
class CommitLog(object):

def __init__(self):
self.file = tempfile.TemporaryFile(suffix=".comit-log")
Expand Down Expand Up @@ -1109,7 +1109,7 @@ def close(self):
self.file.close()
self.file = None

class ServerEvent:
class ServerEvent(object):

def __init__(self, server, **kw):
self.__dict__.update(kw)
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/TransactionBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from ZEO._compat import Pickler, Unpickler

class TransactionBuffer:
class TransactionBuffer(object):

# The TransactionBuffer is used by client storage to hold update
# data until the tpc_finish(). It is only used by a single
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if zeo_dist is not None:
zeo_version = zeo_dist.version

class StorageStats:
class StorageStats(object):
"""Per-storage usage statistics."""

def __init__(self, connections=None):
Expand Down
6 changes: 3 additions & 3 deletions src/ZEO/runzeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def windows_shutdown_handler():
import asyncore
asyncore.close_all()

class ZEOOptionsMixin:
class ZEOOptionsMixin(object):

storages = None

Expand All @@ -72,7 +72,7 @@ def handle_address(self, arg):

def handle_filename(self, arg):
from ZODB.config import FileStorage # That's a FileStorage *opener*!
class FSConfig:
class FSConfig(object):
def __init__(self, name, path):
self._name = name
self.path = path
Expand Down Expand Up @@ -138,7 +138,7 @@ def realize(self, *a, **k):
break


class ZEOServer:
class ZEOServer(object):

def __init__(self, options):
self.options = options
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/scripts/parsezeolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_line(line):
m = meth_name, tuple(meth_args)
return t, m

class TStats:
class TStats(object):

counter = 1

Expand All @@ -73,7 +73,7 @@ def report(self):
print(self.fmt % (time.ctime(self.begin), d_vote, d_finish,
self.user, self.url))

class TransactionParser:
class TransactionParser(object):

def __init__(self):
self.txns = {}
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/scripts/zeoqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def parse_time(line):
return int(time.mktime(date_l + time_l + [0, 0, 0]))


class Txn:
class Txn(object):
"""Track status of single transaction."""
def __init__(self, tid):
self.tid = tid
Expand All @@ -98,7 +98,7 @@ def isactive(self):



class Status:
class Status(object):
"""Track status of ZEO server by replaying log records.
We want to keep track of several events:
Expand Down
6 changes: 3 additions & 3 deletions src/ZEO/scripts/zeoreplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def parse_line(line):



class StoreStat:
class StoreStat(object):
def __init__(self, when, oid, size):
self.when = when
self.oid = oid
Expand All @@ -109,7 +109,7 @@ def __getitem__(self, i):
raise IndexError


class TxnStat:
class TxnStat(object):
def __init__(self):
self._begintime = None
self._finishtime = None
Expand Down Expand Up @@ -173,7 +173,7 @@ def replay(self):



class ZEOParser:
class ZEOParser(object):
def __init__(self, maxtxns=-1, report=1, storage=None):
self.__txns = []
self.__curtxn = {}
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/Cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle

class TransUndoStorageWithCache:
class TransUndoStorageWithCache(object):

def checkUndoInvalidation(self):
oid = self._storage.new_oid()
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/tests/CommitLockTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

ZERO = b'\0'*8

class DummyDB:
class DummyDB(object):
def invalidate(self, *args, **kwargs):
pass

Expand Down Expand Up @@ -68,7 +68,7 @@ def myvote(self):
self.ready.set()
future.result(9)

class CommitLockTests:
class CommitLockTests(object):

NUM_CLIENTS = 5

Expand Down
6 changes: 3 additions & 3 deletions src/ZEO/tests/ConnectionTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def notify_connected(self, conn, info):
self.connection_count_for_tests += 1
self.verify_result = conn.verify_result

class DummyDB:
class DummyDB(object):
def invalidate(self, *args, **kwargs):
pass

Expand Down Expand Up @@ -416,7 +416,7 @@ def checkBadMessage1(self):
def checkBadMessage2(self):
# just like a real message, but with an unpicklable argument
global Hack
class Hack:
class Hack(object):
pass

msg = encode(1, 0, "foo", (Hack(),))
Expand Down Expand Up @@ -1106,7 +1106,7 @@ def short_timeout(self):
except (socket.error, AttributeError):
pass
else:
class V6Setup:
class V6Setup(object):
def _getAddr(self):
return '::1', forker.get_port(self)

Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/tests/InvalidationTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def testrun(self):
raise


class StressTask:
class StressTask(object):
# Append integers startnum, startnum + step, startnum + 2*step, ...
# to 'tree'. If sleep is given, sleep
# that long after each append. At the end, instance var .added_keys
Expand Down Expand Up @@ -234,7 +234,7 @@ def _testrun(self):
self.added_keys = keys_added.keys()
cn.close()

class InvalidationTests:
class InvalidationTests(object):

# Minimum # of seconds the main thread lets the workers run. The
# test stops as soon as this much time has elapsed, and all threads
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/IterationTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from ..asyncio.testing import AsyncRPC

class IterationTests:
class IterationTests(object):

def _assertIteratorIdsEmpty(self):
# Account for the need to run a GC collection
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/ThreadTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def run(self):
self.gotValueError = 1


class ThreadTests:
class ThreadTests(object):
# Thread 1 should start a transaction, but not get all the way through it.
# Main thread should close the connection. Thread 1 should then get
# disconnected.
Expand Down
16 changes: 8 additions & 8 deletions src/ZEO/tests/ZEO4/StorageServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class StorageServerError(StorageError):
"""Error reported when an unpicklable exception is raised."""


class ZEOStorage:
class ZEOStorage(object):
"""Proxy to underlying storage for a single remote client."""

# A list of extension methods. A subclass with extra methods
Expand Down Expand Up @@ -758,7 +758,7 @@ def server_status(self):
def set_client_label(self, label):
self.log_label = str(label)+' '+_addr_label(self.connection.addr)

class StorageServerDB:
class StorageServerDB(object):

def __init__(self, server, storage_id):
self.server = server
Expand All @@ -776,7 +776,7 @@ def invalidateCache(self):

transform_record_data = untransform_record_data = lambda self, data: data

class StorageServer:
class StorageServer(object):

"""The server side implementation of ZEO.
Expand Down Expand Up @@ -1328,7 +1328,7 @@ def _level_for_waiting(waiting):
else:
return logging.DEBUG

class StubTimeoutThread:
class StubTimeoutThread(object):

def begin(self, client):
pass
Expand Down Expand Up @@ -1434,7 +1434,7 @@ def run(self):
self.delay.reply(result)


class ClientStub:
class ClientStub(object):

def __init__(self, rpc):
self.rpc = rpc
Expand Down Expand Up @@ -1494,7 +1494,7 @@ def invalidateTransaction(self, tid, args):
def invalidateVerify(self, oid):
ClientStub.invalidateVerify(self, (oid, ''))

class ZEOStorage308Adapter:
class ZEOStorage308Adapter(object):

def __init__(self, storage):
self.storage = storage
Expand Down Expand Up @@ -1582,7 +1582,7 @@ def _addr_label(addr):
host, port = addr
return str(host) + ":" + str(port)

class CommitLog:
class CommitLog(object):

def __init__(self):
self.file = tempfile.TemporaryFile(suffix=".comit-log")
Expand Down Expand Up @@ -1624,7 +1624,7 @@ def close(self):
self.file.close()
self.file = None

class ServerEvent:
class ServerEvent(object):

def __init__(self, server, **kw):
self.__dict__.update(kw)
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/tests/ZEO4/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import os
from ..hash import sha1

class Client:
class Client(object):
# Subclass should override to list the names of methods that
# will be called on the server.
extensions = []
Expand All @@ -37,7 +37,7 @@ def sort(L):
L.sort()
return L

class Database:
class Database(object):
"""Abstracts a password database.
This class is used both in the authentication process (via
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/ZEO4/auth/hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _strxor(s1, s2):
# hashing module used.
digest_size = None

class HMAC:
class HMAC(object):
"""RFC2104 HMAC class.
This supports the API for Cryptographic Hash Functions (PEP 247).
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/ZEO4/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if zeo_dist is not None:
zeo_version = zeo_dist.version

class StorageStats:
class StorageStats(object):
"""Per-storage usage statistics."""

def __init__(self, connections=None):
Expand Down
Loading

0 comments on commit a4af74b

Please sign in to comment.