New submission from Boštjan Mejak <bostjan.xpe...@gmail.com>:

I stumbled upon a possible bug in the Python interpreter while doing some 
Python version comparisons.

Look at this:
"3.10.2" < "3.8.2"
True  # This is not true as a version number comparison

Now look at this:
"3.10.2" < "3.08.2"
False  # Adding a leading 0 compares those two version numbers correctly

Is it possible Python is fixed to correctly compare such numbers? That would 
make comparing Python version numbers possible in the future.

import platform
if platform.python_version() < "3.8.2":
    # Do something

This is currently possible and correct, but this will break when Python version 
number becomes 3.10 and you wanna compare this version number to, say, 3.9.

----------
components: Interpreter Core
messages: 364535
nosy: PedanticHacker, gvanrossum
priority: normal
severity: normal
status: open
title: String comparison with dotted numerical values wrong
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40004>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to