Bug#590805: Updated patch

2010-08-08 Thread Jelmer Vernooij
Hi John,

On Tue, 2010-08-03 at 23:25 -0700, John Wright wrote:
 On Mon, Aug 02, 2010 at 10:24:24PM +0200, Jelmer Vernooij wrote:
  On Sun, 2010-08-01 at 01:40 -0700, John Wright wrote:
   On Fri, Jul 30, 2010 at 12:45:07PM +0200, Jelmer Vernooij wrote:
Attached patch updates the changelog as well and removes the conflict
with older versions of apt.
   Thanks - how about this one?  It's a little simpler since the only thing
   we use apt_pkg for in deb822 is TagFile.
  Nice, I hadn't thought of that.
  
   Also...are you just using the deb822 module on its own?  There are
   plenty of dependencies in python-debian that aren't satisfiable in
   Dapper.  Also, I just added a feature that depends on UnicodeWarning
   being available, but that's only in python2.5.  Thinking about it,
   though, it's better to make a new warning class anyway, hence the second
   patch.  With both patches, I think at least deb822 should work fine in a
   Dapper environment.
  We're using Python2.5 on Hardy at the moment, and will hopefully be
  switching to the next LTS (Lucid) in a couple of months. Sorry if I said
  dapper.
 Ah, ok.  I'm rethinking the second patch - UnicodeWarning, according to
 the Python documentation, is actually intended as a base category for
 unicode related warnings, which this is...and if you don't need
 python2.4 support, there's no need to rip it out.  (The What's new in
 Python 2.5 document suggested that the warning was intended for a very
 specific problem, but the warning categories documentation makes it seem
 more general.)
Ok, I'll leave that alone for now. We only care about = 2.5 support. 

   Shall I commit?
  Please do, thanks!
 Ok, no problem. :)
Thanks!

Cheers,

Jelmer



signature.asc
Description: This is a digitally signed message part


Bug#590805: Updated patch

2010-08-04 Thread John Wright
On Mon, Aug 02, 2010 at 10:24:24PM +0200, Jelmer Vernooij wrote:
 On Sun, 2010-08-01 at 01:40 -0700, John Wright wrote:
  On Fri, Jul 30, 2010 at 12:45:07PM +0200, Jelmer Vernooij wrote:
   Attached patch updates the changelog as well and removes the conflict
   with older versions of apt.
  Thanks - how about this one?  It's a little simpler since the only thing
  we use apt_pkg for in deb822 is TagFile.
 Nice, I hadn't thought of that.
 
  Also...are you just using the deb822 module on its own?  There are
  plenty of dependencies in python-debian that aren't satisfiable in
  Dapper.  Also, I just added a feature that depends on UnicodeWarning
  being available, but that's only in python2.5.  Thinking about it,
  though, it's better to make a new warning class anyway, hence the second
  patch.  With both patches, I think at least deb822 should work fine in a
  Dapper environment.
 We're using Python2.5 on Hardy at the moment, and will hopefully be
 switching to the next LTS (Lucid) in a couple of months. Sorry if I said
 dapper.

Ah, ok.  I'm rethinking the second patch - UnicodeWarning, according to
the Python documentation, is actually intended as a base category for
unicode related warnings, which this is...and if you don't need
python2.4 support, there's no need to rip it out.  (The What's new in
Python 2.5 document suggested that the warning was intended for a very
specific problem, but the warning categories documentation makes it seem
more general.)

  Shall I commit?
 Please do, thanks!

Ok, no problem. :)

-- 
John Wright j...@debian.org



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#590805: Updated patch

2010-08-02 Thread Jelmer Vernooij
On Sun, 2010-08-01 at 01:40 -0700, John Wright wrote:
 On Fri, Jul 30, 2010 at 12:45:07PM +0200, Jelmer Vernooij wrote:
  Attached patch updates the changelog as well and removes the conflict
  with older versions of apt.
 Thanks - how about this one?  It's a little simpler since the only thing
 we use apt_pkg for in deb822 is TagFile.
