Skip to content

Commit 96c5842

Browse files
committed
Revert "Remove support for Python 2.7 because it is now really difficult to test with in GHA."
This reverts commit cf86ffd.
1 parent 83b73fe commit 96c5842

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
fail-fast: false
4343

4444
matrix:
45-
python_version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
45+
python_version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
4646

4747
include:
4848
- python_version: "3.12-dev"
@@ -143,11 +143,14 @@ jobs:
143143
#os: [macos-10.15, windows-latest]
144144
#os: [macos-10.15, macOS-M1]
145145
os: [macos-11.0, windows-latest]
146-
python_version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
146+
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
147147

148148
include:
149149
- python_version: "3.12-dev"
150150
allowed_failure: true
151+
exclude:
152+
- python_version: "2.7"
153+
os: windows-latest
151154

152155
runs-on: ${{ matrix.os }}
153156
env: { MACOSX_DEPLOYMENT_TARGET: 11.0 }

CHANGES.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ ChangeLog
66

77
* Add support for Python 3.12 by using Cython 3.0.0.
88

9-
+ Remove support for Python 2.7.
10-
119

1210
1.14 (2023-03-19)
1311
-----------------

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"Intended Audience :: Developers",
101101
"Operating System :: OS Independent",
102102
"Programming Language :: Python",
103+
"Programming Language :: Python :: 2",
103104
"Programming Language :: Python :: 3",
104105
"Programming Language :: Cython",
105106
"Topic :: Scientific/Engineering :: Mathematics",

src/test_fractions.py

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
44
# 2011, 2012, 2013, 2014 Python Software Foundation; All Rights Reserved
55
#
6-
# Based on the "test/test_fractions" module in CPython 3.4 and later.
6+
# Based on the "test/test_fractions" module in CPython 3.4.
77
# https://hg.python.org/cpython/file/b18288f24501/Lib/test/test_fractions.py
88

99
"""Tests for Lib/fractions.py, slightly adapted for quicktions."""
@@ -523,14 +523,16 @@ def testLimitDenominator(self):
523523
def testConversions(self):
524524
self.assertTypedEquals(-1, math.trunc(F(-11, 10)))
525525
self.assertTypedEquals(1, math.trunc(F(11, 10)))
526-
self.assertTypedEquals(-2, math.floor(F(-11, 10)))
527-
self.assertTypedEquals(-1, math.ceil(F(-11, 10)))
528-
self.assertTypedEquals(-1, math.ceil(F(-10, 10)))
526+
if sys.version_info[0] >= 3:
527+
self.assertTypedEquals(-2, math.floor(F(-11, 10)))
528+
self.assertTypedEquals(-1, math.ceil(F(-11, 10)))
529+
self.assertTypedEquals(-1, math.ceil(F(-10, 10)))
529530
self.assertTypedEquals(-1, int(F(-11, 10)))
530-
self.assertTypedEquals(0, round(F(-1, 10)))
531-
self.assertTypedEquals(0, round(F(-5, 10)))
532-
self.assertTypedEquals(-2, round(F(-15, 10)))
533-
self.assertTypedEquals(-1, round(F(-7, 10)))
531+
if sys.version_info[0] >= 3:
532+
self.assertTypedEquals(0, round(F(-1, 10)))
533+
self.assertTypedEquals(0, round(F(-5, 10)))
534+
self.assertTypedEquals(-2, round(F(-15, 10)))
535+
self.assertTypedEquals(-1, round(F(-7, 10)))
534536

535537
self.assertEqual(False, bool(F(0, 1)))
536538
self.assertEqual(True, bool(F(3, 2)))
@@ -625,14 +627,16 @@ def __eq__(self, other):
625627
numerator = CustomValue(0)
626628
r = F(numerator)
627629
self.assertEqual(bool(r), False)
628-
self.assertIs(bool(r), False)
630+
if sys.version_info >= (3,):
631+
self.assertIs(bool(r), False)
629632

630633
def testRound(self):
631-
self.assertTypedEquals(F(-200), round(F(-150), -2))
632-
self.assertTypedEquals(F(-200), round(F(-250), -2))
633-
self.assertTypedEquals(F(30), round(F(26), -1))
634-
self.assertTypedEquals(F(-2, 10), round(F(-15, 100), 1))
635-
self.assertTypedEquals(F(-2, 10), round(F(-25, 100), 1))
634+
if sys.version_info[0] >= 3:
635+
self.assertTypedEquals(F(-200), round(F(-150), -2))
636+
self.assertTypedEquals(F(-200), round(F(-250), -2))
637+
self.assertTypedEquals(F(30), round(F(26), -1))
638+
self.assertTypedEquals(F(-2, 10), round(F(-15, 100), 1))
639+
self.assertTypedEquals(F(-2, 10), round(F(-25, 100), 1))
636640

637641
def testArithmetic(self):
638642
self.assertEqual(F(1, 2), F(1, 10) + F(2, 5))
@@ -652,9 +656,13 @@ def testArithmetic(self):
652656
self.assertEqual(F(27, 8), F(2, 3) ** F(-3))
653657
self.assertTypedEquals(2.0, F(4) ** F(1, 2))
654658
self.assertEqual(F(1, 1), +F(1, 1))
655-
z = pow(F(-1), F(1, 2))
656-
self.assertAlmostEqual(z.real, 0)
657-
self.assertEqual(z.imag, 1)
659+
try:
660+
z = pow(F(-1), F(1, 2))
661+
except ValueError:
662+
self.assertEqual(2, sys.version_info[0])
663+
else:
664+
self.assertAlmostEqual(z.real, 0)
665+
self.assertEqual(z.imag, 1)
658666

659667
# Regression test for #27539.
660668
p = F(-1, 2) ** 0
@@ -765,9 +773,13 @@ def testMixedArithmetic(self):
765773
self.assertTypedEquals(0.1, F(1, 10) ** 1.0)
766774
self.assertTypedEquals(0.1 + 0j, F(1, 10) ** (1.0 + 0j))
767775
self.assertTypedEquals(4 , 2 ** F(2, 1))
768-
z = pow(-1, F(1, 2))
769-
self.assertAlmostEqual(0, z.real)
770-
self.assertEqual(1, z.imag)
776+
try:
777+
z = pow(-1, F(1, 2))
778+
except ValueError:
779+
self.assertEqual(2, sys.version_info[0])
780+
else:
781+
self.assertAlmostEqual(0, z.real)
782+
self.assertEqual(1, z.imag)
771783
self.assertTypedEquals(F(1, 4) , 2 ** F(-2, 1))
772784
self.assertTypedEquals(2.0 , 4 ** F(1, 2))
773785
self.assertTypedEquals(0.25, 2.0 ** F(-2, 1))
@@ -924,12 +936,13 @@ def testStringification(self):
924936
self.assertEqual("7", str(F(7, 1)))
925937

926938
def testHash(self):
927-
hmod = sys.hash_info.modulus
928-
hinf = sys.hash_info.inf
929-
self.assertEqual(hash(2.5), hash(F(5, 2)))
930-
self.assertEqual(hash(10**50), hash(F(10**50)))
931-
self.assertNotEqual(hash(float(10**23)), hash(F(10**23)))
932-
self.assertEqual(hinf, hash(F(1, hmod)))
939+
if sys.version_info >= (3,2):
940+
hmod = sys.hash_info.modulus
941+
hinf = sys.hash_info.inf
942+
self.assertEqual(hash(2.5), hash(F(5, 2)))
943+
self.assertEqual(hash(10**50), hash(F(10**50)))
944+
self.assertNotEqual(hash(float(10**23)), hash(F(10**23)))
945+
self.assertEqual(hinf, hash(F(1, hmod)))
933946
# Check that __hash__ produces the same value as hash(), for
934947
# consistency with int and Decimal. (See issue #10356.)
935948
self.assertEqual(hash(F(-1)), F(-1).__hash__())
@@ -942,8 +955,9 @@ def testHash_compare(self):
942955
self.assertEqual(hash(fractions.Fraction(10, 1)), hash(F(10, 1)))
943956
self.assertEqual(hash(fractions.Fraction(-1, 1)), hash(F(-1, 1)))
944957
self.assertEqual(hash(fractions.Fraction(-1, 10)), hash(F(-1, 10)))
945-
self.assertEqual(hash(fractions.Fraction(1.2)), hash(F(1.2)))
946-
self.assertEqual(hash(fractions.Fraction(1.5)), hash(F(1.5)))
958+
if sys.version_info >= (2, 7):
959+
self.assertEqual(hash(fractions.Fraction(1.2)), hash(F(1.2)))
960+
self.assertEqual(hash(fractions.Fraction(1.5)), hash(F(1.5)))
947961

948962
def testApproximatePi(self):
949963
# Algorithm borrowed from

0 commit comments

Comments
 (0)