-
Notifications
You must be signed in to change notification settings - Fork 71
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
python-unidiff silently fails on string objects #26
Comments
Yeah, I agree. Thanks for reporting the issue. I guess you already worked-around the issue, but FTR until this gets fixed, PatchSet expects a file-like object (so you could use StringIO to build a file-like object from the string). |
This still isn't working for me on the new version, but piping from curl into the CLI version does. Any advice? |
update: |
(I see now this was the intended behavior, but it is confusing) Would you accept a patch that infers the type in the constructor and acts accordingly? |
Right, PatchSet still expects a file-like object, but there is a new constructor, from_string:
But it's true that it could fail if there is no file, instead of returning an empty PatchSet. A patch would be welcome! Just in case, it should keep backwards compatibility. |
can probably close this, may want to document the new usage |
i generally prefer explicit factories (from_string, from_bytes) over inferred behavior. things like multiple inheritance, builtins, isinstance can be tricky/break things when automagically deducing argument types - especially where strings are involved |
Tried:
I would expect some kind of error message, since this is very misleading (internally python-unidiff iterates char-by-char over the string, and thus finds no patches)
The text was updated successfully, but these errors were encountered: