-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Correctly pass newline
parameter to built-in open
function
#478
Conversation
e0a1a24
to
cc0d281
Compare
I've pushed some changes to polish up your PR. Can you please run the tests on your end and confirm that they pass? In the future, we'll really need to run tests on Windows as part of our CI. #161 |
open
behaviour of new lines under windowsnewline
parameter to built-in open
function
Thank you for the edits. I now remember, why temprorary files are quite nasty under Windows 🔥
This is the reason, why the test fails atm. What do you think ? |
Can you please tweak the test so that it passes? I can't reproduce the problem without Windows, unfortunately. I'd do something like this: import contextlib
@contextlib.contextmanager
def win_compatible_tempfile(mode):
with tempfile.NamedTemporaryFile(mode, delete=False) as f:
try:
yield f
finally:
f.close()
os.unlink(f.name) based on this comment bravoserver/bravo#111 (comment) |
Please pull from develop and look for a function called named_temporary_file. Use it to work around the problem. |
Thank you for your suggestions and improvements. The test is green (at least locally.). Sorry, it took so long to respond. |
CHANGELOG.md
Outdated
@@ -1,7 +1,11 @@ | |||
# Unreleased | |||
|
|||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a merge conflict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oi! Thanks, strangely git status
didn't told me.
Finally got around to merging this. Good work @burkovae , and congrats on your first PR to smart_open! 🥇 |
Motivation
It appears, that
newline
parameter is missing when smart_open uses the buildinopen
method.This one is essential, e.g. when writing csv files under windows
csv
module is inconsistent with traditionalopen
behaviour #477Tests
See test case.
kw
and removed it as well, no harm done ❤️Checklist
Before you create the PR, please make sure you have: