mitsuhiko/jinja2 — Issue #97: Jinja2 2.6 fails to dump() on Python 3.2
Author: kazutoshi
Created: 2012-02-29 11:02:26+00:00
State: open

Below code is failed with Jinja2 2.6 on Python 3.2.

jinja2.Template('Hello {{ name }}!').stream(name='Python 3').dump('hello.txt')

Python 3.2 doesn't have file() built-in function. It must be replaced to open().
I think the following patch will work on both Python 2.x and 3.x.

--- environment.py.orig	2012-02-29 19:38:35.000000000 +0900
+++ environment.py	2012-02-29 19:46:36.000000000 +0900
@@ -1062,7 +1062,7 @@
"""
close = False
if isinstance(fp, str):
- fp = file(fp, 'w')
+ fp = open(fp, 'wb')
close = True
try:
if encoding is not None: