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

template_to_file turns CR+LF into CR+CR+LF on windows #234

Closed
sqlalchemy-bot opened this issue Oct 20, 2014 · 11 comments
Closed

template_to_file turns CR+LF into CR+CR+LF on windows #234

sqlalchemy-bot opened this issue Oct 20, 2014 · 11 comments
Labels

Comments

@sqlalchemy-bot
Copy link

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Migrated issue, originally created by Sebastian Bank (@xflr6)

Under Python 2.7, the files created by alembic revision have CR+CR+LF line endings.

Mako opens the template with mode rb, while alembic uses w producing the extra CRs.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

  • Revision files are now written out using the 'wb' modifier to
    open(), since Mako reads the templates with 'rb', thus preventing
    CRs from being doubled up as has been observed on windows.
    fixes #234

d81619b

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

easy enough, thanks!

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Sebastian Bank (@xflr6) wrote:

Thanks, I was not 100% sure this works with Py3 (does Template.render() return bytes under Py3?)

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

it does not.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to reopened
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

(work, that is. dont know why yet)

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Sebastian Bank (@xflr6) wrote:

Sadly, b does something different on Py3. I guess, one could try to use io.open (which is the same under 2 and 3) or do encode('utf-8') prior to writing.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

Revision files are now written out using the 'wb' modifier to
open(), since Mako reads the templates with 'rb', thus preventing
CRs from being doubled up as has been observed on windows. The encoding
of the output now defaults to 'utf-8', which can be configured using
a newly added config file parameter output_encoding.
fixes #234

fd2a172

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot sqlalchemy-bot commented Oct 20, 2014

Michael Bayer (@zzzeek) wrote:

it didn't work because render() passes out a Python unicode and then Py3k with the 'wb' just...not sure, wrote out nothing. So now we write out with 'wb' and set the encoding explicitly, defaults to utf-8, can be set with "output_encoding" in the .ini file.

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

Successfully merging a pull request may close this issue.

None yet
1 participant