From 3af1e3f42d9a5e800952d42a4adf627f0427c42c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 21 Jan 2014 16:33:35 +0100 Subject: [PATCH] Fix internationalization of docstrings of wrap()ed commands. --- src/commands.py | 4 ++-- test/test_i18n.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands.py b/src/commands.py index 3ee2ff546..29c605239 100644 --- a/src/commands.py +++ b/src/commands.py @@ -1071,7 +1071,6 @@ def _wrap(f, specList=[], name=None, checkDoc=True, **kw): name = name or f.func_name assert (not checkDoc) or (hasattr(f, '__doc__') and f.__doc__), \ 'Command %r has no docstring.' % name - f = internationalizeDocstring(f) spec = Spec(specList, **kw) def newf(self, irc, msg, args, **kwargs): state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log}) @@ -1090,7 +1089,8 @@ def _wrap(f, specList=[], name=None, checkDoc=True, **kw): self.log.debug('Make sure you did not wrap a wrapped ' 'function ;)') raise - return utils.python.changeFunctionName(newf, name, f.__doc__) + newf2 = utils.python.changeFunctionName(newf, name, f.__doc__) + return internationalizeDocstring(newf2) def wrap(f, *args, **kwargs): if callable(f): diff --git a/test/test_i18n.py b/test/test_i18n.py index c4ec68ad8..a4f6582b6 100644 --- a/test/test_i18n.py +++ b/test/test_i18n.py @@ -29,6 +29,7 @@ ### from supybot.test import * +from supybot.commands import wrap from supybot.i18n import PluginInternationalization, internationalizeDocstring import supybot.conf as conf @@ -42,6 +43,11 @@ def foo(): """The operation succeeded.""" pass +@wrap +def bar(): + """The operation succeeded.""" + pass + class I18nTestCase(SupyTestCase): def testPluginInternationalization(self): self.assertEqual(_(msg_en), msg_en) @@ -54,6 +60,9 @@ class I18nTestCase(SupyTestCase): def testDocstring(self): self.assertEqual(foo.__doc__, msg_en) + self.assertEqual(bar.__doc__, msg_en) with conf.supybot.language.context('fr'): self.assertEqual(foo.__doc__, msg_fr) + self.assertEqual(bar.__doc__, msg_fr) self.assertEqual(foo.__doc__, msg_en) + self.assertEqual(bar.__doc__, msg_en)