Commit a96ee49b authored by Stefan Behnel's avatar Stefan Behnel

merged in changes from cython-release branch

parents 9255da38 35f59b76
......@@ -186,8 +186,8 @@ class LetNodeMixin:
def setup_temp_expr(self, code):
self.temp_expression.generate_evaluation_code(code)
self._result_in_temp = self.temp_expression.result_in_temp()
self.temp_type = self.temp_expression.type
self._result_in_temp = self.temp_expression.result_in_temp()
if self._result_in_temp:
self.temp = self.temp_expression.result()
else:
......@@ -195,10 +195,15 @@ class LetNodeMixin:
self.temp = code.funcstate.allocate_temp(
self.temp_type, manage_ref=True)
code.putln("%s = %s;" % (self.temp, self.temp_expression.result()))
self.temp_expression.generate_disposal_code(code)
self.temp_expression.free_temps(code)
self.lazy_temp.result_code = self.temp
def teardown_temp_expr(self, code):
if not self._result_in_temp:
if self._result_in_temp:
self.temp_expression.generate_disposal_code(code)
self.temp_expression.free_temps(code)
else:
if self.temp_type.is_pyobject:
code.put_decref_clear(self.temp, self.temp_type)
code.funcstate.release_temp(self.temp)
......@@ -227,6 +232,12 @@ class EvalWithTempExprNode(ExprNodes.ExprNode, LetNodeMixin):
self.subexpression.analyse_types(env)
self.type = self.subexpression.type
def free_subexpr_temps(self, code):
self.subexpression.free_temps(code)
def generate_subexpr_disposal_code(self, code):
self.subexpression.generate_disposal_code(code)
def generate_evaluation_code(self, code):
self.setup_temp_expr(code)
self.subexpression.generate_evaluation_code(code)
......
......@@ -6,10 +6,9 @@ import sys
if 'sdist' in sys.argv and sys.platform != "win32" and sys.version_info >= (2,4):
# Record the current revision in .hgrev
import subprocess # os.popen is cleaner but deprecated
changset = subprocess.Popen("hg log --rev tip | grep changeset",
shell=True,
changeset = subprocess.Popen("hg identify --id --rev tip".split(),
stdout=subprocess.PIPE).stdout.read()
rev = changset.decode('ISO-8859-1').split(':')[-1].strip()
rev = changeset.decode('ISO-8859-1').strip()
hgrev = open('.hgrev', 'w')
hgrev.write(rev)
hgrev.close()
......
......@@ -73,3 +73,17 @@ def test_custom():
"""
assert isinstance(A(), A)
return True
def test_nested(x):
"""
>>> test_nested(1)
True
>>> test_nested(1.5)
True
>>> test_nested("a")
False
"""
cdef object a = (x, None)
if isinstance(a[0], (int, float)):
return True
return False
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