miracle2k / flask-assets

Flask webassets integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'bytes' object has no attribute 'encode'

remimarenco opened this issue · comments

Hi!

Thanks for web-assets, it is really useful for us :).

The only issue we encountered so far is that, when we want to use a cdn (font-awesome css) and make a Bundle out of it, we seem to get an error in very specific cases (when unit testing the rendering of our pages):

app = <Flask 'depmap'>

    def test_render_view_index(app):
        """
        Test that the cell line index page renders
        """
        with app.test_client() as c:
>           r = c.get(url_for("cell_line.view_index"))
obj = <UrlHunk https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css>

    def walk(obj):
        if isinstance(obj, (tuple, list, frozenset)):
            for item in obj:
                for d in walk(item): yield d
        elif isinstance(obj, (dict)):
            for k in sorted(obj.keys()):
                for d in walk(k): yield d
                for d in walk(obj[k]): yield d
        elif isinstance(obj, BaseHunk):
>           yield obj.data().encode('utf-8')
E           AttributeError: 'bytes' object has no attribute 'encode'

../miniconda2/envs/depmap_new/lib/python3.5/site-packages/webassets/cache.py:67: AttributeError

Here is our css configuration in Bundle:

css = Bundle(
    'libs/bootstrap/dist/css/bootstrap.css',
    'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css',
    'libs/datatables-bootstrap/css/dataTables.bootstrap.min.css',
    'libs/selectize/dist/css/selectize.default.css',
    sass,
    sass_fixed_columns_datatables,
    filters='cssmin',
    output='public/css/common.css'
)

Do you know what could go wrong? Also, we are using Python 3.5 (and it seems to work fine in 2.7?)

Thanks a lot!