-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Fix Enum Cyclic Ref #12617
Fix Enum Cyclic Ref #12617
Conversation
Most information copied from Github issue #11766
A diff of the python standard library implementation vs the replacement implementation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be better for maintainability that replacement__new__ is simply:
if value not in cls.__members__.values():
raise ValueError(f"{value} is not a supported value of {cls}")
return old__new__(value)
Though obviously what you wrote will be useful for a pr against cPython.
But other than the other corrections I and @lukaszgo1 have mentioned, I'd be happy to approve with the code you have here.
Co-authored-by: Michael Curran <[email protected]>
Co-authored-by: Michael Curran <[email protected]>
I'm trying to maintain compatibility with the built-in enum behavior. There are a number of other values that it accepts for various reasons. Using the suggestion would mean that only values for the enum are accepted. |
…rent than the one used for building NVDA (#12835) Fixes regression from #12617. Discovered when working on #12753 as that PR required executing unit tests under various versions of Windows Summary of the issue: It is sometimes useful to execute unit tests under various versions of Windows where it is impractical, or even impossible to have full build environment for NVDA. With current master some tests are failing because when importing COM interfaces comtypes complains about them being created on different version of Windows. Before PR #12617 this worked by chance since our monkey patches for compypes were applied when importing core and it just so happened that core was imported before any COM interface was. Description of how this pull request fixes the issue: Since we have monkey patch which stops comtypes from complaining about typelib being different than COM interface it has been applied to comtypes before tests starts. To avoid copying code of this monkey patch it was necessary to refactor our monkey patches to make each of them into a separate function - that allows us to apply them selectively rather than just all of them during import. Testing strategy: Ensured that unit tests pass under a never version of Windows than the one under which virtual environment for NVDA has been created Ensured that comtypes monkey patches are properly applied for NVDA in particular that core.CallCancelled is raised when appropriate.
… appears to have been fixed upstream (I can still reproduce it under 3.7 but not under 3.11).
…sent in Python 3.11+. Partially reverts nvaccess#12617.
…sent in Python 3.11+. (#15531) Partially reverts #12617. Summary of the issue: #12617 added a patched __new__ to work around a GC cycle in Python 3.7. However, on Python 3.11 and 3.12, this is no longer present. Description of how this pull request fixes the issue: Remove the patched method. Testing strategy: Tested that On Python 3.7, the cyclic ref is present when the patched __new__ is removed. On Python 3.11, no unreachable object error is reported in IA2 documents. On Python 3.12, no unreachable object error is reported in IA2 documents.
…sent in Python 3.11+. (#15531) Partially reverts #12617. Summary of the issue: #12617 added a patched __new__ to work around a GC cycle in Python 3.7. However, on Python 3.11 and 3.12, this is no longer present. Description of how this pull request fixes the issue: Remove the patched method. Testing strategy: Tested that On Python 3.7, the cyclic ref is present when the patched __new__ is removed. On Python 3.11, no unreachable object error is reported in IA2 documents. On Python 3.12, no unreachable object error is reported in IA2 documents.
Link to issue number:
Blocking PR #12500
Summary of the issue:
When creating DescriptionFor enum values, a "ValueError" can be raised.
There is a bug in the Python standard library for enum, causing a cyclic reference.
The exception is referenced by the frame.
The frame is referenced by the traceback.
The traceback is referenced by the exception.
This is detected by NVDA as an unreachable object, logging an error.
Description of how this pull request fixes the issue:
This patches the
enum.Enum.__new__
method to no longer reference the exception from the frame.Testing strategy:
Merged with #12500, ran with sample, ensured no unreachable object log error.
Unit testing this would be difficult, we'd have to install the NVDA
garbageHandler
, this would cause side affects for all tests.These errors are reported to the log of system tests already.
In future we plan for system tests to fail if there are ANY errors in the log, however right now there are several
expected errors in the log on appveyor.
These first need to be resolved.
Additionally, we are in the process of resolving a tricky intermittent failure for system tests.
Once the intermittent failure is resolved we can look to make the tests more strict.
Known issues with pull request:
None
Change log entries:
None
Code Review Checklist: