mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-28 05:32:51 +01:00
Add fallback for interpreters which do not support __slots__ for str subclasses.
Affects CPython 2.x, but neither CPython 3.x or Pypy.
Incompatibility introduced in 38e7589ff3
.
This commit is contained in:
parent
15e387ea46
commit
c260a76e06
17
src/i18n.py
17
src/i18n.py
@ -350,10 +350,19 @@ class InternationalizedFunction:
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self._origin(*args, **kwargs)
|
||||
|
||||
class InternationalizedString(str):
|
||||
"""Simple subclass to str, that allow to add attributes. Also used to
|
||||
know if a string is already localized"""
|
||||
__slots__ = ('_original', '_internationalizer')
|
||||
try:
|
||||
class InternationalizedString(str):
|
||||
"""Simple subclass to str, that allow to add attributes. Also used to
|
||||
know if a string is already localized"""
|
||||
__slots__ = ('_original', '_internationalizer')
|
||||
except TypeError:
|
||||
# Fallback for CPython 2.x:
|
||||
# TypeError: Error when calling the metaclass bases
|
||||
# nonempty __slots__ not supported for subtype of 'str'
|
||||
class InternationalizedString(str):
|
||||
"""Simple subclass to str, that allow to add attributes. Also used to
|
||||
know if a string is already localized"""
|
||||
pass
|
||||
|
||||
def internationalizeDocstring(obj):
|
||||
"""Decorates functions and internationalize their docstring.
|
||||
|
Loading…
Reference in New Issue
Block a user