PyISAPIe cannot pass WebOb dict type check

23 views
Skip to first unread message

Yap Sok Ann

unread,
Oct 24, 2011, 7:12:14 AM10/24/11
to PyISAPIe
This change in WebOb:

if type(environ) is not dict:
raise TypeError("WSGI environ must be a dict")

( https://github.com/Pylons/webob/commit/fa3834b1ed35cc7cf8e43fc6bde4dd4ff4df30bd#L4R48
)

somehow doesn't work with PyISAPIe. If I change the if-statement to:

if isinstance(environ, dict):

then it works fine.

Is it an expected behavior, or is there something wrong with my setup?
Thanks.

Yap Sok Ann

unread,
Oct 24, 2011, 7:18:07 AM10/24/11
to PyISAPIe
Ah, nevermind. Just saw that PyISAPIe is using IsapiEnv, a subclass of
dict. I should check with the WebOb guys to change the if-statement to
use isinstance instead.

On Oct 24, 7:12 pm, Yap Sok Ann <sok...@gmail.com> wrote:
> This change in WebOb:
>
>     if type(environ) is not dict:
>         raise TypeError("WSGI environ must be a dict")
>
> (https://github.com/Pylons/webob/commit/fa3834b1ed35cc7cf8e43fc6bde4dd...

Yap Sok Ann

unread,
Oct 24, 2011, 7:28:40 AM10/24/11
to PyISAPIe
From http://www.python.org/dev/peps/pep-3333/

> The environ parameter is a dictionary object, containing CGI-style environment variables. This object must be a builtin Python dictionary (not a subclass, UserDict or other dictionary emulation)

Looks like the "proper" solution is to change this line in PyISAPIe/
Python/Http/WSGI.py from:

Environ = IsapiEnv(Base, EnvWSGI)

to

Environ = dict(IsapiEnv(Base, EnvWSGI))

though I am not sure if it will cause any breakage...

Phillip Sitbon

unread,
Nov 15, 2011, 5:17:30 PM11/15/11
to pyis...@googlegroups.com
Just to follow up:

It's not a big deal, the whole point of creating that dictionary proxy
was to avoid such issues. WebOb should be using isinstance(), because
it would then see that IsapiEnv is an instance of type dict.

Cheers,

Phillip

> --
> You received this message because you are subscribed to the Google Groups "PyISAPIe" group.
> To post to this group, send email to pyis...@googlegroups.com.
> To unsubscribe from this group, send email to pyisapie+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pyisapie?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages