engelbert gruber | 4 Jun 2011 16:40
Picon
Gravatar

Tee encoding

hei everyone,

while on bugfixtour in the manpage-writer alltests.py did report ::

  ======================================================================
  ERROR: test_functional.py: functional/tests/standalone_rst_manpage.py
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/Users/engelbert/projects/docutils/trunk/docutils/test/test_functional.py",
line 197, in test
      diff = diff.encode(sys.stderr.encoding or 'ascii', 'replace')
  AttributeError: Tee instance has no attribute 'encoding'

running functional alone reports the errors in manpage-writer.

my quick fix was ::

  class Tee:

      """Write to a file and a stream (default: stdout) simultaneously."""

      def __init__(self, filename, stream=sys.__stdout__):
          self.file = open(filename, 'w')
          self.stream = stream
  +        self.encoding = stream.encoding

      def write(self, string):
          self.stream.write(string)
          self.file.write(string)

(Continue reading)

Guenter Milde | 4 Jun 2011 23:59
Picon

Re: Tee encoding

On 2011-06-04, engelbert gruber wrote:
> hei everyone,

> while on bugfixtour in the manpage-writer alltests.py did report ::

>  ======================================================================
>   ERROR: test_functional.py: functional/tests/standalone_rst_manpage.py
>   ----------------------------------------------------------------------
>   Traceback (most recent call last):
>     File "/Users/engelbert/projects/docutils/trunk/docutils/test/test_functional.py",
> line 197, in test
>       diff = diff.encode(sys.stderr.encoding or 'ascii', 'replace')
>   AttributeError: Tee instance has no attribute 'encoding'

> running functional alone reports the errors in manpage-writer.

> my quick fix was ::

>   class Tee:

>       """Write to a file and a stream (default: stdout) simultaneously."""

>       def __init__(self, filename, stream=sys.__stdout__):
>           self.file = open(filename, 'w')
>           self.stream = stream
>   +        self.encoding = stream.encoding

>       def write(self, string):
>           self.stream.write(string)
>           self.file.write(string)
(Continue reading)


Gmane