Bug#473254: python-debian: deb822 should use lowercase/uppercase like official Release files
jsw at debian.org
Wed Apr 2 07:30:16 UTC 2008
On Sat, Mar 29, 2008 at 05:06:57PM +0100, Julian Andres Klode wrote:
> Adeodato Simó wrote:
> > * Julian Andres Klode [Sat, 29 Mar 2008 16:31:20 +0100]:
> >> Please change fields like md5sums to MD5Sums, sha1 to SHA1 and sha256 to SHA256,
> >> so Release files created by python-debian look more like official Release files.
> > Have you tried, when creating those files, giving the names to deb822 in
> > the casing you *want*? I think it should work just fine.
> > If it doesn't, we'll look into it.
> > Cheers,
> Of course I have.
> Look here: release822 = Release(); release822['MD5Sum'] = md5sums
> The problem is in __init__:
> def __init__(self, *args, **kwargs):
> Deb822.__init__(self, *args, **kwargs)
> for field, fields in self._multivalued_fields.items():
> contents = self[field]
> except KeyError:
The problem lies in the fact that _CaseInsensitiveString (aka _strI)
caches objects. So, the first time such an object is created for a
string with a particular .lower() value, the original case referred to
will be the one that is always used. The __getitem__ method of Deb822
creates an _strI object to use as a key, so if no _strI object was
created with the desired case (e.g. no official Release file was read in
first), then the lower-case one in _multivalued_fields gets used.
Dato, there are other undesired side-effects of caching the _strI
objects that I hadn't considered before. One of my goals for deb822 is
that a dumped Deb822 object should be exactly the same as the input if
nothing has changed. But this way, if Deb822 objects are created from
two different files, and they use different case conventions, when they
are dumped, both of them will use the case conventions from the first
Was there a motivation besides memory or computational efficiency for
caching the objects? If not, would you object to my removing that chunk
of code, or at least only caching objects by their original case rather
than the "canonical" case?
John Wright <jsw at debian.org>
More information about the pkg-python-debian-maint