[Twisted-Python] t.p.filepath and Unicode

2015-03-08 Thread Adi Roiban
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.

Thanks!
-- 
Adi Roiban

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.p.filepath and Unicode

2015-03-08 Thread Glyph

 On Mar 8, 2015, at 3:03 AM, Adi Roiban a...@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.

-glyph___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.p.filepath and Unicode

2015-03-08 Thread Wolfgang Rohdewald
Am Sonntag, 8. März 2015, 12:30:38 schrieben Sie:
 Some months ago someone outlined his idea, I believe in the mailing
 list in a thread I participated in.

should have tried to find it before posting.

That was Glyph On Sep 9, 2014, at 08:01 with the subject

Re: [Twisted-Python] Python3: should paths be bytes or str?

-- 
Wolfgang

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.p.filepath and Unicode

2015-03-08 Thread Glyph

 On Mar 8, 2015, at 3:26 AM, Glyph gl...@twistedmatrix.com wrote:
 
 
 On Mar 8, 2015, at 3:03 AM, Adi Roiban a...@roiban.ro 
 mailto:a...@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

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] t.p.filepath and Unicode

2015-03-08 Thread Wolfgang Rohdewald
Am Sonntag, 8. März 2015, 10:03:03 schrieb Adi Roiban:
 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.
 
 Thanks!
 

Some months ago someone outlined his idea, I believe in the mailing
list in a thread I participated in. I do not remember who it
was. IIRC, the plan was that FilePath accepts all types of string. It 
keeps a 1:1 copy of that string and has attributes returning the
variant that the caller needs, converting on the fly.


There also is bug report 7166.

-- 
Wolfgang

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python