-
Notifications
You must be signed in to change notification settings - Fork 62
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
Reset directory on failed file interpretation #1770
Conversation
Co-authored-by: Ryan Scott <[email protected]>
The implementation here looks good, I would just make a general observation that in libraries it's not usually advisable to make process-global changes like changing the current working directory because it can have deleterious effects on other threads or expectations of the application using the library. At present this interpreter block probably represents the main thread of |
This should, for the record, finally fix a bug mentioned in #1341. |
Noted and agreed. @kquick and I spoke and agreed that this PR is still appropriate to merge, but that recording this issue would be wise, so I've opened #1791 to surface it more broadly. |
When
include
ing a script in a different directory, failure to load the file will leave the interpreter's working directory as the directory containing that script. This fixes that by catching any exceptions that are thrown during file load, resetting the dirctory, and rethrowing.Once #1769 is merged, this behavior should be amenable to automated testing. As it is, the directory is reset on interpreter exit, so neither the failure mode nor its resolution can be encoded in a test script.