From 074a154af3633f77bfc9d7cfa5cc26a2f5e40587 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 6 Jul 2016 08:05:50 +0200 Subject: [PATCH] Fix a small issue that coul dhappen e.g. in stdin. --- jedi/evaluate/compiled/mixed.py | 4 +++- test/test_parser/test_parser.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/jedi/evaluate/compiled/mixed.py b/jedi/evaluate/compiled/mixed.py index b7a0bb44..96bd33bc 100644 --- a/jedi/evaluate/compiled/mixed.py +++ b/jedi/evaluate/compiled/mixed.py @@ -3,6 +3,7 @@ Used only for REPL Completion. """ import inspect +import os from jedi import common from jedi.parser.fast import FastParser @@ -105,7 +106,8 @@ def find_syntax_node_name(evaluator, python_object): except TypeError: # The type might not be known (e.g. class_with_dict.__weakref__) return None - if path is None: + if path is None or not os.path.exists(path): + # The path might not exist or be e.g. . return None module = _load_module(evaluator, path, python_object) diff --git a/test/test_parser/test_parser.py b/test/test_parser/test_parser.py index 001d49a5..74cac4b5 100644 --- a/test/test_parser/test_parser.py +++ b/test/test_parser/test_parser.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- import sys +from textwrap import dedent import jedi from jedi._compatibility import u, is_py3 from jedi.parser import ParserWithRecovery, load_grammar from jedi.parser import tree as pt -from textwrap import dedent def test_user_statement_on_import():