mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 22:51:01 +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 38e7589ff3252a43aef3927f3b6c965788812b8a.
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):
|
def __call__(self, *args, **kwargs):
|
||||||
return self._origin(*args, **kwargs)
|
return self._origin(*args, **kwargs)
|
||||||
|
|
||||||
class InternationalizedString(str):
|
try:
|
||||||
"""Simple subclass to str, that allow to add attributes. Also used to
|
class InternationalizedString(str):
|
||||||
know if a string is already localized"""
|
"""Simple subclass to str, that allow to add attributes. Also used to
|
||||||
__slots__ = ('_original', '_internationalizer')
|
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):
|
def internationalizeDocstring(obj):
|
||||||
"""Decorates functions and internationalize their docstring.
|
"""Decorates functions and internationalize their docstring.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user