enthought / enthought/traitsui

"import traitsui.api" can raise a SystemExit exception rather than an ImportError.

Open
#168 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Importing `traitsui.api` calls `wx.App()` (`traitsui/wx/toolkit.py:35`) which can raise a `SystemExit` exception, for example, if running on Mac OS X with a non-framework build:

``` bash
$ python -c "import traitsui.api"
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
```

This can mess things up like building documentation with Sphinx, or running automated tests like nosetest which will gracefull handle an `ImportError` exception, but not a `SystemExit`. A simple solution would be to wrap these module-level calls in a block that converts the exception:

``` python
try:
...
wx.App()
except SystemExit, err:
raise ImportError(err)
```

for example.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.