From 3189ba76625b45171a30757ed6288d78654137b6 Mon Sep 17 00:00:00 2001 From: Phillip Berndt Date: Mon, 18 Aug 2014 17:22:11 +0200 Subject: [PATCH] Add type check to jedi.Interpreter() namespace argument and remove default value --- AUTHORS.txt | 1 + jedi/api/__init__.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 668d6576..edf676d7 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -26,5 +26,6 @@ Jorgen Schaefer (@jorgenschaefer) Fredrik Bergroth (@fbergroth) Mathias Fußenegger (@mfussenegger) Syohei Yoshida (@syohex) +Phillip Berndt (@phillipberndt) Note: (@user) means a github user name. diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 1aa73f7b..1a2a09d6 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -621,7 +621,7 @@ class Interpreter(Script): upper """ - def __init__(self, source, namespaces=[], **kwds): + def __init__(self, source, namespaces, **kwds): """ Parse `source` and mixin interpreted Python objects from `namespaces`. @@ -635,6 +635,10 @@ class Interpreter(Script): If `line` and `column` are None, they are assumed be at the end of `source`. """ + if type(namespaces) is not list or len(namespaces) == 0 or \ + any([type(x) is not dict for x in namespaces]): + raise TypeError("namespaces must be a non-empty list of dict") + super(Interpreter, self).__init__(source, **kwds) self.namespaces = namespaces