Skip to content

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Jan 29, 2026

Summary

Remove Python 2 compatibility shims that are no longer needed since the driver requires Python 3.10+.

Changes

  • Remove try/except for Queue vs queue → use queue directly
  • Remove try/except for __builtin__ vs builtins → use builtins directly
  • Remove try/except for thread vs _thread → use _thread directly
  • Remove try/except for futures vs concurrent.futures → use concurrent.futures directly
  • Remove try/except for unittest2 vs unittest → use unittest directly
  • Replace deprecated imp.reload with importlib.reload

Files changed

  • tests/unit/io/eventlet_utils.py
  • tests/integration/long/test_large_data.py
  • tests/integration/standard/test_shard_aware.py
  • tests/integration/standard/test_use_keyspace.py
  • tests/unit/test_protocol_features.py
  • tests/unit/test_shard_aware.py

Test plan

  • Unit tests pass locally (pytest tests/unit/test_protocol_features.py tests/unit/test_shard_aware.py)
  • CI tests pass

The driver requires Python 3.10+ so these compatibility shims are no longer needed:

- Remove try/except for Queue vs queue (use queue directly)
- Remove try/except for __builtin__ vs builtins (use builtins directly)
- Remove try/except for thread vs _thread (use _thread directly)
- Remove try/except for futures vs concurrent.futures (use concurrent.futures directly)
- Remove try/except for unittest2 vs unittest (use unittest directly)
- Replace deprecated imp.reload with importlib.reload
Copy link

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! In the future we could also remove WeakSet from utils.py, I see that std now has it: https://docs.python.org/3/library/weakref.html#weakref.WeakSet ,

@dkropachev dkropachev merged commit 237d269 into master Jan 30, 2026
25 checks passed
@dkropachev dkropachev deleted the cleanup/remove-python2-legacy-imports branch January 30, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants