Use sys.version_info instead of sys.version in packaging.

The contents of this attribute are an implementation detail, as
documented for #9442, so we should not parse it, to support non-CPython
VMs with distutils2 in the future.

Unfortunately, one use comes directly from PEP 345, so an edit will have
to be agreed before fixing the code (see comment in p7g.markers).

Other remaining uses are found in p7g.compiler and could be replaced by
the platform module (which also parses sys.version, but then it wouldn’t
be my fault :)
This commit is contained in:
Éric Araujo 2012-02-10 05:20:53 +01:00
parent ea0b1edf45
commit 9f90a731eb
8 changed files with 23 additions and 17 deletions

View file

@ -1,11 +1,10 @@
"""Parser for the environment markers micro-language defined in PEP 345."""
import os
import sys
import platform
import os
from tokenize import tokenize, NAME, OP, STRING, ENDMARKER, ENCODING
from io import BytesIO
from tokenize import tokenize, NAME, OP, STRING, ENDMARKER, ENCODING
__all__ = ['interpret']
@ -27,12 +26,15 @@ def _operate(operation, x, y):
# restricted set of variables
_VARS = {'sys.platform': sys.platform,
'python_version': sys.version[:3],
'python_version': '%s.%s' % sys.version_info[:2],
# FIXME parsing sys.platform is not reliable, but there is no other
# way to get e.g. 2.7.2+, and the PEP is defined with sys.version
'python_full_version': sys.version.split(' ', 1)[0],
'os.name': os.name,
'platform.version': platform.version(),
'platform.machine': platform.machine(),
'platform.python_implementation': platform.python_implementation()}
'platform.python_implementation': platform.python_implementation(),
}
class _Operation: