Strictly enforce instance attrs in critical functional test classes.

Additionally, removed redundant parentheses and added PEP-8 compliant
spacing around those classes.
This commit is contained in:
Justin Turner Arthur
2018-09-23 21:34:42 -05:00
parent 1d0ce94a54
commit 3a4449e9ad
2 changed files with 138 additions and 44 deletions

View File

@@ -26,7 +26,7 @@ def hash160(s):
_opcode_instances = []
class CScriptOp(int):
"""A single script opcode"""
__slots__ = []
__slots__ = ()
@staticmethod
def encode_op_pushdata(d):
@@ -361,8 +361,11 @@ class CScriptTruncatedPushDataError(CScriptInvalidError):
self.data = data
super(CScriptTruncatedPushDataError, self).__init__(msg)
# This is used, eg, for blockchain heights in coinbase scripts (bip34)
class CScriptNum():
class CScriptNum:
__slots__ = ("value",)
def __init__(self, d=0):
self.value = d
@@ -393,6 +396,8 @@ class CScript(bytes):
iter(script) however does iterate by opcode.
"""
__slots__ = ()
@classmethod
def __coerce_instance(cls, other):
# Coerce other into bytes