summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArie Bovenberg <a.c.bovenberg@gmail.com>2022-01-22 10:10:11 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2022-03-13 12:05:41 +0100
commit3b31182ed21415503e1950dff2be998e9852382b (patch)
tree1636194755b01fe86c4904f900ddaa1aa8e3eb6e
parent6391b1a03682c3493ea69c5a9698277ba9d53a9c (diff)
downloadrsa-git-3b31182ed21415503e1950dff2be998e9852382b.tar.gz
Remove overlapping slots from AbstractKey subclasses
`PublicKey` and `PrivateKey` both define the `n` and `e` slots, which are already present in their base class. This reduces the benefits of having slots. ```shell $ slotscheck -m rsa -v ERROR: 'rsa.key:PrivateKey' defines overlapping slots. - e (rsa.key:AbstractKey) - n (rsa.key:AbstractKey) ERROR: 'rsa.key:PublicKey' defines overlapping slots. - e (rsa.key:AbstractKey) - n (rsa.key:AbstractKey) ``` The Python docs say: > If a class defines a slot also defined in a base class, the instance > variable defined by the base class slot is inaccessible (except by > retrieving its descriptor directly from the base class). This renders > the meaning of the program undefined.
-rw-r--r--rsa/key.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/rsa/key.py b/rsa/key.py
index d4feb42..f800644 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -239,7 +239,7 @@ class PublicKey(AbstractKey):
"""
- __slots__ = ("n", "e")
+ __slots__ = ()
def __getitem__(self, key: str) -> int:
return getattr(self, key)
@@ -404,7 +404,7 @@ class PrivateKey(AbstractKey):
"""
- __slots__ = ("n", "e", "d", "p", "q", "exp1", "exp2", "coef")
+ __slots__ = ("d", "p", "q", "exp1", "exp2", "coef")
def __init__(self, n: int, e: int, d: int, p: int, q: int) -> None:
AbstractKey.__init__(self, n, e)