On Mar 8, 2015, at 3:26 AM, Glyph
wrote: On Mar 8, 2015, at 3:03 AM, Adi Roiban
mailto:adi@roiban.ro> wrote: Hi,
I am trying to help porting Twisted on Py3 and for me the fact that FilePath requires all paths to be bytes is a constant pain.
To reduce the Unicode pain when working with string my principle is to do all internal operations in Unicode and then convert to bytes only at input and output.
Right now I am trying to port t.p.moduled and when using the current implementation of FilePath I have to constantly encode/decode path. I would prefer not to consider the FilePath an input/output level.
Does anyone find this useful and plan to use FilePath with bytes in another Python3 project?
What do you say if we will also have an UnicodeFilePath class which only accept Unicode as path input and only outputs Unicode?
It can start with simple path traversal/directory creation/file creation just to have t.p.moduled (and trial) ported.
This approach to unicode support in FilePath is wrong, but when I went to go looking, I realized that there is no comprehensive ticket that outlines how FilePath should support unicode, so I have nothing to refer you to for how to do it correctly.
I more or less figured this out a long time ago and I have been talking about it for years, and the lack of a write-up is a terrible oversight. I'm sorry about that.
I'm going to go file a ticket now with a specification for this, and I'll post a link as soon as it's done.
Now written in ticket form: https://twistedmatrix.com/trac/ticket/7805 https://twistedmatrix.com/trac/ticket/7805 In short, "FilePath should return the type you give its constructor from all of its public methods, and use an internal representation appropriate to the platform it's running on." -glyph