[python-debian/master] Use the warnings system to report deprecation warnings
John Wright
jsw at debian.org
Tue Mar 16 01:32:15 UTC 2010
All of the function deprecation warnings were already using this system.
Unfortunately, the warnings for using debian instead of debian_bundle
and debian.deb822 instead of deb822 were just prints to sys.stdout, so
they were not easily filtered.
Closes: #573945
---
debian/changelog | 2 ++
lib/deb822.py | 8 ++++----
lib/debian_bundle/__init__.py | 6 +++---
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 4b2534b..79b460a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ python-debian (0.1.16) UNRELEASED; urgency=low
apt_pkg is not availble
* test_deb822.py: Don't test gpg info if debian-keyring is not
available (Closes: #573934)
+ * Use the warnings system to report deprecation warnings
+ (Closes: #573945)
-- John Wright <jsw at debian.org> Sun, 14 Mar 2010 05:31:54 -0600
diff --git a/lib/deb822.py b/lib/deb822.py
index 6dc74ec..cdf5bdc 100644
--- a/lib/deb822.py
+++ b/lib/deb822.py
@@ -1,6 +1,6 @@
-import sys
-print >> sys.stderr, "WARNING:", \
- "the 'deb822' top-level module is *DEPRECATED*,", \
- "please use 'debian.deb822'"
+import warnings
+
+warnings.warn("please use 'debian.deb822' instead", DeprecationWarning,
+ stacklevel=2)
from debian.deb822 import *
diff --git a/lib/debian_bundle/__init__.py b/lib/debian_bundle/__init__.py
index 05b5b83..13db9db 100644
--- a/lib/debian_bundle/__init__.py
+++ b/lib/debian_bundle/__init__.py
@@ -1,8 +1,8 @@
import os
-import sys
+import warnings
-sys.stderr.write("WARNING: the 'debian_bundle' package is *DEPRECATED*; "
- "use the 'debian' package\n")
+warnings.warn("please use 'debian' instead of 'debian_bundle'",
+ DeprecationWarning, stacklevel=2)
# Support "from debian_bundle import foo"
parent_dir = os.path.dirname(__path__[0])
--
1.6.3.3
More information about the pkg-python-debian-commits
mailing list