mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 05:14:29 +08:00
Get rid of Python 3.3 artifacts
This commit is contained in:
@@ -55,7 +55,7 @@ _VERSION_TAG = '%s-%s%s-%s' % (
|
||||
"""
|
||||
Short name for distinguish Python implementations and versions.
|
||||
|
||||
It's like `sys.implementation.cache_tag` but for Python < 3.3
|
||||
It's like `sys.implementation.cache_tag` but for Python2
|
||||
we generate something similar. See:
|
||||
http://docs.python.org/3/library/sys.html#sys.implementation
|
||||
"""
|
||||
|
||||
@@ -224,7 +224,7 @@ def load_grammar(**kwargs):
|
||||
Loads a :py:class:`parso.Grammar`. The default version is the current Python
|
||||
version.
|
||||
|
||||
:param str version: A python version string, e.g. ``version='3.3'``.
|
||||
:param str version: A python version string, e.g. ``version='3.8'``.
|
||||
:param str path: A path to a grammar file
|
||||
"""
|
||||
def load_grammar(language='python', version=None, path=None):
|
||||
|
||||
@@ -123,7 +123,7 @@ def _parse_version(version):
|
||||
match = re.match(r'(\d+)(?:\.(\d)(?:\.\d+)?)?$', version)
|
||||
if match is None:
|
||||
raise ValueError('The given version is not in the right format. '
|
||||
'Use something like "3.2" or "3".')
|
||||
'Use something like "3.8" or "3".')
|
||||
|
||||
major = int(match.group(1))
|
||||
minor = match.group(2)
|
||||
@@ -164,13 +164,13 @@ class PythonVersionInfo(namedtuple('Version', 'major, minor')):
|
||||
|
||||
def parse_version_string(version=None):
|
||||
"""
|
||||
Checks for a valid version number (e.g. `3.2` or `2.7.1` or `3`) and
|
||||
Checks for a valid version number (e.g. `3.8` or `2.7.1` or `3`) and
|
||||
returns a corresponding version info that is always two characters long in
|
||||
decimal.
|
||||
"""
|
||||
if version is None:
|
||||
version = '%s.%s' % sys.version_info[:2]
|
||||
if not isinstance(version, (unicode, str)):
|
||||
raise TypeError("version must be a string like 3.2.")
|
||||
raise TypeError('version must be a string like "3.8"')
|
||||
|
||||
return _parse_version(version)
|
||||
|
||||
@@ -28,4 +28,4 @@ def test_invalid_grammar_version(string):
|
||||
|
||||
def test_grammar_int_version():
|
||||
with pytest.raises(TypeError):
|
||||
load_grammar(version=3.2)
|
||||
load_grammar(version=3.8)
|
||||
|
||||
@@ -142,7 +142,7 @@ def test_yields(each_version):
|
||||
|
||||
|
||||
def test_yield_from():
|
||||
y, = get_yield_exprs('def x(): (yield from 1)', '3.3')
|
||||
y, = get_yield_exprs('def x(): (yield from 1)', '3.8')
|
||||
assert y.type == 'yield_expr'
|
||||
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ def test_python_exception_matches(code):
|
||||
error, = errors
|
||||
actual = error.message
|
||||
assert actual in wanted
|
||||
# Somehow in Python3.3 the SyntaxError().lineno is sometimes None
|
||||
assert line_nr is None or line_nr == error.start_pos[0]
|
||||
assert line_nr == error.start_pos[0]
|
||||
|
||||
|
||||
def test_non_async_in_async():
|
||||
|
||||
Reference in New Issue
Block a user