Merge "Avoid to use eval in pythonk8sclient"
This commit is contained in:
@@ -17,6 +17,7 @@ Copyright 2015 SmartBear Software
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
import __builtin__
|
||||||
from . import models
|
from . import models
|
||||||
from .rest import RESTClient
|
from .rest import RESTClient
|
||||||
from .rest import ApiException
|
from .rest import ApiException
|
||||||
@@ -257,12 +258,15 @@ class ApiClient(object):
|
|||||||
|
|
||||||
# convert str to class
|
# convert str to class
|
||||||
# for native types
|
# for native types
|
||||||
if klass in ['int', 'float', 'str', 'bool',
|
if klass in ['int', 'float', 'str', 'bool', 'object']:
|
||||||
"date", 'datetime', "object"]:
|
klass = getattr(__builtin__, klass)
|
||||||
klass = eval(klass)
|
elif klass == 'date':
|
||||||
|
klass = date
|
||||||
|
elif klass == 'datetime':
|
||||||
|
klass = datetime
|
||||||
# for model types
|
# for model types
|
||||||
else:
|
else:
|
||||||
klass = eval('models.' + klass)
|
klass = getattr(models, klass)
|
||||||
|
|
||||||
if klass in [int, float, str, bool]:
|
if klass in [int, float, str, bool]:
|
||||||
return self.__deserialize_primitive(data, klass)
|
return self.__deserialize_primitive(data, klass)
|
||||||
|
Reference in New Issue
Block a user