Closed jayvdb closed 7 years ago
Sure, let's fix pyficache. I believe Universal Newline Support or PEP-0278 works on both Python 2 and Python 3. Basically one opens a file with mode 'rU', for example f = open('/tmp/foo.py', 'rU')
.
And this can be added as an option for compatibility.
Would you care to submit a patch?
One other feature I have been meaning to add is this feature to return the file size (mod 2**32) as listed in the compiled binary which can be used to verify that code source matches a file found on disk. So a release with these two feature would come out soon.
Python 2 supports universal new lines, but this Python 3 only newlines
parameter does not exist in Python 2, but ... there is a newline
attribute ... and that could be sufficient for my needs if it is exposed.
Ok, I'll submit a patch shortly.
Thanks for handling.
@jayvdb Just reworked the change so we don't get the deprecation warning. Please review 490cfe5 . If that's okay, I'll make another release.
I am looking for a file (line) cache that can open files with the real EOL bytes preserved. In Python 3, this can be achieved using
open(..., newline='')
.The primary need is https://github.com/coala/coala-bears/issues/815 , which is influencing the technical requirements for our file cache rewrite (https://github.com/coala/cEPs/pull/31).
As I only need Python 3 support, a very hacky approach is to allow the client to pass parameters to the
open
call inupdate_cache
, currently at line 540.The alternative is to add a newline parameter/option to
opts
everywhere, using the Python 3 functionality, and either raiseNotImplementedError
on Python 2 or use/build a backport of the Python 3 newline mode when on Python 2.Keen to know your thoughts on how I should proceed.