# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1243479394 25200
# Node ID e081033d4057aa41c523994f64b73cf724d78fc8
# Parent 23bed85236496fc7269544580f0e02370e006635
Trac #6111: Fix bool(SR(oo) == sympy.oo) segfault.
diff git a/sage/symbolic/constants.py b/sage/symbolic/constants.py
a

b


276  276  from sage.symbolic.pynac import register_symbol 
277  277  register_symbol(self.expression(), self._conversions) 
278  278  
 279  def __eq__(self, other): 
 280  """ 
 281  EXAMPLES:: 
 282  
 283  sage: from sage.symbolic.constants import Constant 
 284  sage: p = Constant('p') 
 285  sage: s = Constant('s') 
 286  sage: p == p 
 287  True 
 288  sage: p == s 
 289  False 
 290  sage: p != s 
 291  True 
 292  """ 
 293  return (self.__class__ == other.__class__ and 
 294  self._name == other._name) 
 295  
279  296  def __reduce__(self): 
280  297  """ 
281  298  Adds support for pickling constants. 
diff git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
a

b


1263  1263  False 
1264  1264  sage: bool(1 + x^2 != 2 + x*x) 
1265  1265  True 
 1266  sage: bool(SR(oo) == SR(oo)) 
 1267  True 
 1268  sage: bool(SR(oo) == SR(oo)) 
 1269  False 
 1270  sage: bool(SR(oo) != SR(oo)) 
 1271  True 
1266  1272  """ 
1267  1273  if self.is_relational(): 
 1274  #If both the left hand side and right hand side are wrappers 
 1275  #around Sage objects, then we should do the comparison directly 
 1276  #with those objects 
 1277  if is_a_constant(self._gobj.lhs()) and is_a_constant(self._gobj.rhs()): 
 1278  return self.operator()(self.lhs().pyobject(), self.rhs().pyobject()) 
 1279  
1268  1280  res = relational_to_bool(self._gobj) 
1269  1281  if res: 
1270  1282  return True 