Skip to content

Commit 406153f

Browse files
authored
Merge pull request #409 from hugovk/rm-eol
Drop support for EOL Python 2.7-3.8
2 parents 4dff0bb + 39af3f7 commit 406153f

20 files changed

+21
-65
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["pypy-2.7", "pypy-3.8", "2.7", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
14+
python-version: ["pypy-3.11", "3.9", "3.10", "3.11", "3.12", "3.13"]
1515
os: [ubuntu-latest, macos-latest, windows-latest]
1616
include:
1717
# Add new helper variables to existing jobs
18-
- {python-version: "pypy-2.7", toxenv: "pypy"}
19-
- {python-version: "pypy-3.8", toxenv: "pypy3"}
20-
- {python-version: "2.7", toxenv: "py27"}
21-
- {python-version: "3.7", toxenv: "py37"}
22-
- {python-version: "3.8", toxenv: "py38"}
18+
- {python-version: "pypy-3.11", toxenv: "pypy3"}
2319
- {python-version: "3.9", toxenv: "py39"}
2420
- {python-version: "3.10", toxenv: "py310"}
2521
- {python-version: "3.11", toxenv: "py311"}

README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If you find Colorama useful, please |donate| to the authors. Thank you!
2929
Installation
3030
------------
3131

32-
Tested on CPython 2.7, 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 and PyPy 2.7 and 3.8.
32+
Tested on CPython 3.9, 3.10, 3.11, 3.12, 3.13 and PyPy 3.11.
3333

3434
No requirements other than the standard library.
3535

@@ -257,10 +257,6 @@ init(wrap=True):
257257
init(wrap=False)
258258
stream = AnsiToWin32(sys.stderr).stream
259259
260-
# Python 2
261-
print >>stream, Fore.BLUE + 'blue text on stderr'
262-
263-
# Python 3
264260
print(Fore.BLUE + 'blue text on stderr', file=stream)
265261
266262
Recognised ANSI Sequences

colorama/ansi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def clear_line(mode=2):
2222
return CSI + str(mode) + 'K'
2323

2424

25-
class AnsiCodes(object):
25+
class AnsiCodes:
2626
def __init__(self):
2727
# the subclasses declare class attributes which are numbers.
2828
# Upon instantiation we define instance attributes, which are the same
@@ -33,7 +33,7 @@ def __init__(self):
3333
setattr(self, name, code_to_chars(value))
3434

3535

36-
class AnsiCursor(object):
36+
class AnsiCursor:
3737
def UP(self, n=1):
3838
return CSI + str(n) + 'A'
3939
def DOWN(self, n=1):

colorama/ansitowin32.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
winterm = WinTerm()
1414

1515

16-
class StreamWrapper(object):
16+
class StreamWrapper:
1717
'''
1818
Wraps a stream (such as stdout), acting as a transparent proxy for all
1919
attribute access apart from method 'write()', which is delegated to our
@@ -69,7 +69,7 @@ def closed(self):
6969
return True
7070

7171

72-
class AnsiToWin32(object):
72+
class AnsiToWin32:
7373
'''
7474
Implements a 'write()' method which, on Windows, will strip ANSI character
7575
sequences from the text, and if outputting to a tty, will convert them into

colorama/initialise.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ def _wipe_internal_state_for_tests():
2121
global fixed_windows_console
2222
fixed_windows_console = False
2323

24-
try:
25-
# no-op if it wasn't registered
26-
atexit.unregister(reset_all)
27-
except AttributeError:
28-
# python 2: no atexit.unregister. Oh well, we did our best.
29-
pass
24+
# no-op if it wasn't registered
25+
atexit.unregister(reset_all)
3026

3127

3228
def reset_all():

colorama/tests/ansitowin32_test.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
22
from io import StringIO, TextIOWrapper
33
from unittest import TestCase, main
4-
try:
5-
from contextlib import ExitStack
6-
except ImportError:
7-
# python 2
8-
from contextlib2 import ExitStack
9-
10-
try:
11-
from unittest.mock import MagicMock, Mock, patch
12-
except ImportError:
13-
from mock import MagicMock, Mock, patch
4+
from unittest.mock import MagicMock, Mock, patch
5+
from contextlib import ExitStack
146

157
from ..ansitowin32 import AnsiToWin32, StreamWrapper
168
from ..win32 import ENABLE_VIRTUAL_TERMINAL_PROCESSING
@@ -35,7 +27,7 @@ def testDelegatesContext(self):
3527
mockConverter = Mock()
3628
s = StringIO()
3729
with StreamWrapper(s, mockConverter) as fp:
38-
fp.write(u'hello')
30+
fp.write('hello')
3931
self.assertTrue(s.closed)
4032

4133
def testProxyNoContextManager(self):

colorama/tests/initialise_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
22
import sys
33
from unittest import TestCase, main, skipUnless
4-
5-
try:
6-
from unittest.mock import patch, Mock
7-
except ImportError:
8-
from mock import patch, Mock
4+
from unittest.mock import patch, Mock
95

106
from ..ansitowin32 import StreamWrapper
117
from ..initialise import init, just_fix_windows_console, _wipe_internal_state_for_tests

colorama/tests/winterm_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
22
import sys
33
from unittest import TestCase, main, skipUnless
4-
5-
try:
6-
from unittest.mock import Mock, patch
7-
except ImportError:
8-
from mock import Mock, patch
4+
from unittest.mock import Mock, patch
95

106
from ..winterm import WinColor, WinStyle, WinTerm
117

colorama/winterm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def get_osfhandle(_):
99
from . import win32
1010

1111
# from wincon.h
12-
class WinColor(object):
12+
class WinColor:
1313
BLACK = 0
1414
BLUE = 1
1515
GREEN = 2
@@ -20,12 +20,12 @@ class WinColor(object):
2020
GREY = 7
2121

2222
# from wincon.h
23-
class WinStyle(object):
23+
class WinStyle:
2424
NORMAL = 0x00 # dim text, dim background
2525
BRIGHT = 0x08 # bright text, dim background
2626
BRIGHT_BACKGROUND = 0x80 # dim text, bright background
2727

28-
class WinTerm(object):
28+
class WinTerm:
2929

3030
def __init__(self):
3131
self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes
@@ -191,5 +191,5 @@ def enable_vt_processing(fd):
191191
if mode & win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING:
192192
return True
193193
# Can get TypeError in testsuite where 'fd' is a Mock() and IOError in python2.7
194-
except (IOError, OSError, TypeError):
194+
except (OSError, TypeError):
195195
return False

demos/demo01.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# print grid of all colors and brightnesses
55
# uses stdout.write to write chars with no newline nor spaces between them
66
# This should run more-or-less identically on Windows and Unix.
7-
from __future__ import print_function
87
import sys
98

109
# Add parent dir to sys path, so the following 'import colorama' always finds

0 commit comments

Comments
 (0)