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

Commit

Permalink
trac 27829: add "# py2" to some tests involving "long(...)"
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpalmieri committed May 15, 2019
1 parent baff1c4 commit feac66d
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/sage/interfaces/fricas.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def __long__(self):
"""
TESTS::
sage: long(fricas('1')) # optional - fricas
sage: long(fricas('1')) # optional - fricas py2
1L
"""
return long(self.sage())
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_ZZ.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cdef class ntl_ZZ(object):
12
sage: ntl.ZZ(Integer(95413094))
95413094
sage: ntl.ZZ(long(223895239852389582983))
sage: ntl.ZZ(long(223895239852389582983)) # py2
223895239852389582983
sage: ntl.ZZ('-1')
-1
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_ZZ_p.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ cdef class ntl_ZZ_p(object):
1
sage: ntl.ZZ_p(Integer(95413094), c)
7
sage: ntl.ZZ_p(long(223895239852389582988), c)
sage: ntl.ZZ_p(long(223895239852389582988), c) # py2
5
sage: ntl.ZZ_p('-1', c)
10
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/ntl/ntl_ZZ_pE.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cdef class ntl_ZZ_pE(object):
[1 3]
sage: c.ZZ_pE(Integer(95413094))
[7]
sage: c.ZZ_pE(long(223895239852389582988))
sage: c.ZZ_pE(long(223895239852389582988)) # py2
[5]
sage: c.ZZ_pE('[1]')
[1]
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/pynac/pynac.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ cdef bint py_is_integer(x):
sage: py_is_integer(1r)
True
sage: py_is_integer(long(1))
sage: py_is_integer(long(1)) # py2
True
sage: py_is_integer(3^57)
True
Expand Down Expand Up @@ -1308,7 +1308,7 @@ def py_is_cinteger_for_doctest(x):
sage: from sage.libs.pynac.pynac import py_is_cinteger_for_doctest
sage: py_is_cinteger_for_doctest(1)
True
sage: py_is_cinteger_for_doctest(long(-3))
sage: py_is_cinteger_for_doctest(long(-3)) # py2
True
sage: py_is_cinteger_for_doctest(I.pyobject())
True
Expand Down Expand Up @@ -1706,11 +1706,11 @@ cdef py_log(x):
3.141592653589793j
sage: py_log(int(1))
0.0
sage: py_log(long(1))
sage: py_log(long(1)) # py2
0.0
sage: py_log(int(0))
-inf
sage: py_log(long(0))
sage: py_log(long(0)) # py2
-inf
sage: py_log(complex(0))
-inf
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ cdef class LazyImport(object):
sage: lazy_import('sage.all', 'foo')
sage: type(foo)
<type 'sage.misc.lazy_import.LazyImport'>
sage: long(foo)
sage: long(foo) # py2
10L
"""
return long(self.get_object())
Expand Down
8 changes: 4 additions & 4 deletions src/sage/misc/sage_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,16 @@ def __call__(self, x, coerced=False):
sage: sage_input(long(-5), verify=True) # py2
# Verified
-long(5)
sage: sage_input(long(-7), preparse=False, verify=True)
sage: sage_input(long(-7), preparse=False, verify=True) # py2
# Verified
-7L
sage: sage_input(long(11), preparse=None, verify=True) # py2
# Verified
long(11)
sage: sage_input(long(2^70), verify=True)
sage: sage_input(long(2^70), verify=True) # py2
# Verified
1180591620717411303424r
sage: sage_input(-long(2^80), preparse=False, verify=True)
sage: sage_input(-long(2^80), preparse=False, verify=True) # py2
# Verified
-1208925819614629174706176
sage: sage_input(long(2^75), preparse=None, verify=True) # py2
Expand Down Expand Up @@ -599,7 +599,7 @@ def int(self, n):
-717897987691852588770249
sage: sib = SageInputBuilder()
sage: sib.result(sib.int(long(2^65)))
sage: sib.result(sib.int(long(2^65))) # py2
36893488147419103232
sage: sib = SageInputBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/superseded.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _check_trac_number(trac_number):
...
ValueError: 0 is not a valid trac issue number
sage: _check_trac_number(int(10))
sage: _check_trac_number(long(1000))
sage: _check_trac_number(long(1000)) # py2
sage: _check_trac_number(10.0)
Traceback (most recent call last):
...
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
EXAMPLES::
sage: long(CIF(1,1)) # py2
sage: long(CIF(1,1)) # py2
Traceback (most recent call last):
...
TypeError: can't convert complex interval to long
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_number.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,11 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
EXAMPLES::
sage: a = ComplexNumber(2,1)
sage: long(a) # py2
sage: long(a) # py2
Traceback (most recent call last):
...
TypeError: can't convert complex to long; use long(abs(z))
sage: a.__long__() # py2
sage: a.__long__() # py2
Traceback (most recent call last):
...
TypeError: can't convert complex to long; use long(abs(z))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/element_givaro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ cdef class Cache_givaro(SageObject):
1
sage: k(int(2^100))
1
sage: k(long(2^100))
sage: k(long(2^100)) # py2
1
sage: k(-2^100)
2
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/element_pari_ffelt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
sage: K.<a> = FiniteField(7^20, impl='pari_ffelt')
sage: K(int(8))
1
sage: K(long(-2^300))
sage: K(long(-2^300)) # py2
6
::
Expand Down
46 changes: 23 additions & 23 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def is_Integer(x):
False
sage: is_Integer(int(2))
False
sage: is_Integer(long(2))
sage: is_Integer(long(2)) # py2
False
sage: is_Integer('5')
False
Expand Down Expand Up @@ -491,10 +491,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
"""
EXAMPLES::
sage: a = long(-901824309821093821093812093810928309183091832091)
sage: b = ZZ(a); b
sage: a = long(-901824309821093821093812093810928309183091832091) # py2
sage: b = ZZ(a); b # py2
-901824309821093821093812093810928309183091832091
sage: ZZ(b)
sage: ZZ(b) # py2
-901824309821093821093812093810928309183091832091
sage: ZZ('-901824309821093821093812093810928309183091832091')
-901824309821093821093812093810928309183091832091
Expand Down Expand Up @@ -562,13 +562,13 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: class MyInt(int):
....: pass
sage: class MyLong(long):
sage: class MyLong(long): # py2
....: pass
sage: class MyFloat(float):
....: pass
sage: ZZ(MyInt(3))
3
sage: ZZ(MyLong(4))
sage: ZZ(MyLong(4)) # py2
4
sage: ZZ(MyFloat(5))
5
Expand Down Expand Up @@ -1218,7 +1218,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
10
sage: print(Integer(16938402384092843092843098243).hex())
36bb1e3929d1a8fe2802f083
sage: print(hex(long(16938402384092843092843098243)))
sage: print(hex(long(16938402384092843092843098243))) # py2
0x36bb1e3929d1a8fe2802f083L
TESTS::
Expand Down Expand Up @@ -3525,16 +3525,16 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
EXAMPLES::
sage: n = 9023408290348092849023849820934820938490234290
sage: long(n)
sage: long(n) # py2
9023408290348092849023849820934820938490234290L
sage: long(-n)
sage: long(-n) # py2
-9023408290348092849023849820934820938490234290L
sage: n = 920938
sage: long(n)
sage: long(n) # py2
920938L
sage: n.__long__() # py2
920938L
sage: long(-1), long(0), long(1)
sage: long(-1), long(0), long(1) # py2
(-1L, 0L, 1L)
"""
return mpz_get_pylong(self.value)
Expand Down Expand Up @@ -3590,7 +3590,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: n = -920390823904823094890238490238484; n.__hash__()
-873977844 # 32-bit
6874330978542788722 # 64-bit
sage: hash(long(n))
sage: hash(long(n)) # py2
-873977844 # 32-bit
6874330978542788722 # 64-bit
Expand All @@ -3599,22 +3599,22 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: hash(-1), hash(0), hash(1)
(-2, 0, 1)
sage: n = 2^31 + 2^63 + 2^95 + 2^127 + 2^128*(2^32-2)
sage: hash(n) == hash(long(n))
sage: hash(n) == hash(long(n)) # py2
True
sage: hash(n-1) == hash(long(n-1))
sage: hash(n-1) == hash(long(n-1)) # py2
True
sage: hash(-n) == hash(long(-n))
sage: hash(-n) == hash(long(-n)) # py2
True
sage: hash(1-n) == hash(long(1-n))
sage: hash(1-n) == hash(long(1-n)) # py2
True
sage: n = 2^63 + 2^127 + 2^191 + 2^255 + 2^256*(2^64-2)
sage: hash(n) == hash(long(n))
sage: hash(n) == hash(long(n)) # py2
True
sage: hash(n-1) == hash(long(n-1))
sage: hash(n-1) == hash(long(n-1)) # py2
True
sage: hash(-n) == hash(long(-n))
sage: hash(-n) == hash(long(-n)) # py2
True
sage: hash(1-n) == hash(long(1-n))
sage: hash(1-n) == hash(long(1-n)) # py2
True
These tests come from :trac:`4957`::
Expand Down Expand Up @@ -7172,13 +7172,13 @@ cdef class long_to_Z(Morphism):
"""
EXAMPLES::
sage: f = ZZ.coerce_map_from(long); f
sage: f = ZZ.coerce_map_from(long); f # py2
Native morphism:
From: Set of Python objects of class 'long'
To: Integer Ring
sage: f(1rL)
sage: f(1rL) # py2
1
sage: f(-10000000000000000000001r)
sage: f(-10000000000000000000001r) # py2
-10000000000000000000001
"""
def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -7376,7 +7376,7 @@ def _coerce_map_from_(self, R):
sage: S.<y> = NumberField(x^3 + x + 1)
sage: S.coerce(int(4)) # indirect doctest
4
sage: S.coerce(long(7))
sage: S.coerce(long(7)) # py2
7
sage: S.coerce(-Integer(2))
-2
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/number_field/number_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,7 @@ cdef class NumberFieldElement(FieldElement):
::
sage: long(K(393/29))
sage: long(K(393/29)) # py2
13L
"""
return long(self.polynomial())
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/plural.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ cdef class NCPolynomialRing_plural(Ring):
17
sage: P(int(19))
19
sage: P(long(19))
sage: P(long(19)) # py2
19

