Get rid of Python 3.3 artifacts

This commit is contained in:
Dave Halter
2020-01-05 23:59:38 +01:00
parent 4090c80401
commit 9ee7409d8a
6 changed files with 8 additions and 9 deletions

View File

@@ -55,7 +55,7 @@ _VERSION_TAG = '%s-%s%s-%s' % (
""" """
Short name for distinguish Python implementations and versions. 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: we generate something similar. See:
http://docs.python.org/3/library/sys.html#sys.implementation http://docs.python.org/3/library/sys.html#sys.implementation
""" """

View File

@@ -224,7 +224,7 @@ def load_grammar(**kwargs):
Loads a :py:class:`parso.Grammar`. The default version is the current Python Loads a :py:class:`parso.Grammar`. The default version is the current Python
version. 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 :param str path: A path to a grammar file
""" """
def load_grammar(language='python', version=None, path=None): def load_grammar(language='python', version=None, path=None):

View File

@@ -123,7 +123,7 @@ def _parse_version(version):
match = re.match(r'(\d+)(?:\.(\d)(?:\.\d+)?)?$', version) match = re.match(r'(\d+)(?:\.(\d)(?:\.\d+)?)?$', version)
if match is None: if match is None:
raise ValueError('The given version is not in the right format. ' 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)) major = int(match.group(1))
minor = match.group(2) minor = match.group(2)
@@ -164,13 +164,13 @@ class PythonVersionInfo(namedtuple('Version', 'major, minor')):
def parse_version_string(version=None): 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 returns a corresponding version info that is always two characters long in
decimal. decimal.
""" """
if version is None: if version is None:
version = '%s.%s' % sys.version_info[:2] version = '%s.%s' % sys.version_info[:2]
if not isinstance(version, (unicode, str)): 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) return _parse_version(version)

View File

@@ -28,4 +28,4 @@ def test_invalid_grammar_version(string):
def test_grammar_int_version(): def test_grammar_int_version():
with pytest.raises(TypeError): with pytest.raises(TypeError):
load_grammar(version=3.2) load_grammar(version=3.8)

View File

@@ -142,7 +142,7 @@ def test_yields(each_version):
def test_yield_from(): 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' assert y.type == 'yield_expr'

View File

@@ -37,8 +37,7 @@ def test_python_exception_matches(code):
error, = errors error, = errors
actual = error.message actual = error.message
assert actual in wanted assert actual in wanted
# Somehow in Python3.3 the SyntaxError().lineno is sometimes None assert line_nr == error.start_pos[0]
assert line_nr is None or line_nr == error.start_pos[0]
def test_non_async_in_async(): def test_non_async_in_async():