Skip to content
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

Handle COMError when fetching table header cells in Word documents #7777

Merged
merged 1 commit into from Dec 8, 2017

Conversation

bramd
Copy link
Contributor

@bramd bramd commented Nov 18, 2017

Link to issue number:

Fixes #6827

Summary of the issue:

Sometimes there is a reference to a COM object in _curHeaderCellTrackerTable, but the object throws a COMError on accessing one of it's properties, such as range.
Especially in Outlook this problem occurs if an email containing a table has been opened and the user closes that email and opens another email containing tables.
The unhandled COMError prevented the user from reading the email/document.

Description of how this pull request fixes the issue:

Handle the COMError.

Testing performed:

Tested on Outlook 2016.

Known issues with pull request:

None.

Change log entry:

tableRangesEqual=tableRange.isEqual(self._curHeaderCellTrackerTable.range)
except (COMError, AttributeError):
tableRangesEqual=False
if not self._curHeaderCellTrackerTable or not tableRangesEqual:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I belief the if not self._curHeaderCellTrackerTable will alreade be dealt with if the lines above raise an AttributeError. Honestly, I'd check for if not self._curHeaderCellTrackerTable before executing the try statement, which looks somewhat cleaner. I leave it up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the first part of this or statement is unneeded. I removed it and left the try/except intact. Removing the except AttributeError and solving this in an if statement would introduce another variable to hold state, or a level of nested if statements. I think having all the logic in a single try/except makes the code easier to read.

michaelDCurran added a commit that referenced this pull request Nov 23, 2017
@michaelDCurran michaelDCurran merged commit de20ef1 into nvaccess:master Dec 8, 2017
@nvaccessAuto nvaccessAuto added this to the 2018.1 milestone Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to read tables in Outlook 2016
4 participants