Skip to content

Conversation

@KanaparthySaiSreekar
Copy link

@KanaparthySaiSreekar KanaparthySaiSreekar commented Nov 12, 2025

The C implementation of RLock (_thread.RLock) is now always available on all supported platforms, making the Python fallback implementation and the factory function unnecessary.

Changes:

  • Remove _RLock class (Python implementation) from Lib/threading.py
  • Replace RLock() factory function with direct alias to _thread.RLock
  • Remove _PyRLock and _CRLock aliases
  • Update tests to use threading.RLock instead of _PyRLock or _CRLock
  • Remove PyRLockTests class and merge CRLockTests into RLockTests
  • Update test_free_threading/test_monitoring.py to use RLock

This simplification removes ~150 lines of dead code while maintaining full backward compatibility, as threading.RLock remains callable and returns the same C-based RLock instances as before.

The C implementation of RLock (_thread.RLock) is now always available
on all supported platforms, making the Python fallback implementation
and the factory function unnecessary.

Changes:
- Remove _RLock class (Python implementation) from Lib/threading.py
- Replace RLock() factory function with direct alias to _thread.RLock
- Remove _PyRLock and _CRLock aliases
- Update tests to use threading.RLock instead of _PyRLock or _CRLock
- Remove PyRLockTests class and merge CRLockTests into RLockTests
- Update test_free_threading/test_monitoring.py to use RLock

This simplification removes ~150 lines of dead code while maintaining
full backward compatibility, as threading.RLock remains callable and
returns the same C-based RLock instances as before.
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@bedevere-app
Copy link

bedevere-app bot commented Nov 12, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland
Copy link
Member

StanFromIreland commented Nov 12, 2025

Closing, seeing the CI this is pretty clearly not dead code. Removing public functions needs deprecation cycles too. Please open a discussion first.

@StanFromIreland
Copy link
Member

Ah, there is indeed already an issue for this. cc @larryhastings

@bedevere-app
Copy link

bedevere-app bot commented Nov 12, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland StanFromIreland changed the title Simplify threading.RLock implementation by removing dead code gh-141460: Simplify threading.RLock implementation by removing dead code Nov 12, 2025
@StanFromIreland StanFromIreland marked this pull request as draft November 12, 2025 16:50
@zware
Copy link
Member

zware commented Nov 12, 2025

Closing anyway; Claude is never going to sign the CLA. See also the devguide chapter on generative AI.

@zware zware closed this Nov 12, 2025
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