[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem with penlight's pl.pretty.dump 0.8.1 from LfW 5.1.4-34
- From: Ross Berteig <Ross@...>
- Date: Wed, 31 Mar 2010 16:13:39 -0700
I attempted to use penlight's pl.pretty.dump() for a quick and
dirty document format for a simple utility. Its one-argument form
where the first parameter is the table to dump to stdout works
exactly as documented. Its two-argument form where the second
argument is the name of a file fails with a mysterious error:
E:...>lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'pl.pretty'
> pl.pretty.dump({}, "test.txt")
utils.assert_string: argument 2 expected a 'string', got a 'table'
stack traceback:
stdin:1: in main chunk
[C]: ?
E:...>
Note that the message appears to blame argument 2 of my call to
pl.pretty.dump() for being a table, but it is obviously not a
table. The issue is that the implementation of dump() leverages
pl.util.writefile(), but doesn't pass the table through
pl.pretty.write() to make it into a pretty string first. This is
confounded by the (otherwise rational) decision to make all stack
traces start from the user's call site.
At line 160 of pl/pretty.lua, change:
- return utils.raise(utils.writefile((select(1,...)),t))
+ return
utils.raise(utils.writefile((select(1,...)),write(t)))
Incidentally, as packaged in Lua for Windows, the penlight
documentation has broken links.... probably because the
docs\penlight\index.html assumes that the folder api\modules is
just modules. Also, docs\penlight\function_index.html has good
links, but leaves out the pl.pretty module.
Ross Berteig Ross@CheshireEng.com
Cheshire Engineering Corp. http://www.CheshireEng.com/