[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-181-g9f7c87d
Sandro Tosi
morph at debian.org
Sun Apr 24 23:44:28 UTC 2011
The following commit has been merged in the master branch:
commit eb049967aa02415504fb328dd8f47127fbf6b938
Author: Sandro Tosi <morph at debian.org>
Date: Mon Apr 25 01:19:34 2011 +0200
the followup information must be an integer: try to convert it or raise an exception; prevents a crash when following-up to an existing report using GTK+ UI; thanks to all the reporters; Closes: #619801
diff --git a/debian/changelog b/debian/changelog
index e026651..21a79e1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,8 +12,12 @@ reportbug (5.1) UNRELEASED; urgency=low
- check if there are no reports (or a problem occurred), than don't try to
parse the bugs list; thanks to Erik de Castro Lopo for the report;
Closes: #622338
+ * reportbug/bugreport.py + unittests
+ - the followup information must be an integer: try to convert it or raise an
+ exception; prevents a crash when following-up to an existing report using
+ GTK+ UI; thanks to all the reporters; Closes: #619801
- -- Sandro Tosi <morph at debian.org> Sun, 24 Apr 2011 10:59:22 +0200
+ -- Sandro Tosi <morph at debian.org> Mon, 25 Apr 2011 01:17:51 +0200
reportbug (5.0) unstable; urgency=low
diff --git a/reportbug/bugreport.py b/reportbug/bugreport.py
index 0a96f49..a59220b 100644
--- a/reportbug/bugreport.py
+++ b/reportbug/bugreport.py
@@ -48,7 +48,16 @@ class bugreport(object):
setattr(self, k, v)
self.package = package
self.subject = subject
- self.followup = followup
+ # try to convert followup to int (if it's not already), TypeError if
+ # the conversion is impossible
+ if not isinstance(followup, int):
+ try:
+ self.followup = int(followup)
+ except TypeError:
+ ui.long_message('Invalid value for followup, it must be an integer')
+ raise TypeError
+ else:
+ self.followup = followup
self.body = body
self.mode = mode
self.system = system
diff --git a/test/test_bugreport.py b/test/test_bugreport.py
index 2a5ef63..b7b9352 100644
--- a/test/test_bugreport.py
+++ b/test/test_bugreport.py
@@ -24,3 +24,15 @@ class TestBugreport(unittest2.TestCase):
self.assertIn('Followup-For: Bug #123456', self.text)
self.assertNotIn('Severity: ', self.text)
+
+ # test also a string as followup, and a datatype unconvertible to int
+ self.report = bugreport(package=self.package, body=self.body,
+ followup='123456')
+ self.text = self.report.__unicode__()
+
+ self.assertIn('Followup-For: Bug #123456', self.text)
+ self.assertNotIn('Severity: ', self.text)
+
+ with self.assertRaises(TypeError):
+ self.report = bugreport(package=self.package, body=self.body,
+ followup={'123456': 654321})
diff --git a/test/test_utils.py b/test/test_utils.py
index 46df50f..39edc8f 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -353,6 +353,22 @@ Shell: /bin/sh linked to /bin/bash"""
self.assertIn('Version: 1.2.3', report)
self.assertIn('Severity: normal', report)
+ # test with exinfo (represents the bug number if this is a followup):
+ # int, string, unconvertible (to int) datatype
+ report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
+ '', '', '', type='debbugs',
+ exinfo=123456)
+ self.assertIn('Followup-For: Bug #123456', report)
+
+ report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
+ '', '', '', type='debbugs',
+ exinfo='123456')
+ self.assertIn('Followup-For: Bug #123456', report)
+
+ with self.assertRaises(TypeError):
+ report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
+ '', '', '', type='debbugs',
+ exinfo={'123456': ''})
class TestConfig(unittest2.TestCase):
--
Reportbug - reports bugs in the Debian distribution
More information about the Reportbug-commits
mailing list