[Distutils] Are chained comparisons allowed in environment markers?

PJ Eby pje at telecommunity.com
Sat Apr 27 21:19:24 CEST 2013


On Sat, Apr 27, 2013 at 2:35 PM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> So IIUC, that just means that the variables we support in expressions are:
>
> * python_version, python_full_version, extra as in the PEP already.
> * os_name instead of os.name.
> * sys_platform instead of sys.platform
> * platform_version instead of platform.version
> * platform_machine instead of platform.machine
> * platform_python_implementation instead of platform.python_implementation
>
> How about just python_implementation for the last one?

+1


> Why should chained comparisons be disallowed? If we assume that inequalities are allowed, then surely "'v1' <= some_var < 'v2'" is a reasonable short-hand for "'v1' <= some_var and some_var < 'v2'"?

I was not proposing that we support inequalities.  They aren't so
problematic in themselves, as they are inviting various questions and
issues such as why they don't do any sort of version parsing.


> I'd like to know what practical problems there would be with supporting Unicode escapes. As I understand it, you can convert to Unicode on 2.x by just using s.decode('unicode_escape').

It's not just the escapes, it's supporting Unicode at all.  Does that
mean all of the variables have to be Unicode too, to prevent errors
when non-ASCII characters are present?  Under Python 3 these issues
are all moot because str==unicode.  Under 2.x it's just a giant can of
worms to introduce unicode instances in a library that's all strs at
the moment.

My preferred way to deal with the whole thing is to allow single or
triple-quoted strings, disallow backslashes, and assume ASCII-only.
That lets me avoid eval *and* string decoding on 2.x.  (My
implementation is actually single-source for 2.3 up through 3.2 at
least, but does so by assuming all the strings it handles are the same
type.)


More information about the Distutils-SIG mailing list