Nice, I hadn't thought of that.

 Also...are you just using the deb822 module on its own?  There are
 plenty of dependencies in python-debian that aren't satisfiable in
 Dapper.  Also, I just added a feature that depends on UnicodeWarning
 being available, but that's only in python2.5.  Thinking about it,
 though, it's better to make a new warning class anyway, hence the second
 patch.  With both patches, I think at least deb822 should work fine in a
 Dapper environment.
We're using Python2.5 on Hardy at the moment, and will hopefully be
switching to the next LTS (Lucid) in a couple of months. Sorry if I said
dapper.

 Shall I commit?
Please do, thanks!

Cheers,

Jelmer


signature.asc
Description: This is a digitally signed message part


Bug#590805: Updated patch

2010-08-01 Thread John Wright
On Fri, Jul 30, 2010 at 12:45:07PM +0200, Jelmer Vernooij wrote:
 Attached patch updates the changelog as well and removes the conflict
 with older versions of apt.

Thanks - how about this one?  It's a little simpler since the only thing
we use apt_pkg for in deb822 is TagFile.

Also...are you just using the deb822 module on its own?  There are
plenty of dependencies in python-debian that aren't satisfiable in
Dapper.  Also, I just added a feature that depends on UnicodeWarning
being available, but that's only in python2.5.  Thinking about it,
though, it's better to make a new warning class anyway, hence the second
patch.  With both patches, I think at least deb822 should work fine in a
Dapper environment.

Shall I commit?

-- 
John Wright j...@debian.org
From 67702928d49e3381f8c39c954da231c1ce0c82a1 Mon Sep 17 00:00:00 2001
From: John Wright j...@debian.org
Date: Sun, 1 Aug 2010 01:06:42 -0700
Subject: [PATCH 1/2] Support installation together with older versions of python-apt

The deb822 module only uses apt_pkg for its TagFile interface, which is
only supported in later versions of python-apt.  But it's simple enough
to detect whether TagFile is available and fall back to the native
parser, rather than conflicting with earlier versions of python-apt.

Original patch by Jelmer Vernooij.

Closes: #590805
---
 debian/changelog |7 +++
 debian/control   |4 ++--
 lib/debian/deb822.py |4 +++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 7e1188a..5d164a5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-debian (0.1.18) UNRELEASED; urgency=low
+
+  * Support installation together with older versions of python-apt.
+Original patch by Jelmer Vernooij. (Closes: #590805)
+
+ -- John Wright j...@debian.org  Sun, 01 Aug 2010 01:01:41 -0700
+
 python-debian (0.1.17) unstable; urgency=low
 
   [ James Westby ]
diff --git a/debian/control b/debian/control
index d52ab3e..e8ad071 100644
--- a/debian/control
+++ b/debian/control
@@ -20,10 +20,10 @@ Depends: ${python:Depends}, ${misc:Depends}, python-chardet
 Recommends: python-apt
 Suggests: gpgv
 Provides: python-deb822
-Conflicts: python-deb822, python-apt ( 0.7.94~)
+Conflicts: python-deb822
 Replaces: python-deb822
 Description: Python modules to work with Debian-related data formats
- This package provides Python modules that abstract many formats of Debian 
+ This package provides Python modules that abstract many formats of Debian
  related files. Currently handled are:
   * Debtags information (debian.debtags module)
   * debian/changelog (debian.changelog module)
diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py
index 1a21e62..a0cad69 100644
--- a/lib/debian/deb822.py
+++ b/lib/debian/deb822.py
@@ -26,8 +26,10 @@ from deprecation import function_deprecated_by
 
 try:
 import apt_pkg
+# This module uses apt_pkg only for its TagFile interface.
+apt_pkg.TagFile
 _have_apt_pkg = True
-except ImportError:
+except (ImportError, AttributeError):
 _have_apt_pkg = False
 
 import chardet
-- 
1.7.1

From 251967b8cf08cfb7acde8602977b83a2f8ec2619 Mon Sep 17 00:00:00 2001
From: John Wright j...@debian.org
Date: Sun, 1 Aug 2010 01:25:36 -0700
Subject: [PATCH 2/2] Use our own warning class when auto-detecting string encoding

We used UnicodeWarning initially, but that has specific meaning in the
Python documentation.  Furthermore, it's not available in Python 2.4,
and while for Debian we don't need to support older Python versions,
this is the first 2.5-specific dependency in the deb822 module, and it
doesn't provide any benefit.
---
 debian/changelog |1 +
 lib/debian/deb822.py |7 ++-
 tests/test_deb822.py |3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5d164a5..01f7732 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ python-debian (0.1.18) UNRELEASED; urgency=low
 
   * Support installation together with older versions of python-apt.
 Original patch by Jelmer Vernooij. (Closes: #590805)
+  * Use our own warning class when auto-detecting string encoding.
 
  -- John Wright j...@debian.org  Sun, 01 Aug 2010 01:01:41 -0700
 
diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py
index a0cad69..500cbda 100644
--- a/lib/debian/deb822.py
+++ b/lib/debian/deb822.py
@@ -42,6 +42,11 @@ import warnings
 import StringIO
 import UserDict
 
+
+class Deb822EncodingWarning(Warning):
+Attempting to detect string encoding using chardet
+
+
 class TagSectionWrapper(object, UserDict.DictMixin):
 Wrap a TagSection object, using its find_raw method to get field values
 
@@ -188,7 +193,7 @@ class Deb822Dict(object, UserDict.DictMixin):
 # user specified.  Try detecting it.
 warnings.warn('decoding from %s failed; attempting to detect '
   'the true encoding' % self.encoding,
- 

Bug#590805: Updated patch

2010-07-30 Thread Jelmer Vernooij
Attached patch updates the changelog as well and removes the conflict
with older versions of apt.
=== modified file 'debian/changelog'
--- debian/changelog	2010-07-25 09:13:26 +
+++ debian/changelog	2010-07-30 10:43:52 +
@@ -10,7 +10,11 @@
   useful for files containing multiple deb822 paragraphs with mixed
   encodings, like etch's Sources file. (Closes: #586021)
 
- -- John Wright j...@debian.org  Sun, 25 Jul 2010 02:07:11 -0700
+  [ Jelmer Vernooij ]
+  * Support installation together with older versions of python-apt.
+Closes: #590805
+
+ -- Jelmer Vernooij jel...@debian.org  Fri, 30 Jul 2010 12:43:52 +0200
 
 python-debian (0.1.16) unstable; urgency=low
 

=== modified file 'debian/control'
--- debian/control	2010-07-25 08:46:02 +
+++ debian/control	2010-07-30 10:42:35 +
@@ -20,10 +20,10 @@
 Recommends: python-apt
 Suggests: gpgv
 Provides: python-deb822
-Conflicts: python-deb822, python-apt ( 0.7.94~)
+Conflicts: python-deb822
 Replaces: python-deb822
 Description: Python modules to work with Debian-related data formats
- This package provides Python modules that abstract many formats of Debian 
+ This package provides Python modules that abstract many formats of Debian
  related files. Currently handled are:
   * Debtags information (debian.debtags module)
   * debian/changelog (debian.changelog module)

=== modified file 'lib/debian/deb822.py'
--- lib/debian/deb822.py	2010-07-25 08:46:02 +
+++ lib/debian/deb822.py	2010-07-30 10:43:14 +
@@ -297,7 +297,8 @@
 necessary in order to properly interpret the strings.)
 
 
-if _have_apt_pkg and use_apt_pkg and isinstance(sequence, file):
+if (_have_apt_pkg and use_apt_pkg and isinstance(sequence, file) and
+getattr(apt_pkg, TagFile, None) is not None):
 parser = apt_pkg.TagFile(sequence)
 for section in parser:
 yield cls(fields=fields, _parsed=TagSectionWrapper(section),



signature.asc
Description: This is a digitally signed message part