From eca786bf0ed0fe1310dc494769e3b59f543c6dce Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 21 Aug 2013 13:42:18 +0430 Subject: [PATCH] fix a problem with empty scripts --- jedi/api.py | 2 +- test/test_api.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jedi/api.py b/jedi/api.py index 1d44d203..739bbabd 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -60,7 +60,7 @@ class Script(object): warnings.warn("Use path instead of source_path.", DeprecationWarning) path = source_path - lines = source.splitlines() + lines = source.splitlines() or [''] if source and source[-1] == '\n': lines.append('') diff --git a/test/test_api.py b/test/test_api.py index 1ee95afd..594bf5b3 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -24,3 +24,7 @@ def test_preload_modules(): check_loaded('datetime', 'json', 'token') cache.parser_cache = temp_cache + + +def test_empty_script(): + assert api.Script('')