@@ -117,7 +117,7 @@ def getLocalePath(name, localeName, extension):
117117 return '%s/%s.%s' % (directory , localeName , extension )
118118
119119i18nClasses = weakref .WeakValueDictionary ()
120- internationalizedCommands = weakref .WeakValueDictionary ()
120+ internationalizedCommands = weakref .WeakSet ()
121121
122122def reloadLocalesIfRequired ():
123123 global currentLocale
@@ -132,7 +132,7 @@ def reloadLocales():
132132
133133 for pluginClass in i18nClasses .values ():
134134 pluginClass .loadLocale ()
135- for command in list (internationalizedCommands . values () ):
135+ for command in list (internationalizedCommands ):
136136 internationalizeDocstring (command )
137137 utils .str ._relocalizeFunctions (PluginInternationalization ())
138138
@@ -331,19 +331,10 @@ def localizeFunction(self, name):
331331 return self ._l10nFunctions [name ]
332332
333333
334- try :
335- class InternationalizedString (str ):
336- """Simple subclass to str, that allow to add attributes. Also used to
337- know if a string is already localized"""
338- __slots__ = ('_original' , '_internationalizer' )
339- except TypeError :
340- # Fallback for CPython 2.x:
341- # TypeError: Error when calling the metaclass bases
342- # nonempty __slots__ not supported for subtype of 'str'
343- class InternationalizedString (str ):
344- """Simple subclass to str, that allow to add attributes. Also used to
345- know if a string is already localized"""
346- pass
334+ class InternationalizedString (str ):
335+ """Simple subclass to str, that allow to add attributes. Also used to
336+ know if a string is already localized"""
337+ __slots__ = ('_original' , '_internationalizer' )
347338
348339
349340def internationalizeDocstring (obj ):
@@ -354,7 +345,7 @@ def internationalizeDocstring(obj):
354345 return obj
355346 plugin_module = sys .modules [obj .__module__ ]
356347 if '_' in plugin_module .__dict__ :
357- internationalizedCommands .update ({ hash ( obj ): obj } )
348+ internationalizedCommands .insert ( obj )
358349 try :
359350 obj .__doc__ = plugin_module ._ .__call__ (obj .__doc__ )
360351 # We use _.__call__() instead of _() because of a pygettext warning.
0 commit comments