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

wrong sys.exit argument #66

Open
dlancer opened this issue May 26, 2017 · 6 comments
Open

wrong sys.exit argument #66

dlancer opened this issue May 26, 2017 · 6 comments

Comments

@dlancer
Copy link

dlancer commented May 26, 2017

line 118:
sys.exit("""DEBUG is False but no SECRET_KEY is set in the environment - either it has been hardcoded (bad) or not set at all (bad) - exit()ing for safety reasons""")
Argument should be integer value, so if error message is required, we should raise exception here.

@doismellburning
Copy link
Owner

Thanks! So, reading help():

>>> help(sys.exit)
Help on built-in function exit in module sys:

exit(...)
    exit([status])
    
    Exit the interpreter by raising SystemExit(status).
    If the status is omitted or None, it defaults to zero (i.e., success).
    If the status is an integer, it will be used as the system exit status.
    If it is another kind of object, it will be printed and the system
    exit status will be one (i.e., failure).

the usage seems legit as per the last case. Where're you getting

Argument should be integer value

from?

Cheers

@dlancer
Copy link
Author

dlancer commented May 27, 2017

Oh, sorry. My problem related to pycharm pydevconsole. pydevconsole use os._exit() when handle exception, and os._exit() required integer value. Looks like your package can't work within pydevconsole when DEBUG not defined in the ENV or set to false and SECRET_KEY not defined.

@doismellburning
Copy link
Owner

No worries! That sounds like it might be a bug their side then? If you could file an issue and link it here I'd love to follow along please :)

Thanks again!

@doismellburning
Copy link
Owner

I guess more generally it might be more friendly to throw an exception - would that be a helpful workaround for you? (I don't really understand the PyCharm issue you're having)

@dlancer
Copy link
Author

dlancer commented May 27, 2017

Yes, that pydev bug. pydev interpreter override exit function. See do_exit function.
So when you pass string to sys.exit it throw TypeError exception.

@jdelic
Copy link
Collaborator

jdelic commented May 27, 2017

@doismellburning throwing an exception is probably more friendly. It's also less opinionated, but I'm pretty sure it's the right way to go. Since the calling code might catch the exception, we should make it so that d12f doesn't load half of the settings before raising the exception. I.e. the check for SECRET_KEY should probably be the first thing that happens in factorise().

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

No branches or pull requests

3 participants