This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2018年10月31日 22:28 by davide moro, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg329018 - (view) | Author: davide moro (davide moro) | Date: 2018年10月31日 22:28 | |
I noticed that with the python2.7 version of distutils.version.LooseVersion let you compare '7' with 'xp' without exceptions (e.g., LooseVersion('7') > LooseVersion('xp')).
If you do the same with python3.6 or python3.7, you'll get the following exception:
* TypeError: '<' not supported between instances of 'int' and 'str'
You can see the full example with complete traceback and differences between python2.x and python3.x here:
* https://pastebin.com/kAwUTihe
Thanks,
davide
|
|||
| msg329020 - (view) | Author: Steven D'Aprano (steven.daprano) * (Python committer) | Date: 2018年10月31日 22:49 | |
There is no need to split the relevant code into a third-party website, especially when it is so small and can be included in-line here.
Python 2.7:
py> import distutils.version
py> distutils.version.LooseVersion('7') > distutils.version.LooseVersion('XP')
False
Python 3.6:
py> import distutils.version
py> distutils.version.LooseVersion('7') > distutils.version.LooseVersion('XP')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/storage/python/Python-3.6.4/Lib/distutils/version.py", line 64, in __gt__
c = self._cmp(other)
File "/storage/python/Python-3.6.4/Lib/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'int' and 'str'
(By the way, you appear to have a bug in your sys.excepthook handler. At least I can't reproduce the ModuleNotFoundError you are getting.)
|
|||
| msg329027 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2018年10月31日 23:53 | |
Please discuss on #14894 |
|||
| msg329091 - (view) | Author: davide moro (davide moro) | Date: 2018年11月01日 22:06 | |
Thanks and sorry for the duplicate! Il giorno gio 1 nov 2018 alle ore 00:53 Éric Araujo <report@bugs.python.org> ha scritto: > > Éric Araujo <merwok@netwok.org> added the comment: > > Please discuss on #14894 > > ---------- > resolution: -> duplicate > stage: -> resolved > status: open -> closed > superseder: -> distutils.LooseVersion fails to compare number and a word > > _______________________________________ > Python tracker <report@bugs.python.org> > <https://bugs.python.org/issue35129> > _______________________________________ > |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:07 | admin | set | github: 79310 |
| 2018年11月01日 22:06:08 | davide moro | set | messages: + msg329091 |
| 2018年10月31日 23:53:21 | eric.araujo | set | status: open -> closed superseder: distutils.LooseVersion fails to compare number and a word messages: + msg329027 resolution: duplicate stage: resolved |
| 2018年10月31日 22:49:18 | steven.daprano | set | nosy:
+ steven.daprano messages: + msg329020 |
| 2018年10月31日 22:28:42 | davide moro | create | |