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

error running django-admin.py build --parse-templates #135

Closed
rob-b opened this issue May 9, 2012 · 0 comments
Closed

error running django-admin.py build --parse-templates #135

rob-b opened this issue May 9, 2012 · 0 comments

Comments

@rob-b
Copy link

rob-b commented May 9, 2012

File "/home/vagrant/.virtualenvs/extit/local/lib/python2.7/site-packages/webassets/ext/jinja2.py", line 157, in _recurse_node
filter, output, files = node.args
ValueError: too many values to unpack

The issue is because node.args returns 4 values, the 3rd being a Const with value of None

(Pdb++) print node.args[2]
Const(value=None)

This patch fixes the issue in a backwards compatible way

--- ext/jinja2.py·  2012-05-09 12:00:30.518965070 +0000
+++ ext/jinja2.new.py·  2012-05-09 12:01:09.731791216 +0000
@@ -154,7 +154,7 @@
                         if isinstance(node, jinja2.nodes.Call):
                             if isinstance(node.node, jinja2.nodes.ExtensionAttribute)\
                            and node.node.identifier == AssetsExtension.identifier:
-                                filter, output, files = node.args
+                                (filter, output), files = node.args[0:2], node.args[-1]
                                 bundle = Bundle(
                                     *AssetsExtension.resolve_contents(files.as_const(), self.asset_env),
                                     **{ 

Now that I think about it, it's somewhat fragile as it will probably fail in an unexpected way if len(node.args) > 3 and so something like

try:
    filter, output, files = node.args
except ValueError:
   filter, output, _, files = node.args

might be better as it will fail sooner if node.args contains anything other than 3 or 4 values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants