[Svnmerge] Bug in svnmerge.py, rev 30107 (not fully compatible with Python 2.2.x)

Raman Gupta rocketraman at fastmail.fm
Tue Apr 1 21:21:22 PDT 2008


Justin Akehurst wrote:
> The problem: sys.stdout (file object) under Python 2.2.2 does not have the
> 'encoding' attribute.
> 
> My workaround:
> @@ -217,7 +217,7 @@
>      return prefix + lines[:-1].replace("\n", "\n"+prefix) + "\n"
>  
>  def recode_stdout_to_file(s):
> -    if locale.getdefaultlocale()[1] is None or sys.stdout.encoding is None:
> +    if locale.getdefaultlocale()[1] is None or not
> sys.stdout.has_attr('encoding') or sys.stdout.encoding is None:
>        return s
>      u = s.decode(sys.stdout.encoding)
>      return u.encode(locale.getdefaultlocale()[1])

Ok, but unfortunately the work-around doesn't seem to work on more
recent versions:

$ python -V
Python 2.5.1

$ python
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.stdout.has_attr('encoding')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'file' object has no attribute 'has_attr'

An other ideas?

Cheers,
Raman



More information about the Svnmerge mailing list