mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Support for str in StrEnum.
The StrEnum class has been modified to accept str value and convert it into unicode. This is to fix encoding issue on F14.
This commit is contained in:
@@ -1384,6 +1384,24 @@ class StrEnum(Enum):
|
||||
|
||||
type = unicode
|
||||
|
||||
def _convert_scalar(self, value, index=None):
|
||||
"""
|
||||
Convert a single scalar value.
|
||||
"""
|
||||
if type(value) is self.type:
|
||||
return value
|
||||
if type(value) is str:
|
||||
try:
|
||||
return value.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
raise ConversionError(
|
||||
name=self.name, index=index,
|
||||
error=ugettext(self.scalar_error)
|
||||
)
|
||||
raise ConversionError(name=self.name, index=index,
|
||||
error=ugettext(self.type_error),
|
||||
)
|
||||
|
||||
|
||||
class List(Param):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user