Use inspect instead of TypeError for backwards-compatible APIs

This commit is contained in:
Raphael Michel
2019-07-09 10:06:33 +02:00
parent 55d423af18
commit 0ac98f5127
3 changed files with 11 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import inspect
import logging
import smtplib
import warnings
@@ -177,9 +178,9 @@ def mail(email: str, subject: str, template: Union[str, LazyI18nString],
body_plain += "\r\n"
try:
try:
if 'position' in inspect.signature(renderer.render).parameters:
body_html = renderer.render(content_plain, signature, str(subject), order, position)
except TypeError:
else:
# Backwards compatibility
warnings.warn('E-mail renderer called without position argument because position argument is not '
'supported.',