diff options
author | Joseph <powderflask@gmail.com> | 2015-07-28 18:36:08 -0700 |
---|---|---|
committer | Joseph <powderflask@gmail.com> | 2015-07-28 18:36:08 -0700 |
commit | 4b73d48254749bbf08c42126f10b16ac2d71f004 (patch) | |
tree | 8d501467f74913234516a01a5dc74c27e9beaa0a | |
parent | ed9881478d064e55679a2eb684c29baf1939776c (diff) | |
download | django-wkhtmltopdf-4b73d48254749bbf08c42126f10b16ac2d71f004.tar.gz django-wkhtmltopdf-4b73d48254749bbf08c42126f10b16ac2d71f004.tar.bz2 django-wkhtmltopdf-4b73d48254749bbf08c42126f10b16ac2d71f004.zip |
Patch python3 / mod_wsgi incompatibility on sys.stderrr.fileno() call
Root cause of this issue is in python3 / mod_wsgi. See: https://github.com/GrahamDumpleton/mod_wsgi/issues/85
This patch detects if there is something screwy with fileno() and simply skips setting stderr if there is to avoid the AttributeError that occurs otherwise. Pull https://github.com/incuna/django-wkhtmltopdf/pull/40 fixed this same issue when it arose for python 2.7, but the nature of the issue seems to have shifted, making it trickier to detect that the fileno() method cannot be called.
-rw-r--r-- | wkhtmltopdf/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index e841380..9c338bf 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -93,8 +93,13 @@ def wkhtmltopdf(pages, output=None, **kwargs): list(pages), [output])) ck_kwargs = {'env': env} - if hasattr(sys.stderr, 'fileno'): + try: + i = sys.stderr.fileno() ck_kwargs['stderr'] = sys.stderr + except AttributeError: + # can't call fileno() on mod_wsgi stderr object + pass + return check_output(ck_args, **ck_kwargs) |