Use feature detection instead of version detection

Python porting best practice is to Use feature detection instead of version detection
* https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection
This commit is contained in:
cclauss 2018-08-11 08:29:44 +02:00 committed by GitHub
parent e5376b9c93
commit ca658ed745
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,6 @@ import collections
import math
import os
import psutil
import sys
class Attribute(BaseObject):
@ -121,9 +120,10 @@ class IntParam(Param):
def validateValue(self, value):
# handle unsigned int values that are translated to int by shiboken and may overflow
longInt = int if sys.version_info > (3,) else long
try:
return longInt(value)
return long(value) # Python 2
except NameError:
return int(value) # Python 3
except:
raise ValueError('IntParam only supports int value (param:{}, value:{}, type:{})'.format(self.name, value, type(value)))