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

Stomp messes with sys.path and breaks stuff #23

Closed
lietu opened this issue Nov 26, 2014 · 2 comments
Closed

Stomp messes with sys.path and breaks stuff #23

lietu opened this issue Nov 26, 2014 · 2 comments

Comments

@lietu
Copy link

lietu commented Nov 26, 2014

I have a package utils in my project, probably not a very unique name I'm sure.

If I import stomp and then later try and import any code from my utils package, I get a mystical ImportError: No module named time.

After considerable effort I finally backtracked this error to stomp.

Stomp breaks my code because it modifies sys.path (which is bad enough as it is, for a library), by prepending (even worse) it's own path to it. This causes my previously ok code to break.

This works:

from utils.time import my_util_func

This does not:

import stomp
from utils.time import my_util_func

After importing stomp the utils actually resolves to utils.py inside stomp. I assume this same error will occur if anyone will try and use the names: adapter, backward2, backward3, backward, colors, connect, constants, exception, listener, protocol, or transport.

Most of those names don't seem that unique.

Worse yet, since the path change is done globally, it can break any seemingly unrelated code that is just executed after the import.

The issue is caused by these lines:
https://github.com/jasonrbriggs/stomp.py/blob/master/stomp/__init__.py#L12-L14

I can fix this myself by moving all of my code under another package, "myproject", and then use from myproject.utils.time import ..., but I wouldn't have to worry about this if stomp wasn't changing the path.

@jasonrbriggs
Copy link
Owner

Good point. No idea why that's (still) there. Suspect it was because of some issue in the distant past. However, if I remove it, other than having to reference stomp. everywhere, instead of just , doesn't look like there's any other negative side effects. So will fix in the next version.

@jasonrbriggs
Copy link
Owner

Fixed in 4.0.13

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