diff -urN lua-5.1.1/src/lstrlib.c lua-5.1.1e/src/lstrlib.c
--- lua-5.1.1/src/lstrlib.c	Wed Apr 26 16:41:19 2006
+++ lua-5.1.1e/src/lstrlib.c	Tue Oct  3 15:19:22 2006
@@ -795,7 +795,14 @@
         }
         case 's': {
           size_t l;
-          const char *s = luaL_checklstring(L, arg, &l);
+          const char *s;
+          if (!lua_isstring(L, arg)) {
+            lua_getglobal(L, "tostring");
+            lua_pushvalue(L, arg);
+            lua_call(L, 1, 1);
+            lua_replace(L,arg);
+          }
+          s = luaL_checklstring(L, arg, &l);
           if (!strchr(form, '.') && l >= 100) {
             /* no precision and string is too long to be formatted;
                keep original string */
