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

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

Open
remimarenco opened this issue Jul 5, 2017 · 0 comments
Open

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

remimarenco opened this issue Jul 5, 2017 · 0 comments

Comments

@remimarenco
Copy link

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!

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

1 participant