Skip to content

speech.getControlFieldSpeech: avoid exception which stops a line from being read.#18130

Merged
SaschaCowley merged 2 commits into
masterfrom
getControlFieldspeechError
May 20, 2025
Merged

speech.getControlFieldSpeech: avoid exception which stops a line from being read.#18130
SaschaCowley merged 2 commits into
masterfrom
getControlFieldspeechError

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

None

Summary of the issue:

When trying to read some lines in Chomium, such as a list item with a checkbox at the start, the following traceback is produced and the line is not read:

ERROR - scriptHandler.executeScript (07:47:48.801) - MainThread (22912):
error executing script: <bound method EditableText.script_caret_moveByLine of <NVDAObjects.Dynamic_EditorEditableTextWithAutoSelectDetectionEditorIa2WebIAccessible object at 0x05DBB2F0>> with gesture 'down arrow'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 300, in executeScript
  File "editableText.pyc", line 268, in script_caret_moveByLine
  File "editableText.pyc", line 192, in _caretMovementScriptHelper
  File "NVDAObjects\behaviors.pyc", line 254, in _caretScriptPostMovedHelper
  File "editableText.pyc", line 178, in _caretScriptPostMovedHelper
  File "speech\speech.pyc", line 1483, in speakTextInfo
  File "speech\types.pyc", line 47, in __iter__
  File "speech\speech.pyc", line 1678, in getTextInfoSpeech
AttributeError: 'FieldCommand' object has no attribute 'isspace'

The code assumes the next field in the list is a string, but in this case it is a controlEnd (from a checkbox with no content inside).

Description of user facing changes

NVDA no longer refuses to read a line in Google Chrome / Edge where a list item starts with a checkbox, such as within a check list in Microsoft Loop.

Description of development approach

Ensure the field is an str before calling isspace or strip.

Testing strategy:

In Google Chrome, read the line produced by:

<div contenteditable="true">
<p>Start</p>
<ul style="list-style-type: none">
<li><input contenteditable="false" type="checkbox" /> Item 1</li>
</ul>
<p>end</p>
</div>

Known issues with pull request:

In this case, the specific code here that is meant to speak the string as a single character will not run. But this is a very rare case, and it is arguable that the browser content and or control fields may be wrong here anyway. At least we will still speak the line and not cause an exception.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@michaelDCurran michaelDCurran marked this pull request as ready for review May 19, 2025 22:09
@michaelDCurran michaelDCurran requested a review from a team as a code owner May 19, 2025 22:09
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label May 20, 2025
@SaschaCowley SaschaCowley merged commit 533ee86 into master May 20, 2025
15 checks passed
@SaschaCowley SaschaCowley deleted the getControlFieldspeechError branch May 20, 2025 01:39
@github-actions github-actions Bot added this to the 2025.2 milestone May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants