From 78996837ec609a2e4adb7ffd14df1d03ca9bc8f9 Mon Sep 17 00:00:00 2001 From: Timok Khan Date: Tue, 21 Jun 2016 22:30:34 +0200 Subject: [PATCH 1/3] Add light colors in README --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index c341ad6..9a349ac 100644 --- a/README.rst +++ b/README.rst @@ -163,6 +163,11 @@ Available formatting constants are:: ``Style.RESET_ALL`` resets foreground, background, and brightness. Colorama will perform this reset automatically on program exit. +These are fairly well supported, but not part of the standard:: + + Fore: LIGHTBLACK_EX, LIGHTRED_EX, LIGHTGREEN_EX, LIGHTYELLOW_EX, LIGHTBLUE_EX, LIGHTMAGENTA_EX, LIGHTCYAN_EX, LIGHTWHITE_EX + Back: LIGHTBLACK_EX, LIGHTRED_EX, LIGHTGREEN_EX, LIGHTYELLOW_EX, LIGHTBLUE_EX, LIGHTMAGENTA_EX, LIGHTCYAN_EX, LIGHTWHITE_EX + Cursor Positioning .................. From 788106f7c4d0e4e18e52964b0271a070843819dd Mon Sep 17 00:00:00 2001 From: Max Tilley <1138504+3tilley@users.noreply.github.com> Date: Thu, 28 Oct 2021 23:56:57 +0100 Subject: [PATCH 2/3] Detached stream fix --- colorama/ansitowin32.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/colorama/ansitowin32.py b/colorama/ansitowin32.py index 6039a05..5286b22 100644 --- a/colorama/ansitowin32.py +++ b/colorama/ansitowin32.py @@ -57,7 +57,9 @@ def closed(self): stream = self.__wrapped try: return stream.closed - except AttributeError: + # AttributeError in the case that the stream doesn't support being closed + # ValueError for the case that the stream has already been detached when atexit runs + except (AttributeError, ValueError): return True From 8a364bd03c68e42e5b7f5a908b2030e50d153b7b Mon Sep 17 00:00:00 2001 From: Max Tilley <1138504+3tilley@users.noreply.github.com> Date: Fri, 29 Oct 2021 19:56:51 +0100 Subject: [PATCH 3/3] Added test --- colorama/tests/ansitowin32_test.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/colorama/tests/ansitowin32_test.py b/colorama/tests/ansitowin32_test.py index bbe99f4..bbc647b 100644 --- a/colorama/tests/ansitowin32_test.py +++ b/colorama/tests/ansitowin32_test.py @@ -1,5 +1,5 @@ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. -from io import StringIO +from io import StringIO, TextIOWrapper from unittest import TestCase, main try: @@ -40,6 +40,17 @@ def testProxyNoContextManager(self): with StreamWrapper(mockStream, mockConverter) as wrapper: wrapper.write('hello') + def test_closed_shouldnt_raise_on_closed_stream(self): + stream = StringIO() + stream.close() + wrapper = StreamWrapper(stream, None) + self.assertEqual(wrapper.closed, True) + + def test_closed_shouldnt_raise_on_detached_stream(self): + stream = TextIOWrapper(StringIO()) + stream.detach() + wrapper = StreamWrapper(stream, None) + self.assertEqual(wrapper.closed, True) class AnsiToWin32Test(TestCase):