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

hooks breaks from x import * (0.15.2, Python 2) #238

Open
itamarst opened this issue Sep 8, 2016 · 2 comments
Open

hooks breaks from x import * (0.15.2, Python 2) #238

itamarst opened this issue Sep 8, 2016 · 2 comments

Comments

@itamarst
Copy link

itamarst commented Sep 8, 2016

from future.standard_library import hooks

with hooks():
    from urllib.parse import urlparse, urlencode
    from urllib.request import urlopen, Request
    from urllib.error import HTTPError

This code made from mymodule import * fail. That is, it runs, but nothing gets imported into the module running that, as if mymodule is empty. Later calls to from mymodule import *, e.g. in a debuger, do work. My guess is the issue is something to do with copying and then re-inserting stuff from sys.modules that the install_hooks-related code does; probably modules are being copied at the wrong time, when they're still half-empty or something.

@itamarst itamarst changed the title hooks breaks from x import * hooks breaks from x import * (0.15.2) Sep 8, 2016
@itamarst
Copy link
Author

itamarst commented Sep 8, 2016

Unfortunately the real code is complex and I'm having trouble creating a reproducer, but updated my description above with plausible theory.

@itamarst itamarst changed the title hooks breaks from x import * (0.15.2) hooks breaks from x import * (0.15.2, Python 2) Sep 8, 2016
@edschofield
Copy link
Contributor

Thanks for the feedback. I have seen this before too during development of some modules in future.backports, but it was hard to reproduce for me too. I ended up removing the use of hooks. It may be time to mark the hooks interface as deprecated.

Meanwhile, please let us know if you succeed in reproducing it reliably.

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

3 participants