Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 24.4.2011 11:19, Thomas 'PointedEars' Lahn wrote: It is clear now that codecs.open() would not support universal newlines from at least Python 2.6 forward as it is *documented* that it opens files in *binary mode* only. The source code that I have posted shows that it therefore actively remov

Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 24.4.2011 9:05, jmfauth wrote: Use the io module. For the record, when I use io.open(file=self.path, mode="rt", encoding=enc)) as fobj: my tests are passing and everything seems to work fine. That indicates there is a bug with codecs module and universal newline support. -- S pozdrav

Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 23.4.2011 21:18, Thomas 'PointedEars' Lahn wrote: Daniel Geržo wrote: I need to detect the newline characters used in the file I am reading. For this purpose I am using the following code: def _read_lines(self): with contextlib.closing(codecs.open(self.path, &quo

Re: detecting newline character

2011-04-23 Thread Daniel Geržo
On 23.4.2011 21:33, Thomas 'PointedEars' Lahn wrote: Chris Rebert wrote: On Sat, Apr 23, 2011 at 11:09 AM, Daniel Geržo wrote: I need to detect the newline characters used in the file I am reading. For this purpose I am using the following code: def _read_lines(self):

detecting newline character

2011-04-23 Thread Daniel Geržo
Hello guys, I need to detect the newline characters used in the file I am reading. For this purpose I am using the following code: def _read_lines(self): with contextlib.closing(codecs.open(self.path, "rU")) as fobj: fobj.readlines() if isinstance(fobj.newlines, tuple):