Skip to content

Commit

Permalink
Use legacy version implementation for Python itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsajip committed Dec 11, 2023
1 parent 8242f39 commit 0e261af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,11 @@ Change log for ``distlib``

Released: Not yet.

- markers

- Fix #209: use legacy version implementation for Python versions.


0.3.7
~~~~~

Expand Down
10 changes: 5 additions & 5 deletions distlib/markers.py
Expand Up @@ -19,7 +19,7 @@

from .compat import string_types
from .util import in_venv, parse_marker
from .version import NormalizedVersion as NV
from .version import LegacyVersion as LV

__all__ = ['interpret']

Expand All @@ -35,7 +35,7 @@ def _is_literal(o):
return o[0] in '\'"'

def _get_versions(s):
return {NV(m.groups()[0]) for m in _VERSION_PATTERN.finditer(s)}
return {LV(m.groups()[0]) for m in _VERSION_PATTERN.finditer(s)}

class Evaluator(object):
"""
Expand Down Expand Up @@ -83,10 +83,10 @@ def evaluate(self, expr, context):
rhs = self.evaluate(erhs, context)
if ((_is_version_marker(elhs) or _is_version_marker(erhs)) and
op in ('<', '<=', '>', '>=', '===', '==', '!=', '~=')):
lhs = NV(lhs)
rhs = NV(rhs)
lhs = LV(lhs)
rhs = LV(rhs)
elif _is_version_marker(elhs) and op in ('in', 'not in'):
lhs = NV(lhs)
lhs = LV(lhs)
rhs = _get_versions(rhs)
result = self.operations[op](lhs, rhs)
return result
Expand Down
7 changes: 3 additions & 4 deletions tests/test_markers.py
Expand Up @@ -26,10 +26,9 @@ def test_interpret(self):
platform_python_implementation = python_implementation()

self.assertTrue(interpret("sys_platform == '%s'" % sys_platform))
if sys.version_info[3] == 'final':
self.assertTrue(interpret(
"sys_platform == '%s' and python_full_version == '%s'" %
(sys_platform, version)))
self.assertTrue(interpret(
"sys_platform == '%s' and python_full_version == '%s'" %
(sys_platform, version)))
self.assertTrue(interpret("'%s' == sys_platform" % sys_platform))
self.assertTrue(interpret('os_name == "%s"' % os_name))
self.assertTrue(interpret(
Expand Down

0 comments on commit 0e261af

Please sign in to comment.