Commit 1931b7d9 by Chris Jerdonek

Merge branch 'issue_34' into development: closing issue #34

parents b01a1e00 2c09a99b
...@@ -7,6 +7,8 @@ Next Release (version TBD) ...@@ -7,6 +7,8 @@ Next Release (version TBD)
accordance with the mustache spec. [heliodor] accordance with the mustache spec. [heliodor]
* A custom template loader can now be passed to a View. [cjerdonek] * A custom template loader can now be passed to a View. [cjerdonek]
* Added a command-line interface. [vrde, cjerdonek] * Added a command-line interface. [vrde, cjerdonek]
* Bugfix: Fixed an issue that affected the rendering of zeroes when using
certain implementations of Python (i.e. PyPy). [alex]
* Added some docstrings. [kennethreitz] * Added some docstrings. [kennethreitz]
0.4.0 (2011-01-12) 0.4.0 (2011-01-12)
......
...@@ -166,7 +166,12 @@ class Template(object): ...@@ -166,7 +166,12 @@ class Template(object):
raw = self.view.get(tag_name, '') raw = self.view.get(tag_name, '')
# For methods with no return value # For methods with no return value
if not raw and raw is not 0: #
# We use "==" rather than "is" to compare integers, as using "is" relies
# on an implementation detail of CPython. The test about rendering
# zeroes failed while using PyPy when using "is".
# See issue #34: https://github.com/defunkt/pystache/issues/34
if not raw and raw != 0:
if tag_name == '.': if tag_name == '.':
raw = self.view.context_list[0] raw = self.view.context_list[0]
else: else:
......
...@@ -139,7 +139,11 @@ class View(object): ...@@ -139,7 +139,11 @@ class View(object):
def __getitem__(self, attr): def __getitem__(self, attr):
val = self.get(attr, None) val = self.get(attr, None)
if not val and val is not 0: # We use "==" rather than "is" to compare integers, as using "is" relies
# on an implementation detail of CPython. The test about rendering
# zeroes failed while using PyPy when using "is".
# See issue #34: https://github.com/defunkt/pystache/issues/34
if not val and val != 0:
raise KeyError("Key '%s' does not exist in View" % attr) raise KeyError("Key '%s' does not exist in View" % attr)
return val return val
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment