mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
logging(cmp_version): output assertion
Log error. The integer comparison is Python 3 compatible and ripped from [1]. This will catch incorrectly implemented version comparison functions. [1] http://stackoverflow.com/a/3646519/260805
This commit is contained in:
parent
673b6c683d
commit
4763f28725
1 changed files with 7 additions and 0 deletions
|
@ -16,6 +16,7 @@ import hashlib
|
|||
import imp
|
||||
import json
|
||||
import logging
|
||||
import numbers
|
||||
import os
|
||||
import pprint
|
||||
import random
|
||||
|
@ -2020,6 +2021,12 @@ def compare_versions(ver1='', oper='==', ver2='', cmp_func=None):
|
|||
if cmp_result is None:
|
||||
return False
|
||||
|
||||
# Check if integer/long
|
||||
if not isinstance(cmp_result, numbers.Integral):
|
||||
log.error('The version comparison function did not return an '
|
||||
'integer/long.')
|
||||
return False
|
||||
|
||||
if oper == '!=':
|
||||
return cmp_result not in cmp_map['==']
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue