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

Python style config files try pickling module imports? #556

Closed
bitprophet opened this Issue Jul 13, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@bitprophet
Member

bitprophet commented Jul 13, 2018

I could swear we already ran into and fixed this but I cannot find another issue for it, and the only applicable test I can find specifically calls out builtins and not other imported modules.

Symptomatic case is fabric/fabric#1823 where a user is (unintentionally) loading a tasks module as a runtime config file. The presence of the os module then causes an explosion as modules cannot be pickled, which copy.copy does internally (ugh).

@bitprophet

This comment has been minimized.

Member

bitprophet commented Aug 1, 2018

Writing test for this now; the obvious fix is to raise a specifically phrased and subclassed exception so users know what's going on instead of getting a TypeError about pickling, which is just confusing.

Suppose we could instead try to detect this and strip, as we do for builtins, but it feels more fragile than with builtins, and would lead to silent problems for advanced users attempting to assign modules to config values on purpose for whatever reason.

I've already gone back and forth on this a few times internally (and between the two repos) so I'm definitely past the point of caring about corner cases. Will set it up to just raise a useful error instead of TypeError, and that's that for now. Can iterate later if anybody gets mad.

@bitprophet

This comment has been minimized.

Member

bitprophet commented Aug 1, 2018

Fix committed and pushed!

@bitprophet bitprophet closed this Aug 1, 2018

bitprophet added a commit that referenced this issue Aug 1, 2018

Test and solution re #556
Ironically, this DOES make use of pytest's version of raises()

bitprophet added a commit that referenced this issue Aug 1, 2018

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