Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac 20731: isinstance(X,Y) -> type(X) is Y
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Jul 9, 2016
1 parent 1a93a12 commit dd2defb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/sage/rings/integer.pyx
Expand Up @@ -1584,7 +1584,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
x = <Integer>PY_NEW(Integer)
mpz_add(x.value, (<Integer>left).value, (<Integer>right).value)
return x
elif isinstance(right, Rational):
elif type(right) is Rational:
y = <Rational> Rational.__new__(Rational)
mpq_add_z(y.value, (<Rational>right).value, (<Integer>left).value)
return y
Expand Down Expand Up @@ -1667,7 +1667,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
x = <Integer>PY_NEW(Integer)
mpz_sub(x.value, (<Integer>left).value, (<Integer>right).value)
return x
elif isinstance(right, Rational):
elif type(right) is Rational:
y = <Rational> Rational.__new__(Rational)
mpz_mul(mpq_numref(y.value), (<Integer>left).value,
mpq_denref((<Rational>right).value))
Expand Down Expand Up @@ -1777,7 +1777,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
x = <Integer>PY_NEW(Integer)
mpz_mul(x.value, (<Integer>left).value, (<Integer>right).value)
return x
elif isinstance(right, Rational):
elif type(right) is Rational:
y = <Rational> Rational.__new__(Rational)
mpq_mul_z(y.value, (<Rational>right).value, (<Integer>left).value)
return y
Expand Down Expand Up @@ -1844,7 +1844,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
x = <Rational> Rational.__new__(Rational)
mpq_div_zz(x.value, (<Integer>left).value, (<Integer>right).value)
return x
elif isinstance(right, Rational):
elif type(right) is Rational:
if mpq_sgn((<Rational>right).value) == 0:
raise ZeroDivisionError("rational division by zero")
# left * den(right) / num(right)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/rational.pyx
Expand Up @@ -2096,7 +2096,7 @@ cdef class Rational(sage.structure.element.FieldElement):
x = <Rational> Rational.__new__(Rational)
mpq_add(x.value, (<Rational>left).value, (<Rational>right).value)
return x
elif isinstance(right, Integer):
elif type(right) is Integer:
x = <Rational> Rational.__new__(Rational)
mpq_add_z(x.value, (<Rational>left).value, (<Integer>right).value)
return x
Expand Down Expand Up @@ -2144,7 +2144,7 @@ cdef class Rational(sage.structure.element.FieldElement):
x = <Rational> Rational.__new__(Rational)
mpq_sub(x.value, (<Rational>left).value, (<Rational>right).value)
return x
elif isinstance(right, Integer):
elif type(right) is Integer:
x = <Rational> Rational.__new__(Rational)
mpz_mul(mpq_numref(x.value), mpq_denref((<Rational>left).value),
(<Integer>right).value)
Expand Down Expand Up @@ -2201,7 +2201,7 @@ cdef class Rational(sage.structure.element.FieldElement):
x = <Rational> Rational.__new__(Rational)
mpq_mul(x.value, (<Rational>left).value, (<Rational>right).value)
return x
elif isinstance(right, Integer):
elif type(right) is Integer:
x = <Rational> Rational.__new__(Rational)
mpq_mul_z(x.value, (<Rational>left).value, (<Integer>right).value)
return x
Expand Down Expand Up @@ -2254,7 +2254,7 @@ cdef class Rational(sage.structure.element.FieldElement):
x = <Rational> Rational.__new__(Rational)
mpq_div(x.value, (<Rational>left).value, (<Rational>right).value)
return x
elif isinstance(right, Integer):
elif type(right) is Integer:
if mpz_cmp_si((<Integer> right).value, 0) == 0:
raise ZeroDivisionError('rational division by zero')
x = <Rational> Rational.__new__(Rational)
Expand Down

0 comments on commit dd2defb

Please sign in to comment.