Ticket #406 (closed defect: wontfix)

Opened 2 years ago

Last modified 18 months ago

LazyWriter does not have a closed attribute

Reported by: k0s Owned by: ianb
Priority: normal Milestone: 1.4.1
Component: paste Version: released-version
Severity: normal Keywords:
Cc:

Description

This could actually a mercurial bug or, more likely, a bug in Paste and mercurial.

The symptom is as follows. Using hgpaste ( http://k0s.org/hg/hgpaste/) to serve hg using the paste web server, adding an hgrc file to the project serve gives a very strange error in the paste log file:

Traceback (most recent call last):
  File "/home/jhammel/web/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 1062, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.5/SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.5/SocketServer.py", line 522, in __init__
    self.handle()
  File "/home/jhammel/web/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 436, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.5/BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "/home/jhammel/web/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 431, in handle_one_request
    self.wsgi_execute()
  File "/home/jhammel/web/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/home/jhammel/web/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/urlmap.py", line 202, in __call__
    return app(environ, start_response)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/hgweb/hgwebdir_mod.py", line 74, in __call__
    self.run_wsgi(req)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/hgweb/hgwebdir_mod.py", line 120, in run_wsgi
    repo = hg.repository(self.parentui, real)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/hg.py", line 60, in repository
    repo = _lookup(path).instance(ui, path, create)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/localrepo.py", line 2135, in instance
    return localrepository(ui, util.drop_scheme('file', path), create)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/localrepo.py", line 90, in __init__
    extensions.loadall(self.ui)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/extensions.py", line 86, in loadall
    % (name, inst))
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/ui.py", line 445, in warn
    self.write_err(*msg)
  File "/home/jhammel/web/lib/python2.5/site-packages/mercurial-1.0.1-py2.5-linux-i686.egg/mercurial/ui.py", line 388, in write_err
    if not sys.stdout.closed: sys.stdout.flush()
AttributeError: 'LazyWriter' object has no attribute 'closed'
----------------------------------------

(I am not sure why mercurial needs to see if stdout is closed or if to flush it). I have fixed this by adding a closed attribute to paste.script.serve.LazyWriter. I made it False, but it would probably work fine in either case.

class LazyWriter(object):

    """
    File-like object that opens a file lazily when it is first written
    to.
    """
    closed = False
    def __init__(self, filename, mode='w'):

Change History

Changed 18 months ago by ianb

  • status changed from new to closed
  • resolution set to wontfix

I'm not sure why sys.stdout is a LazyWriter? object, but WSGI file objects are not required to have a closed attribute. So something odd is happening with hg.

Note: See TracTickets for help on using tickets.