Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with penlight's pl.pretty.dump #1

Closed
rjpcomputing opened this issue Apr 12, 2010 · 1 comment
Closed

Problem with penlight's pl.pretty.dump #1

rjpcomputing opened this issue Apr 12, 2010 · 1 comment

Comments

@rjpcomputing
Copy link
Contributor

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)))

@rjpcomputing
Copy link
Contributor Author

Fixed in version 0.8.4

stevedonovan pushed a commit that referenced this issue May 7, 2013
Caught red handed, after a shameless copy 😄. Thx for the fix
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant