payload: {"action":"opened","issue":{"url":"https://api.github.com/repos/google/pinject/issues/39","repository_url":"https://api.github.com/repos/google/pinject","labels_url":"https://api.github.com/repos/google/pinject/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/google/pinject/issues/39/comments","events_url":"https://api.github.com/repos/google/pinject/issues/39/events","html_url":"https://github.com/google/pinject/issues/39","id":454966888,"node_id":"MDU6SXNzdWU0NTQ5NjY4ODg=","number":39,"title":"Requests/Urllib3/six injection issue.","user":{"login":"joshpaulchan","id":5693033,"node_id":"MDQ6VXNlcjU2OTMwMzM=","avatar_url":"https://avatars0.githubusercontent.com/u/5693033?v=4","gravatar_id":"","url":"https://api.github.com/users/joshpaulchan","html_url":"https://github.com/joshpaulchan","followers_url":"https://api.github.com/users/joshpaulchan/followers","following_url":"https://api.github.com/users/joshpaulchan/following{/other_user}","gists_url":"https://api.github.com/users/joshpaulchan/gists{/gist_id}","starred_url":"https://api.github.com/users/joshpaulchan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshpaulchan/subscriptions","organizations_url":"https://api.github.com/users/joshpaulchan/orgs","repos_url":"https://api.github.com/users/joshpaulchan/repos","events_url":"https://api.github.com/users/joshpaulchan/events{/privacy}","received_events_url":"https://api.github.com/users/joshpaulchan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-06-12T01:07:54Z","updated_at":"2019-06-12T01:07:54Z","closed_at":null,"author_association":"NONE","body":"### Issue\r\nWhen importing the requests library and calling `new_object_graph`, it fails complaining about Tkinter not being configured for the system.\r\n\r\nThe problem is that when calling new_object_graph, Pinject traverses the imported modules by default but for some reason it's error on importing Tkinter on python installations where Tkinter isn't supported (intentionally, i.e. `python:3.7-alpine`). I believe the import tree is application -> requests -> urllib3 -> six -> Tkinter. I'm not sure what the proper fix is here, but I wanted to report it in case it is an actual behavioral issue with Pinject. \r\n\r\n### Environment\r\n\r\nDocker container: python3.7-alpine\r\nRequests: 2.2.1\r\nPinject: v0.12\r\n\r\n### Reproduction\r\n\r\nThis should be enough to repro it:\r\n\r\n```python\r\n# repro.py\r\nimport pinject\r\n\r\nimport requests\r\n\r\ndef main():\r\n    graph = pinject.new_object_graph() # errors\r\n\r\nif __name__ == \"__main__\":\r\n    main()\r\n```\r\n\r\n```bash\r\n(pinject-requests-tkinter) ~/w/pinject-requests-tkinter ❯❯❯ docker run --rm -it pinject-requests-tkinter                    master ✱ ◼\r\nPython 3.7.3 (default, May 11 2019, 02:00:41)\r\n[GCC 8.3.0] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import repro\r\n>>> repro.main()\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/opt/app/repro.py\", line 7, in main\r\n    pinject.new_object_graph()\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/pinject/object_graph.py\", line 100, in new_object_graph\r\n    found_classes = finding.find_classes(modules, classes)\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/pinject/finding.py\", line 32, in find_classes\r\n    all_classes |= _find_classes_in_module(module)\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/pinject/finding.py\", line 46, in _find_classes_in_module\r\n    for member_name, member in inspect.getmembers(module):\r\n  File \"/usr/local/lib/python3.7/inspect.py\", line 341, in getmembers\r\n    value = getattr(object, key)\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/urllib3/packages/six.py\", line 92, in __get__\r\n    result = self._resolve()\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/urllib3/packages/six.py\", line 115, in _resolve\r\n    return _import_module(self.mod)\r\n  File \"/root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/site-packages/urllib3/packages/six.py\", line 82, in _import_module\r\n    __import__(name)\r\n  File \"/usr/local/lib/python3.7/tkinter/__init__.py\", line 36, in <module>\r\n    import _tkinter # If this fails your Python may not be configured for Tk\r\nImportError: Error loading shared library libtk8.6.so: No such file or directory (needed by /root/.local/share/virtualenvs/app-ueEJiAOq/lib/python3.7/lib-dynload/_tkinter.cpython-37m-x86_64-linux-gnu.so)\r\n>>>\r\n```\r\n\r\nAlso, apologies if this is the wrong place to put this! I figured it wasn't an issue with requests/urllib3/six (at least, I'd hope not) since they're so prevalent."}}
other: {"actor":{"display_login":"joshpaulchan"}}