TESTS:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/qqbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5656,7 +5656,7 @@ def __init__(self, x):

sage: polygen(QQbar) / int(3)
1/3*x
sage: QQbar(int(7)) / QQbar(long(2))
sage: QQbar(int(7)) / QQbar(long(2)) # py2
7/2
"""
if isinstance(x, (sage.rings.integer.Integer,
Expand Down
12 changes: 7 additions & 5 deletions src/sage/rings/rational.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def is_Rational(x):
True
sage: is_Rational(int(2))
False
sage: is_Rational(long(2))
sage: is_Rational(long(2)) # py2
False
sage: is_Rational('5')
False
Expand Down Expand Up @@ -3009,9 +3009,9 @@ cdef class Rational(sage.structure.element.FieldElement):

EXAMPLES::

sage: long(7/3)
sage: long(7/3) # py2
2L
sage: long(-7/3)
sage: long(-7/3) # py2
-2L
"""
cdef mpz_t x
Expand Down Expand Up @@ -4253,9 +4253,11 @@ cdef class long_to_Q(Morphism):
EXAMPLES::

sage: f = sage.rings.rational.long_to_Q()
sage: f(long(4)) # indirect doctest
sage: f(long(4)) # indirect doctest py2
4
sage: f(long(4^100))
sage: f(long(4^100)) # py2
1606938044258990275541962092341162602522202993782792835301376
sage: f(4^100) # py3
1606938044258990275541962092341162602522202993782792835301376
"""

Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/rational_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class RationalField(Singleton, number_field_base.NumberField):

EXAMPLES::

sage: a = long(901824309821093821093812093810928309183091832091)
sage: b = QQ(a); b
sage: a = long(901824309821093821093812093810928309183091832091) # py2
sage: b = QQ(a); b # py2
901824309821093821093812093810928309183091832091
sage: QQ(b)
sage: QQ(b) # py2
901824309821093821093812093810928309183091832091
sage: QQ(int(93820984323))
93820984323
Expand Down
7 changes: 4 additions & 3 deletions src/sage/structure/coerce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ cpdef py_scalar_to_element(x):
sage: x = py_scalar_to_element(int(42))
sage: x, parent(x)
(42, Integer Ring)
sage: x = py_scalar_to_element(long(42))
sage: x = py_scalar_to_element(long(42)) # py2
sage: x, parent(x)
(42, Integer Ring)
sage: x = py_scalar_to_element(float(42))
Expand Down Expand Up @@ -250,7 +250,8 @@ cpdef py_scalar_to_element(x):
Test compatibility with :func:`py_scalar_parent`::

sage: from sage.structure.coerce import py_scalar_parent
sage: elt = [True, int(42), long(42), float(42), complex(42)]
sage: elt = [True, int(42), long(42), float(42), complex(42)] # py2
sage: elt = [True, int(42), float(42), complex(42)] # py3
sage: for x in elt:
....: assert py_scalar_parent(type(x)) == py_scalar_to_element(x).parent()

Expand Down Expand Up @@ -322,7 +323,7 @@ cpdef bint parent_is_integers(P) except -1:
sage: from sage.structure.coerce import parent_is_integers
sage: parent_is_integers(int)
True
sage: parent_is_integers(long)
sage: parent_is_integers(long) # py2
True
sage: parent_is_integers(float)
False
Expand Down
Loading

0 comments on commit feac66d

Please sign in to comment.