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

modalSession exits prematurely #3

Open
jeremygray opened this issue Dec 26, 2014 · 4 comments
Open

modalSession exits prematurely #3

jeremygray opened this issue Dec 26, 2014 · 4 comments

Comments

@jeremygray
Copy link
Contributor

I know that Python 3 is the intended version to use, and testing is done on 3.4. Things seems to work with Python 2.7.8, and it would be nice if they did. But I typically get the warning / error message below.

>>> from easygui_qt.easygui_qt import *
>>> get_int()
2014-12-26 11:04:26.769 python[93886:303] modalSession has been exited prematurely - check for a reentrant call to endModalSession:
1

I get the same thing when calling that code as a script. Any ideas? I see the with_app decorator but just looking at it can't follow the logic of the inner _decorator.

@aroberge
Copy link
Owner

I'm downloading/installing Python 2 as a conda environment so that I can run the tests and see if I can fix this.

@aroberge
Copy link
Owner

I can not reproduce this bug.

Python 2.7.9 |Continuum Analytics, Inc.| (default, Dec 18 2014, 16:57:52) [MSC v.1500 64 bit (AMD64)] on win32
...
>>> from easygui_qt.easygui_qt import *
>>> get_list_of_choices()
[PyQt4.QtCore.QString(u'Item 3'), PyQt4.QtCore.QString(u'Item 7')]
>>> get_int()
3
>>> get_int()   # pressing cancel
>>> get_int()   # closing the window
>>>

@aroberge
Copy link
Owner

Explanation about the inner decorator mentioned when this issue was first open. The logic of the inner decorator can be greatly simplified if one does not call set_locale or select_language; Without these two, the code for the inner decorator would simply be:

def _decorator(*args, **kwargs):
    app = SimpleApp()
    response = func(*args, **kwargs)
    app.quit()
    return response

set_locale() and select_language() require that an app instance be passed as one
of the parameters so that language/locale choices can be recorded. (I'm thinking of doing this differently in the future so that this approach will no longer be needed.)

So, the simple version of the inner decorator above changes so as to first add "app" as one of the kwargs and try running the function; if "app" was not a valid keyword argument in the first place, and exception is caught. With Python 3.3+, there is a way to find out if "app" was indeed an expected keyword argument. For earlier version, we just assume that the exception was raised for this reason; for Python 3.3, we examine to see if the unexpected "app" was the reason for the exception: if it looks like it, we just run the program again, otherwise we raise the exception.

@jeremygray
Copy link
Contributor Author

This issue might be mac-specific: https://bugreports.qt-project.org/browse/QTBUG-37699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants