[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#986840: apt-listchanges fails to parse status files with ^M characters; should use apt_pkg.TagFile, not write its own parser



> As reported in
> https://bugs.launchpad.net/ubuntu/+source/apt-listchanges/+bug/1854772,
> apt-listchanges
> fails to parse status files that contain carriage return characters, as
> Python normalizes the line endings.

I'm tracking the downstream bug in Ubuntu as well as this one.

> Instead of writing its own ad-hoc parser, apt-listchanges should use
> apt_pkg.TagFile instead.

I did a little bit of digging into how to rewrite the parser with your
suggested changes.  I agree that apt-listchanges should not be using its
own parser, especially since a standardized one exists in apt_pkg.

Preliminarily, I have these changes in mind for
apt_listchanges.ControlParser.readfile() (spacing adjusted for brevity):

```python
...
try:
  with apt_pkg.TagFile(file) as tagfile:
    for section in tagfile:
      self.stanzas += [ControlStanza(x) for x in section]
except: ...      
```

There also, at the very least, may need a change to be made to
apt_listchanges.DebianFiles.ControlParser.readdeb() as well.  I'm hoping 
that we can avoid rewriting some of the classes in
apt_listchanges.DebianFiles, namely ControlParser and ControlStanza.

If you have suggestions on how the change would look, please let me
know.

-- 
Best regards,

Brian T

Attachment: signature.asc
Description: PGP signature


Reply to: