Skip to content

Protect __new__ from method rename - #974

Open
cloudgpuapp wants to merge 1 commit into
python-rope:masterfrom
cloudgpuapp:fix/protect-constructor-rename
Open

cloudgpuapp wants to merge 1 commit into
python-rope:masterfrom
cloudgpuapp:fix/protect-constructor-rename

Conversation

@cloudgpuapp

Copy link
Copy Markdown

Renaming __new__ as an ordinary method changes what happens when Python constructs the class. In the report's singleton example, two calls stop returning the same object after the rename. Reject method renames into or out of __new__, while retaining ordinary rename behavior for a module-level name.

Related to #832.

The two regression tests fail before the change and pass after it. I reproduced the singleton behavior on the baseline. On the local Python 3.12 build, one unrelated SQLite test fixture errors on both the baseline and the patch because _sqlite3 is built in. With that test excluded, 2,178 tests passed, 11 skipped, and 5 xfailed.

AI assistance was used to prepare and test this change.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.45%. Comparing base (ff8a306) to head (a02ac4e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #974   +/-   ##
=======================================
  Coverage   95.44%   95.45%           
=======================================
  Files         134      134           
  Lines       26910    26924   +14     
=======================================
+ Hits        25685    25699   +14     
  Misses       1225     1225           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant