Permalink
Browse files

Do not pass Unicode filenames to pycairo.

Older versions (1.8 on py2) do not like that.
  • Loading branch information...
1 parent b1f0959 commit 9447363f69be51822effb114f2f2d9f3bbfed92b @SimonSapin SimonSapin committed Jul 28, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 weasyprint/document.py
View
@@ -13,6 +13,7 @@
from __future__ import division, unicode_literals
import io
+import sys
import math
import shutil
@@ -133,6 +134,9 @@ def write_png(self, target=None, resolution=None):
surface.write_to_png(target)
return target.getvalue()
else:
+ if sys.version_info[0] < 3 and isinstance(target, unicode):
+ # py2cairo 1.8 does not support unicode filenames.
+ target = target.encode(sys.getfilesystemencoding())
surface.write_to_png(target)
def write_pdf(self, target=None):

0 comments on commit 9447363

Please sign in to comment.