fix: stop reading deprecated braille module aliases - #9
Closed
serrebidev wants to merge 1 commit into
Closed
Conversation
NVDA moved the regions, buffers, handler, labels, constants, display helpers and the braille input handler out of the flat `braille` / `brailleInput` namespaces into sub-modules, leaving deprecated aliases behind. Every read of an alias goes through the `utils._deprecate` module `__getattr__`, which logs a WARNING plus a full stack trace. The add-on reads those names 167 times across 12 modules, so start-up alone emits about 50 such warnings and more follow on braille updates. Add `brailleCompat`, which imports each symbol from its real home and falls back to the flat modules on builds that predate the split, so the add-on keeps working down to the manifest minimum of 2025.3.3. Stable objects (classes, functions, constants, label mappings) are re-exported directly; two module aliases are kept because they cannot be captured at import time: * `brailleInput`, since `handler` is rebound by braille initialise/terminate; * `regionsProperties`, since patches.py assigns the field-formatting functions back. Also fixes `LOUIS_DOTS_IO_START`, which patches.py reads on every braille keyboard translation. NVDA's deprecation table says it moved to `braille.input.constants`, but that module never defines it -- the value now lives in `louisHelper._DOTS_IO_START`. Reading the documented alias raises AttributeError on current builds, so `brailleCompat` resolves it from louisHelper, then the pre-split public name, then the liblouis literal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AUFZd6deUGuMmJYnLAvXxL
Author
|
Closing as a duplicate — I missed that #8 already covers this, and covers it better. #8 resolves the same symbols through a Please review #8 instead. Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NVDA split the flat
brailleandbrailleInputnamespaces into sub-modules and left deprecated aliases behind. Every read of an alias goes through theutils._deprecatemodule__getattr__, which logs a WARNING and a full stack trace.Braille Essentials reads those names 167 times across 12 modules, so start-up alone produces around 50 of these, and more arrive on braille updates:
Observed on NVDA alpha-57522 (Python 3.13) with add-on 26.08.
The names involved:
Region,TextRegion,TextInfoRegion,NVDAObjectRegion,NVDAObjectHasUsefulText,BrailleBuffer,BrailleHandler,getControlFieldBraille,getFormatFieldBraille,getPropertiesBraille,getFocusRegions,getFocusContextRegions,getDisplayList,roleLabels,positiveStateLabels,negativeStateLabels,landmarkLabels,TEXT_SEPARATOR,INPUT_START_IND,INPUT_END_IND,SELECTION_SHAPE,brailleInput.handler,brailleInput.BrailleInputHandler.Fix
Add
globalPlugins/brailleEssentials/brailleCompat.py, which imports each symbol from its real home and falls back to the flat modules when the sub-modules are absent — so the add-on still runs on the manifest minimum of 2025.3.3, where these names are neither moved nor deprecated.Call sites become
bc.TextInfoRegioninstead ofbraille.TextInfoRegion, which is marginally shorter than what it replaces; no line goes over the configured 110-column limit.Stable objects are re-exported directly. Two module aliases are kept, because they can't be captured at import time:
bc.brailleInput—handleris rebound by braille initialise/terminate, so it must be read through the module.bc.regionsProperties—patches.pyassigns the field-formatting functions back, so it needs the module object.Second bug:
LOUIS_DOTS_IO_STARTraises AttributeErrorpatches.pyreadsbrailleInput.LOUIS_DOTS_IO_STARTin itsBrailleInputHandler._translatereplacement, which runs on every braille keyboard translation:NVDA's deprecation table declares that name moved to
braille.input.constants, but that module never defines it — I checked every module inlibrary.zip, and the value now lives only inlouisHelper._DOTS_IO_START. So the documented alias resolves to nothing and raisesAttributeErroron current builds.brailleCompatresolves it fromlouisHelper._DOTS_IO_START, then the pre-split public name, then the liblouis literal0x8000.Verification
bc.*accesses was resolved against the actual symbol tables in NVDA'slibrary.zip— 0 unresolved.braille.*/brailleInput.*deprecated reads remain;braille.handleris untouched, since it is not deprecated.Not addressed here
patches.pyreplaces the field-formatting functions by assigning to thebraillemodule:On current NVDA
braille/regions/textInfo.pybindsgetControlFieldBrailleinto its own module globals at import, so writing the name onto thebraillepackage no longer reaches the code that calls it — these three patches appear to be inert on recent builds, independently of this PR. This change retargets the assignment toregionsPropertiesso save and restore stay symmetric and the deprecated alias reflects the patch, but making the patch effective again would mean assigning into the consumer modules, which is a behaviour change I did not want to make blind. Flagging it for you rather than guessing.