{"action":"created","issue":{"url":"https://api.github.com/repos/PythonCharmers/python-future/issues/320","repository_url":"https://api.github.com/repos/PythonCharmers/python-future","labels_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/320/labels{/name}","comments_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/320/comments","events_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/320/events","html_url":"https://github.com/PythonCharmers/python-future/issues/320","id":288451478,"node_id":"MDU6SXNzdWUyODg0NTE0Nzg=","number":320,"title":"http.client broken on google app engine","user":{"login":"snarfed","id":778068,"node_id":"MDQ6VXNlcjc3ODA2OA==","avatar_url":"https://avatars2.githubusercontent.com/u/778068?v=4","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-01-14T23:59:49Z","updated_at":"2018-08-10T19:31:47Z","closed_at":null,"author_association":"NONE","body":"first off, thanks for future! it's hugely valuable.\r\n\r\ni noticed that the aliases for `http.client` don't work in google app engine, at least not in `dev_appserver.py`. (#231 is an older, similar app engine compability issue.) here's the exception:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py\", line 240, in Handle\r\n    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())\r\n  File \"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py\", line 299, in _LoadHandler\r\n    handler, path, err = LoadObject(self._handler)\r\n  File \"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py\", line 85, in LoadObject\r\n    obj = __import__(path[0])\r\n  File \"/Users/ryan/src/oauth-dropins/foo.py\", line 9, in <module>\r\n    import http.client\r\n  File \"/Users/ryan/src/oauth-dropins/local/lib/python2.7/site-packages/http/client.py\", line 11, in <module>\r\n    from httplib import (HTTP_PORT,\r\nImportError: cannot import name _CS_IDLE\r\n```\r\n\r\nto reproduce, create these two files: `app.yaml`:\r\n\r\n```yaml\r\napi_version: 1\r\nruntime: python27\r\n\r\n- url: .*\r\n  script: app.application\r\n```\r\n\r\n`app.py`:\r\n\r\n```py\r\nfrom google.appengine.ext import vendor\r\nvendor.add('local')\r\n\r\nfrom future import standard_library\r\nstandard_library.install_aliases()\r\n\r\nimport http.client\r\n```\r\n\r\nthen create the virtualenv, run the server:\r\n```sh\r\nvirtualenv local\r\nsource local/bin/activate\r\npip install future\r\ndev_appserver.py .\r\n```\r\n\r\nand open http://localhost:8080/ in your browser.\r\n\r\ni'm on future 0.16.0 and gcloud 184.0.0. details:\r\n\r\n```sh\r\n$ gcloud info\r\nGoogle Cloud SDK [184.0.0]\r\n\r\nPlatform: [Mac OS X, x86_64] ('Darwin', 'hell.local', '17.3.0', 'Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64', 'x86_64', 'i386')\r\nPython Version: [2.7.10 (default, Jul 15 2017, 17:16:57)  [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]]\r\nPython Location: [/Users/ryan/src/gcp-variant-transforms/local/bin/python2]\r\nSite Packages: [Enabled]\r\n\r\nInstallation Root: [/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk]\r\nInstalled Components:\r\n  core: [2018.01.05]\r\n  app-engine-python: [1.9.65]\r\n  gcloud: []\r\n  beta: [2017.09.15]\r\n  gsutil: [4.28]\r\n  bq: [2.0.28]\r\n  alpha: [2017.09.15]\r\nSystem PATH: [...]\r\nPython PATH: [...]\r\nCloud SDK on PATH: [False]\r\nKubectl on PATH: [False]\r\n...\r\ngit: [git version 2.15.1]\r\nssh: [OpenSSH_7.6p1, LibreSSL 2.6.2]\r\n```"},"comment":{"url":"https://api.github.com/repos/PythonCharmers/python-future/issues/comments/412183064","html_url":"https://github.com/PythonCharmers/python-future/issues/320#issuecomment-412183064","issue_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/320","id":412183064,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjE4MzA2NA==","user":{"login":"jacobg","id":736985,"node_id":"MDQ6VXNlcjczNjk4NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/736985?v=4","gravatar_id":"","url":"https://api.github.com/users/jacobg","html_url":"https://github.com/jacobg","followers_url":"https://api.github.com/users/jacobg/followers","following_url":"https://api.github.com/users/jacobg/following{/other_user}","gists_url":"https://api.github.com/users/jacobg/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobg/subscriptions","organizations_url":"https://api.github.com/users/jacobg/orgs","repos_url":"https://api.github.com/users/jacobg/repos","events_url":"https://api.github.com/users/jacobg/events{/privacy}","received_events_url":"https://api.github.com/users/jacobg/received_events","type":"User","site_admin":false},"created_at":"2018-08-10T19:31:47Z","updated_at":"2018-08-10T19:31:47Z","author_association":"NONE","body":"@snarfed haha thanks! This monkeypatch fixes it:\r\n\r\n```\r\ndef _fix_sendgrid_http_client():\r\n    # force sendgrid's http client to use urllib2, not future urllib.\r\n    # future urllib doesn't work in local development.\r\n    # https://github.com/PythonCharmers/python-future/issues/320#issuecomment-412174717\r\n    import urllib2 as urllib\r\n    from urllib2 import HTTPError\r\n    from urllib import urlencode\r\n    from python_http_client import client\r\n    client.urllib = urllib\r\n    client.HTTPError = HTTPError\r\n    client.urlencode = urlencode\r\n```"}}
{"actor":{"display_login":"jacobg"}}