GAE - Error during the import _winreg

Hi,

I use GAE - Google Application Engine - and my project raises error during 'import requests' when it is ran under GAE sandbox (locally).

GAE doesn't have _winreg in sys.modules and the _winreg is called by platform.py. In platform.py: system() function -> uname() -> win32_ver() -> import _winreg.

'platform' now is used in requests/utils.py after the commit '**proxy bypass on Windows without DNS lookups**' by @schlamar. 

I don't know why GAE doesn't import _winreg. It seems GAE was developed in Unix-like platform.

![imagem001](https://cloud.githubusercontent.com/assets/11619400/26034212/95ce62d8-388f-11e7-9fb6-354e57ab0d3f.png)

If I copy an old requests version to my project (without import platform) and it works nice.

I'm not sure if this is a problem with the Requests project or Google.

Regards,
André





It's a problem with Requests: we removed some error handling code there as we didn't think there was any situation where that module would not be present: apparently we were wrong. 😟

@schlamar; want to fix this up?

Remark: I use Windows 10 and Python 2.7, because it is a GAE limitation. I want to import google.auth.transport.requests, consequently it uses requests library. 

Thanks.

I don't entirely agree that this is a Requests bug. We can and *should* fix it there, but I think the bug is actually in the standard library (it should handle an ImportError like this). That stacktrace, however, is very odd. Why would `platform.py` be going through `C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py`. It seems like this might be a bug in the GAE sandbox utility. It seems to have an import hook and it seems to be broken. :/

https://issuetracker.google.com/issues/35895346 it seems there's a whitelist of modules in the devappserver2 source code that may need to be updated to allow the use of `_winreg`.

cc @jonparrott

I'll definitely look into this. Quick question- does this work when deployed? Does it only fail locally?

It works fine when it is deployed. Only at the local level (GAE sandbox) that the error occurs.

Cool, I'll report this to the SDK team. It should be a relatively easy fix,
but fair warning that the release cycle is generally at least 2 weeks. I'll
keep this bug updated.

On Sun, May 14, 2017, 10:38 AM André Avilla <notifications@github.com>
wrote:

> It works fine when it is deployed.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/kennethreitz/requests/issues/4020#issuecomment-301327649>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAPUc7smNQhA8Aq_MWd0gpWP19tJlYdJks5r5zv3gaJpZM4NaYgf>
> .
>


Google-side public issue: https://issuetracker.google.com/issues/38290292

This was fixed 3 weeks ago. Based on @jonparrott's previous comments, this should be released. I believe this is fixed now so I'm going to close this. If I'm mistaken, please let me know and we can reopen this.

I see this exact same case in my local GAE sandbox on Windows 10 machine using Python 2.7
Is the fix available in master already? Thanks!

It should be *released*, not just in master, but the fix is upstream of us in the GAE sandbox.

> It should be released, not just in master, but the fix is upstream of us in the GAE sandbox.

Correct, and if it's still present, it should be reported there as well.