Skip to content

Fix adobe reader int/str to NoneType comparisons as well as other identified cases - #9881

Merged
feerrenrut merged 6 commits into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:fixAdobe
Jul 11, 2019
Merged

Fix adobe reader int/str to NoneType comparisons as well as other identified cases#9881
feerrenrut merged 6 commits into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:fixAdobe

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #9859

Summary of the issue:

Reading documents in Adobe Reader raises a TypeError

Description of how this pull request fixes the issue:

Fixed this int to NoneType comparison, identified some others while at it. The following commands where used:

  • git grep "ID > 0"
  • git grep "ID < 0"
  • git grep "ID>0"
  • git grep "ID<0"

I did not touch comparisons for IAccessibleChildID, as I'm 99% sure that this will never be None.

Testing performed:

T.b.d. @lukaszgo1 would you be able to test your case with Acrobat?

Known issues with pull request:

one

Change log entry:

None

@LeonarddeR
LeonarddeR requested a review from feerrenrut July 5, 2019 19:41
@zstanecic

zstanecic commented Jul 5, 2019 via email

Copy link
Copy Markdown
Contributor

@lukaszgo1

lukaszgo1 commented Jul 5, 2019

Copy link
Copy Markdown
Contributor

This specific bug has been fixed. However after pressing CTRL+Page Down error sound is played with each key press, NVDA needs to be killed, and the following is in the log multiple times:

ERROR - eventHandler.executeEvent (21:53:43.938):
error executing event: gainFocus on <NVDAObjects.IAccessible.adobeAcrobat.Document object at 0x06FA8D30> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 150, in executeEvent
  File "eventHandler.pyc", line 163, in doPreGainFocus
  File "api.pyc", line 117, in setFocusObject
  File "treeInterceptorHandler.pyc", line 57, in cleanup
  File "baseObject.pyc", line 30, in __get__
  File "virtualBuffers\adobeAcrobat.pyc", line 99, in _get_isAlive
  File "baseObject.pyc", line 30, in __get__
  File "NVDAObjects\IAccessible\adobeAcrobat.pyc", line 86, in _get_role
  File "NVDAObjects\IAccessible\adobeAcrobat.pyc", line 42, in normalizeStdName
TypeError: '<=' not supported between instances of 'str' and 'NoneType'

@LeonarddeR

LeonarddeR commented Jul 5, 2019 via email

Copy link
Copy Markdown
Collaborator Author

@LeonarddeR LeonarddeR changed the title Fix adobe reader int to NoneType comparison as well as other identified cases Fix adobe reader int/str to NoneType comparisons as well as other identified cases Jul 6, 2019
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

Thanks for reporting again @lukaszgo1. Could you have another try?

@lukaszgo1

lukaszgo1 commented Jul 6, 2019

Copy link
Copy Markdown
Contributor

This time error is as follows:

ERROR - eventHandler.executeEvent (12:14:52.955):
error executing event: gainFocus on <NVDAObjects.IAccessible.adobeAcrobat.Document object at 0x04E46DF0> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 150, in executeEvent
  File "eventHandler.pyc", line 163, in doPreGainFocus
  File "api.pyc", line 89, in setFocusObject
  File "NVDAObjects\__init__.pyc", line 318, in __eq__
  File "NVDAObjects\IAccessible\adobeAcrobat.pyc", line 107, in _isEqual
  File "NVDAObjects\IAccessible\__init__.pyc", line 738, in _isEqual
  File "baseObject.pyc", line 46, in __get__
  File "baseObject.pyc", line 149, in _getPropertyViaCache
  File "NVDAObjects\IAccessible\__init__.pyc", line 744, in _get_name
  File "baseObject.pyc", line 30, in __get__
  File "NVDAObjects\IAccessible\adobeAcrobat.pyc", line 85, in _get_role
AttributeError: 'NoneType' object has no attribute 'GetStdName'

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

Ugh, my bad. Just did another push.

@lukaszgo1

Copy link
Copy Markdown
Contributor

Now it works. Thanks @LeonarddeR

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, but a question about logging the caught exception.

try:
return normalizeStdName(self.pdDomNode.GetStdName())[0]
except (AttributeError, LookupError, COMError):
except (AttributeError, LookupError, COMError, TypeError):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that it will hide any other TypeErrors. I think this should instead log at Debug / Debug warning.

return normalizeStdName(self.pdDomNode.GetStdName())[0]
except (AttributeError, LookupError, COMError, TypeError):
pass
log.debugWarning("Could not get role for AcrobatNode using normalizeStdName", exc_info=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be noisy? Are regular LookupError or AttributeError exceptions expected?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point. Do you want me to only log this for type errors? I'd say that this could still be noisy though. May be I should avoid raising the typeerror altogether.

@feerrenrut
feerrenrut merged commit d28b527 into nvaccess:threshold_py3_staging Jul 11, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jul 11, 2019
@LeonarddeR
LeonarddeR deleted the fixAdobe branch August 23, 2025 06:27
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.

5 participants