aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJán Jančár2022-03-01 12:45:24 +0100
committerGitHub2022-03-01 12:45:24 +0100
commit577df62aab9785c248a3a6b01d4f94b7370e5ea2 (patch)
treea89ab63e6a3ddc15c86257ddfd1d2681fa72539b
parent0f5f050dc79f9bf29a983c689a8461cb15a7cfcf (diff)
parentec22e0ce6704a4ed06939960583808866ae91a50 (diff)
downloadpyecsca-577df62aab9785c248a3a6b01d4f94b7370e5ea2.tar.gz
pyecsca-577df62aab9785c248a3a6b01d4f94b7370e5ea2.tar.zst
pyecsca-577df62aab9785c248a3a6b01d4f94b7370e5ea2.zip
Merge pull request #17 from J08nY/deepsource-fix-325158fb
Return `NotImplemented` instead of raising `NotImplementedError`
-rw-r--r--pyecsca/ec/mod.py28
-rw-r--r--test/ec/test_mod.py7
2 files changed, 19 insertions, 16 deletions
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py
index 68007dd..47bf2b3 100644
--- a/pyecsca/ec/mod.py
+++ b/pyecsca/ec/mod.py
@@ -251,7 +251,7 @@ class Mod:
return action.exit(cls(secrets.randbelow(n), n))
def __pow__(self, n) -> "Mod":
- raise NotImplementedError
+ return NotImplemented
def __str__(self):
return str(self.x)
@@ -376,16 +376,16 @@ class Undefined(Mod):
self.n = None
def __add__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __radd__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __sub__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __rsub__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __neg__(self):
raise NotImplementedError
@@ -403,25 +403,25 @@ class Undefined(Mod):
raise NotImplementedError
def __mul__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __rmul__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __truediv__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __rtruediv__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __floordiv__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __rfloordiv__(self, other):
- raise NotImplementedError
+ return NotImplemented
def __divmod__(self, divisor):
- raise NotImplementedError
+ return NotImplemented
def __bytes__(self):
raise NotImplementedError
@@ -442,7 +442,7 @@ class Undefined(Mod):
return hash("Undefined") + 1
def __pow__(self, n):
- raise NotImplementedError
+ return NotImplemented
@lru_cache
@@ -536,7 +536,7 @@ class SymbolicMod(Mod):
return ~self * other
def __divmod__(self, divisor) -> "SymbolicMod":
- raise NotImplementedError
+ return NotImplemented
def __bytes__(self):
return int(self.x).to_bytes((self.n.bit_length() + 7) // 8, byteorder="big")
diff --git a/test/ec/test_mod.py b/test/ec/test_mod.py
index cac9be4..7802e95 100644
--- a/test/ec/test_mod.py
+++ b/test/ec/test_mod.py
@@ -184,8 +184,11 @@ class ModTests(TestCase):
elif k in ("__eq__", "__ne__"):
assert not meth(u, *args)
else:
- with self.assertRaises(NotImplementedError):
- meth(u, *args)
+ try:
+ res = meth(u, *args)
+ self.assertEqual(res, NotImplemented)
+ except NotImplementedError:
+ pass
def test_implementation(self):
if not has_gmp: