-
Notifications
You must be signed in to change notification settings - Fork 575
CASSPYTHON-18: removed obsolete check for python version > 3.7+ #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1424,26 +1424,26 @@ def _create_thread_pool_executor(self, **kwargs): | |
| :return: A ThreadPoolExecutor instance. | ||
| """ | ||
| tpe_class = ThreadPoolExecutor | ||
| if sys.version_info[0] >= 3 and sys.version_info[1] >= 7: | ||
| try: | ||
| from cassandra.io.eventletreactor import EventletConnection | ||
| is_eventlet = issubclass(self.connection_class, EventletConnection) | ||
| except: | ||
| # Eventlet is not available or can't be detected | ||
| return tpe_class(**kwargs) | ||
|
|
||
| if is_eventlet: | ||
| try: | ||
| from futurist import GreenThreadPoolExecutor | ||
| tpe_class = GreenThreadPoolExecutor | ||
| except ImportError: | ||
| # futurist is not available | ||
| raise ImportError( | ||
| ("Python 3.7+ and Eventlet cause the `concurrent.futures.ThreadPoolExecutor` " | ||
| "to hang indefinitely. If you want to use the Eventlet reactor, you " | ||
| "need to install the `futurist` package to allow the driver to use " | ||
| "the GreenThreadPoolExecutor. See https://github.com/eventlet/eventlet/issues/508 " | ||
| "for more details.")) | ||
| try: | ||
| from cassandra.io.eventletreactor import EventletConnection | ||
| is_eventlet = issubclass(self.connection_class, EventletConnection) | ||
| except ImportError: | ||
| # Eventlet is not available or can't be detected | ||
| return tpe_class(**kwargs) | ||
|
|
||
| if is_eventlet: | ||
| try: | ||
| from futurist import GreenThreadPoolExecutor | ||
| tpe_class = GreenThreadPoolExecutor | ||
| except ImportError: | ||
| # futurist is not available | ||
| raise ImportError( | ||
| ("Python 3.7+ and Eventlet cause the `concurrent.futures.ThreadPoolExecutor` " | ||
| "to hang indefinitely. If you want to use the Eventlet reactor, you " | ||
| "need to install the `futurist` package to allow the driver to use " | ||
| "the GreenThreadPoolExecutor. See https://github.com/eventlet/eventlet/issues/508 " | ||
| "for more details.")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should perhaps change this usage to be more consistent with the current state of things on two fronts:
Maybe something more like the following?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, I'm not even 💯 sure we need this at all. It looks as if eventlet fixed this issue here and that this code was released in version 0.26.0. That version went out in July of 2020 so it's hard to imagine anyone getting an old enough version of eventlet for this to actually be a problem if they did a requirements install today. |
||
|
|
||
| return tpe_class(**kwargs) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1087,14 +1087,6 @@ def test_export_keyspace_schema_udts(self): | |
| Test udt exports | ||
| """ | ||
|
|
||
| if PROTOCOL_VERSION < 3: | ||
| raise unittest.SkipTest( | ||
| "Protocol 3.0+ is required for UDT change events, currently testing against %r" | ||
| % (PROTOCOL_VERSION,)) | ||
|
|
||
| if sys.version_info[0:2] != (2, 7): | ||
| raise unittest.SkipTest('This test compares static strings generated from dict items, which may change orders. Test with 2.7.') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is certainly possible, but if we find ourselves in a situation where our output changes because a particular version is handling dictionary keys differently I would much rather know that (by way of a failing test) than silently skipping the test in question. |
||
|
|
||
| cluster = TestCluster() | ||
| session = cluster.connect() | ||
|
|
||
|
|
@@ -1591,7 +1583,7 @@ def test_function_no_parameters(self): | |
|
|
||
| with self.VerifiedFunction(self, **kwargs) as vf: | ||
| fn_meta = self.keyspace_function_meta[vf.signature] | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*%s\(\) .*" % kwargs['name']) | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*%s() .*" % kwargs['name']) | ||
|
|
||
| def test_functions_follow_keyspace_alter(self): | ||
| """ | ||
|
|
@@ -1639,12 +1631,12 @@ def test_function_cql_called_on_null(self): | |
| kwargs['called_on_null_input'] = True | ||
| with self.VerifiedFunction(self, **kwargs) as vf: | ||
| fn_meta = self.keyspace_function_meta[vf.signature] | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*") | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*) CALLED ON NULL INPUT RETURNS .*") | ||
|
|
||
| kwargs['called_on_null_input'] = False | ||
| with self.VerifiedFunction(self, **kwargs) as vf: | ||
| fn_meta = self.keyspace_function_meta[vf.signature] | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*") | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*) RETURNS NULL ON NULL INPUT RETURNS .*") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Three changes above were minor fixes to address some deprecation warnings noted when running the test via Python 3.10: |
||
|
|
||
|
|
||
| class AggregateMetadata(FunctionTest): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,12 +24,8 @@ | |
|
|
||
| from unittest import TestCase | ||
|
|
||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| NAMEDTUPLE_CREATION_BUG = sys.version_info >= (3,) and sys.version_info < (3, 7) | ||
|
|
||
| class TestNamedTupleFactory(TestCase): | ||
|
|
||
| long_colnames, long_rows = ( | ||
|
|
@@ -49,37 +45,16 @@ class TestNamedTupleFactory(TestCase): | |
|
|
||
| def test_creation_warning_on_long_column_list(self): | ||
| """ | ||
| Reproduces the failure described in PYTHON-893 | ||
|
|
||
| @since 3.15 | ||
| @jira_ticket PYTHON-893 | ||
| @expected_result creation fails on Python > 3 and < 3.7 | ||
|
|
||
| @test_category row_factory | ||
| Test for a regression in PYTHON-893. Shouldn't be an issue with currently | ||
| supported versions since the underlying issue was fixed in Python 3.7 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The underlying problem is fixed in Python 3.7 (see PYTHON-893 for more on that point) so we should no longer have any case in which NAMEDTUPLE_CREATION_BUG eval's to true. |
||
| """ | ||
| if not NAMEDTUPLE_CREATION_BUG: | ||
| named_tuple_factory(self.long_colnames, self.long_rows) | ||
| return | ||
|
|
||
| with warnings.catch_warnings(record=True) as w: | ||
| rows = named_tuple_factory(self.long_colnames, self.long_rows) | ||
| self.assertEqual(len(w), 1) | ||
| warning = w[0] | ||
| self.assertIn('pseudo_namedtuple_factory', str(warning)) | ||
| self.assertIn('3.7', str(warning)) | ||
|
|
||
| for r in rows: | ||
| self.assertEqual(r.col0, self.long_rows[0][0]) | ||
| named_tuple_factory(self.long_colnames, self.long_rows) | ||
|
|
||
| def test_creation_no_warning_on_short_column_list(self): | ||
| """ | ||
| Tests that normal namedtuple row creation still works after PYTHON-893 fix | ||
|
|
||
| @since 3.15 | ||
| @jira_ticket PYTHON-893 | ||
| @expected_result creates namedtuple-based Rows | ||
|
|
||
| @test_category row_factory | ||
| Tests that normal namedtuple row creation still works after PYTHON-893 fix. | ||
| Shouldn't be an issue with currently supported versions since the underlying | ||
| issue was fixed in Python 3.7 | ||
| """ | ||
| with warnings.catch_warnings(record=True) as w: | ||
| rows = named_tuple_factory(self.short_colnames, self.short_rows) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.