mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
If newer versions are using Jedi (e.g. at the moment Python 3.7), it shouldn't just result in a grammar issue, just because that grammar doesn't not exist. Just take the Python 3.6 grammar instead.
This commit is contained in:
@@ -233,6 +233,11 @@ try:
|
||||
except ImportError:
|
||||
from itertools import izip_longest as zip_longest # Python 2
|
||||
|
||||
try:
|
||||
FileNotFoundError = FileNotFoundError
|
||||
except NameError:
|
||||
FileNotFoundError = IOError
|
||||
|
||||
|
||||
def no_unicode_pprint(dct):
|
||||
"""
|
||||
|
||||
@@ -18,6 +18,7 @@ complexity of the ``Parser`` (there's another parser sitting inside
|
||||
import os
|
||||
import re
|
||||
|
||||
from jedi._compatibility import FileNotFoundError
|
||||
from jedi.parser import tree as pt
|
||||
from jedi.parser import tokenize
|
||||
from jedi.parser.token import (DEDENT, INDENT, ENDMARKER, NEWLINE, NUMBER,
|
||||
@@ -40,7 +41,7 @@ class ParseError(Exception):
|
||||
"""
|
||||
|
||||
|
||||
def load_grammar(version='3.4'):
|
||||
def load_grammar(version='3.6'):
|
||||
# For now we only support two different Python syntax versions: The latest
|
||||
# Python 3 and Python 2. This may change.
|
||||
if version in ('3.2', '3.3'):
|
||||
@@ -55,7 +56,11 @@ def load_grammar(version='3.4'):
|
||||
try:
|
||||
return _loaded_grammars[path]
|
||||
except KeyError:
|
||||
try:
|
||||
return _loaded_grammars.setdefault(path, generate_grammar(path))
|
||||
except FileNotFoundError:
|
||||
# Just load the default if the file does not exist.
|
||||
return load_grammar()
|
||||
|
||||
|
||||
class ParserSyntaxError(object):
|
||||
|
||||
@@ -234,3 +234,12 @@ def test_python3_octal():
|
||||
assert module.children[0].children[0].type == 'number'
|
||||
else:
|
||||
assert module.children[0].type == 'error_node'
|
||||
|
||||
|
||||
def test_load_newer_grammar():
|
||||
# This version shouldn't be out for a while, but if we somehow get this it
|
||||
# should just take the latest Python grammar.
|
||||
load_grammar('15.8')
|
||||
# The same is true for very old grammars (even though this is probably not
|
||||
# going to be an issue.
|
||||
load_grammar('1.5')
|
||||
|
||||
Reference in New Issue
Block a user