mercurial.ui.ui requires sys.stdout to have a closed attribute.

Roger Gammans rgammans at computer-surgery.co.uk
Fri Jan 1 16:07:50 CST 2010


Hi,

To expand on the subject, mercurial.ui.ui.warn() call
sys.stderr.closed() but the closed() method is documented 
(http://docs.python.org/library/stdtypes.html#file.closed )  as not
being provided for all file like objects.

This hits any uses of mercurial from inside a bpython shell, which
does not provide the closed() method, for it's redirected sys.stderr .

eg.
>>> import mercurial
>>> import mercurial.ui
>>> ui = mercurial.ui.ui()
>>> ui.warn("foo")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/pymodules/python2.5/mercurial/ui.py", line 313, in warn
    self.write_err(*msg)
  File "/usr/lib/pymodules/python2.5/mercurial/ui.py", line 234, in
write_err
    if not sys.stdout.closed: sys.stdout.flush()
AttributeError: 'Repl' object has no attrib

I have raised this in bpython as a fault there , but they point out
that file-like objects are not guaranteed / required to provide closed

TTFN

-- 
Roger Gammans <rgammans at computer-surgery.co.uk>


More information about the Mercurial mailing list