datadesk / django-bigbuild

The open-source engine that powers bigbuilder, the Los Angeles Times Data Desk's system for publishing standalone pages
http://www.latimes.com/projects/
MIT License
24 stars 0 forks source link

bytes error with new python-frontmatter #39

Closed palewire closed 7 years ago

palewire commented 7 years ago

Python 3 builds failing now with the new python-frontmatter. Something about how it's converting our Post object for writing? Any ideas @eyeseast?

.E.
======================================================================
ERROR: setUpClass (bigbuild.tests.FakePagesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/datadesk/django-bigbuild/bigbuild/tests.py", line 79, in setUpClass
    [p.create_directory() for p in pages]
  File "/home/travis/build/datadesk/django-bigbuild/bigbuild/tests.py", line 79, in <listcomp>
    [p.create_directory() for p in pages]
  File "/home/travis/build/datadesk/django-bigbuild/bigbuild/models/pages.py", line 70, in create_directory
    self.write_frontmatter()
  File "/home/travis/build/datadesk/django-bigbuild/bigbuild/models/pages.py", line 95, in write_frontmatter
    frontmatter.dump(self, path or self.frontmatter_path)
  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/frontmatter/__init__.py", line 159, in dump
    f.write(content)
  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/codecs.py", line 718, in write
    return self.writer.write(data)
  File "/home/travis/virtualenv/python3.5.2/lib/python3.5/codecs.py", line 376, in write
    data, consumed = self.encode(object, self.errors)
TypeError: Can't convert 'bytes' object to str implicitly
----------------------------------------------------------------------
eyeseast commented 7 years ago

Yup, that's a bug. Fixing it now.

eyeseast commented 7 years ago

OK, bugfix pushed: https://pypi.python.org/pypi/python-frontmatter/0.4.2

Problem was where the exported post was getting encoded on the way out. When we already have a file descriptor, it should get encoded to bytes right as it's written. When we're opening with codecs.open, we need unicode text still.

So that's fixed now, with a new test.

palewire commented 7 years ago

Thank you.