Merge ~spitap/dkimpy:FixSilentFailNonAsync into dkimpy:master

Proposed by Adrien
Status: Needs review
Proposed branch: ~spitap/dkimpy:FixSilentFailNonAsync
Merge into: dkimpy:master
Diff against target: 31 lines (+6/-0)
1 file modified
dkim/__init__.py (+6/-0)
Reviewer Review Type Date Requested Status
dkimpy developers Pending
Review via email: mp+427829@code.launchpad.net

Commit message

Raise an exception when calling an async function where it shouldn't.

Description of the change

To post a comment you must log in.

Unmerged commits

8f008c0... by Adrien

Raise exception when calling async function where it shouldn't

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/dkim/__init__.py b/dkim/__init__.py
index acdad51..4c4ba09 100644
--- a/dkim/__init__.py
+++ b/dkim/__init__.py
@@ -39,6 +39,7 @@ import re
39import sys39import sys
40import time40import time
41import binascii41import binascii
42import inspect
4243
43# only needed for arc44# only needed for arc
44try:45try:
@@ -187,6 +188,9 @@ class NaClNotFoundError(DKIMException):
187class UnknownKeyTypeError(DKIMException):188class UnknownKeyTypeError(DKIMException):
188 """ Key type (k tag) is not known (rsa/ed25519) """189 """ Key type (k tag) is not known (rsa/ed25519) """
189190
191class AsyncFunctionCalledFromNonAsync(DKIMException):
192 """ Tried to call async function not properly"""
193
190194
191def select_headers(headers, include_headers):195def select_headers(headers, include_headers):
192 """Select message header fields to be signed/verified.196 """Select message header fields to be signed/verified.
@@ -946,6 +950,8 @@ class DKIM(DomainSigner):
946 #: @return: True if signature verifies or False otherwise950 #: @return: True if signature verifies or False otherwise
947 #: @raise DKIMException: when the message, signature, or key are badly formed951 #: @raise DKIMException: when the message, signature, or key are badly formed
948 def verify(self,idx=0,dnsfunc=get_txt):952 def verify(self,idx=0,dnsfunc=get_txt):
953 if inspect.iscoroutinefunction(dnsfunc):
954 raise AsyncFunctionCalledFromNonAsync()
949 prep = self.verify_headerprep(idx)955 prep = self.verify_headerprep(idx)
950 if prep:956 if prep:
951 sig, include_headers, sigheaders = prep957 sig, include_headers, sigheaders = prep

Subscribers

People subscribed via source and target branches

to all changes: