Skip to content

Commit 5005de8

Browse files
kmodgvanrossum
authored andcommitted
Remove the dict constraint in ForwardRef._eval_type (#252)
This improves compatibility with Pyston, which doesn't use a dict for globals. I'm not sure if there is a better solution, but just removing the check seems ok: eval() will still do type checking, and though the error messages won't be as nice I think it's ok because this is all internal (the locals/globals seem to come from f_locals/f_globals).
1 parent 26ebf93 commit 5005de8

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

python2/typing.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,6 @@ def __new__(cls, arg):
155155
return self
156156

157157
def _eval_type(self, globalns, localns):
158-
if not isinstance(localns, dict):
159-
raise TypeError('ForwardRef localns must be a dict -- got %r' %
160-
(localns,))
161-
if not isinstance(globalns, dict):
162-
raise TypeError('ForwardRef globalns must be a dict -- got %r' %
163-
(globalns,))
164158
if not self.__forward_evaluated__:
165159
if globalns is None and localns is None:
166160
globalns = localns = {}

src/typing.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ def __new__(cls, arg):
160160
return self
161161

162162
def _eval_type(self, globalns, localns):
163-
if not isinstance(localns, dict):
164-
raise TypeError('ForwardRef localns must be a dict -- got %r' %
165-
(localns,))
166-
if not isinstance(globalns, dict):
167-
raise TypeError('ForwardRef globalns must be a dict -- got %r' %
168-
(globalns,))
169163
if not self.__forward_evaluated__:
170164
if globalns is None and localns is None:
171165
globalns = localns = {}

0 commit comments

Comments
 (0)