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

wxGUI: Updated exception handling to fix AttributeNotFound error #4961

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

arohanajit
Copy link
Contributor

An error was highlighted mentioning error module 'wx' has no attribute 'PyDeadObjectError' in the relevant code. This PR is to update the code with other relevant exceptions to replace that

@echoix
Copy link
Member

echoix commented Jan 17, 2025

Indeed, PyDeadObjectError doesn't exist in the Phoenix version of wxPython (version 4 and after), like explained in the migration docs
https://github.com/wxWidgets/Phoenix/blob/169aacfab65096fe4a609732a5ad15be77c63d4f/docs/MigrationGuide.rst#wxpydeadobjecterror----runtimeerror

It is fine since it was decided in #4890 that we can keep support for only version 4 and up.

@arohanajit
Copy link
Contributor Author

Indeed, PyDeadObjectError doesn't exist in the Phoenix version of wxPython (version 4 and after), like explained in the migration docs https://github.com/wxWidgets/Phoenix/blob/169aacfab65096fe4a609732a5ad15be77c63d4f/docs/MigrationGuide.rst#wxpydeadobjecterror----runtimeerror

It is fine since it was decided in #4890 that we can keep support for only version 4 and up.

@petrasovaa mentioned an error while downloading sample project to GRASS database and sent this trace

Traceback (most recent call last):
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 98, in write

self._resize(heigth)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 137, in
_resize

self.out.GetParent().parent.sizer.Fit,
AttributeError
:
'LocationDownloadDialog' object has no attribute 'sizer'
. Did you mean: '
Sizer
'?
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/datacatalog/tree.py", line 1631, in
OnDownloadLocation

self.DownloadLocation(self.selected_grassdb[0])
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/datacatalog/tree.py", line 1619, in
DownloadLocation

grassdatabase, location, mapset =
download_location_interactively(
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/guiutils.py", line 329, in
download_location_interactively

loc_download = LocationDownloadDialog(parent=guiparent,
database=grassdb)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 447, in
__init__

self.panel = LocationDownloadPanel(parent=self,
database=database)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 260, in
__init__

self.CheckItem(self.locations[default])
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 383, in
CheckItem

self._warning(
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 407, in
_warning

sys.stdout.write(text)
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-
gnu/gui/wxpython/startup/locdownload.py", line 99, in write

except wx.PyDeadObjectError:
AttributeError
:
module 'wx' has no attribute 'PyDeadObjectError'

@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python labels Jan 17, 2025
@echoix
Copy link
Member

echoix commented Jan 17, 2025

There's another PyDeadObject error in

except (wx.PyDeadObjectError, KeyError):

Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

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

This PR is fine by itself. While it won't fix the root issue of the stack trace shared here, as it doesn't address the parent.sizer not found (maybe Sizer?), it does fix one of the errors occurring during exception handling.

So two things to do somewhere else (if wanted): fix the sizer not found causing the issue, and search for other wx.PyDeadObjectError in the repo. I found 2 total, this fixes one.

@echoix echoix merged commit 2c9b614 into OSGeo:main Jan 18, 2025
27 checks passed
@petrasovaa
Copy link
Contributor

There's another PyDeadObject error in

except (wx.PyDeadObjectError, KeyError):

@arohanajit could you look into that as well?

@github-actions github-actions bot added this to the 8.5.0 milestone Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants