[prev in list] [next in list] [prev in thread] [next in thread] 

List:       darcs-devel
Subject:    [darcs-devel] [issue1655] warnings should go to stderr
From:       Zooko <bugs () darcs ! net>
Date:       2009-10-25 15:47:38
Message-ID: 1256485658.27.0.727154493415.issue1655 () darcs ! net
[Download RAW message or body]


Zooko <zooko@zooko.com> added the comment:

So it turns out that this breaks my darcsver tool (in the case that there are crc errors 
present).

With darcs-2.2.0 installed:

-------
$ python setup.py darcsver
running darcsver
setup.py darcsver: wrote '0.9.35' into _version.py
-------

After upgrading to 2.3.1+271 patches it gets a parse error since the stdout is no longer well-
formed XML:

-------
$ python setup.py darcsver
running darcsver
Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    'License :: GNU General Public License',
  File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.6/dist-packages/darcsver-unknown-
py2.6.egg/darcsver/setuptools_command.py", line 77, in run
    (rc, verstr) = darcsvermodule.update(self.project_name, self.version_file, 
self.count_all_patches, abort_if_snapshot=self.abort_if_snapshot, loud=loud, EXE_NAME="setup.py 
darcsver")
  File "/usr/local/lib/python2.6/dist-packages/darcsver-unknown-
py2.6.egg/darcsver/darcsvermodule.py", line 112, in update
    doc = xml.dom.minidom.parseString(output)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: junk after document element: line 288, column 0
-------

The tail of the string that it attempted to parse looks like this:

<name>Document the &apos;overwrite-tags&apos; for git</name>\n-<comment>Also, emit a critical 
log indicating the possible source of the\nproblem, mentioning the 
option.</comment>\n</patch>\n</changelog>\n\nWarning: CRC errors found. These are probably 
harmless but should be repaired.\nSee 'darcs gzcrcs --help' for more information.\n\n

I've made a new version of darcsver which before XML parsing scans for "</changelog>" and 
strips off everything which follows it.  That appears to restore darcsver to correct behavior 
in this case.

If you're planning to release another stable in the 2.3 series then if you could move that 
warning from stdout to stderr this would allow the current version of darcsver to continue to 
work.  (This could be useful because, for example, some of my projects have a copy of darcsver 
bundled in with the project's own source code, so it will continue to be using the old version 
of darcsver even after I've published a newer one with this work-around.)

In any case, in the future it might be convenient if darcs uses stderr for warnings, 
exceptions, errors, and "communication to the user" and reserves stdout for a structured value 
that can be consumed programmatically (when that makes sense).

__________________________________
Darcs bug tracker <bugs@darcs.net>
<http://bugs.darcs.net/issue1655>
__________________________________
_______________________________________________
darcs-devel mailing list (AUTOMATIC POSTINGS ONLY PLEASE!)
darcs-devel@darcs.net
http://lists.osuosl.org/mailman/listinfo/darcs-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic