From c66222e8d649ef3d10ca679921c4c6ce8793cddd Mon Sep 17 00:00:00 2001 From: Matt Lenc Date: Wed, 18 Jun 2014 17:11:38 +0100 Subject: First try py3k then fall back to python2 --- wkhtmltopdf/utils.py | 6 +++--- wkhtmltopdf/views.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index 9be8f86..e34085d 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -7,11 +7,11 @@ import re import sys try: - from urllib import pathname2url - from urlparse import urljoin -except ImportError: # py3k from urllib.request import pathname2url from urllib.parse import urljoin +except ImportError: # Python2 + from urllib import pathname2url + from urlparse import urljoin from django.conf import settings from django.utils import six diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index 92e2d0f..1c57869 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -77,12 +77,12 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse): content = make_absolute_paths(content) try: - tempfile = NamedTemporaryFile(mode=mode, bufsize=bufsize, + # Python3 has 'buffering' arg instead of 'bufsize' + tempfile = NamedTemporaryFile(mode=mode, buffering=bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete) except TypeError: - # Python 3 has 'buffering' arg for 'NamedTemporaryFile' class - tempfile = NamedTemporaryFile(mode=mode, buffering=bufsize, + tempfile = NamedTemporaryFile(mode=mode, bufsize=bufsize, suffix=suffix, prefix=prefix, dir=dir, delete=delete) -- cgit v1.2.3