Przeglądaj źródła

Dpkg: Use warnings::warnif() instead of carp() for deprecated warnings

Suggested-by: Niels Thykier <niels@thykier.net>
Guillem Jover 10 lat temu
rodzic
commit
e5b4e9a0c9

+ 2 - 0
debian/changelog

@@ -1,6 +1,8 @@
 dpkg (1.18.8) UNRELEASED; urgency=medium
 
   [ Guillem Jover ]
+  * Perl modules:
+    - Use warnings::warnif() instead of carp() for deprecated warnings.
   * Documentation:
     - Improve dpkg-buildpackage(1) on environment expectations.
     - Clarify the format of the db:Status-Abbrev virtual field in

+ 6 - 3
scripts/Dpkg/Changelog/Entry/Debian.pm

@@ -29,7 +29,6 @@ our @EXPORT_OK = qw(
 );
 
 use Exporter qw(import);
-use Carp;
 use Time::Piece;
 
 use Dpkg::Gettext;
@@ -250,7 +249,9 @@ Obsolete method. Use parse_header() instead.
 sub check_header {
     my $self = shift;
 
-    carp 'obsolete check_header(), use parse_header() instead';
+    warnings::warnif('deprecated',
+                     'obsolete check_header(), use parse_header() instead');
+
     return $self->parse_header();
 }
 
@@ -263,7 +264,9 @@ Obsolete method. Use parse_trailer() instead.
 sub check_trailer {
     my $self = shift;
 
-    carp 'obsolete check_trailer(), use parse_trailer() instead';
+    warnings::warnif('deprecated',
+                     'obsolete check_trailer(), use parse_trailer() instead');
+
     return $self->parse_header();
 }
 

+ 6 - 3
scripts/Dpkg/Checksums.pm

@@ -28,7 +28,6 @@ our @EXPORT = qw(
 );
 
 use Exporter qw(import);
-use Carp;
 use Digest;
 
 use Dpkg::Gettext;
@@ -106,7 +105,11 @@ whether the checksum algorithm is considered cryptographically strong.
 
 sub checksums_get_property($$) {
     my ($alg, $property) = @_;
-    carp 'obsolete checksums program property' if $property eq 'program';
+
+    if ($property eq 'program') {
+        warnings::warnif('deprecated', 'obsolete checksums program property');
+    }
+
     return unless checksums_is_supported($alg);
     return $CHECKSUMS->{lc($alg)}{$property};
 }
@@ -405,7 +408,7 @@ New member: $ck->has_strong_checksums().
 
 =head2 Version 1.02 (dpkg 1.18.0)
 
-Obsolete property: Getting the 'program' checksum property will carp() and
+Obsolete property: Getting the 'program' checksum property will warn and
 return undef, the Digest module is used internally now.
 
 New property: Add new 'name' property with the name of the Digest algorithm

+ 2 - 4
scripts/Dpkg/Deps.pm

@@ -1337,8 +1337,6 @@ Creates a new object.
 use strict;
 use warnings;
 
-use Carp;
-
 use Dpkg::Version;
 
 sub new {
@@ -1409,8 +1407,8 @@ methods where appropriate, but it should not be directly queried.
 sub check_package {
     my ($self, $pkg) = @_;
 
-    carp 'obsolete function, pass Dpkg::Deps::KnownFacts to Dpkg::Deps ' .
-         'methods instead';
+    warnings::warnif('deprecated', 'obsolete function, pass ' .
+                     'Dpkg::Deps::KnownFacts to Dpkg::Deps methods instead');
 
     if (exists $self->{pkg}{$pkg}) {
 	return (1, $self->{pkg}{$pkg}[0]{version});

+ 2 - 2
scripts/Dpkg/Gettext.pm

@@ -160,8 +160,8 @@ sub _g ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
 {
     my $msgid = shift;
 
-    require Carp;
-    Carp::carp('obsolete _g() function, please use g_() instead');
+    warnings::warnif('deprecated',
+                     'obsolete _g() function, please use g_() instead');
 
     return g_($msgid);
 }

+ 4 - 2
scripts/Dpkg/Substvars.pm

@@ -22,7 +22,6 @@ use warnings;
 our $VERSION = '1.04';
 
 use POSIX qw(:errno_h);
-use Carp;
 
 use Dpkg ();
 use Dpkg::Arch qw(get_host_arch);
@@ -179,7 +178,10 @@ Obsolete function, use mark_as_used() instead.
 
 sub no_warn {
     my ($self, $key) = @_;
-    carp 'obsolete no_warn() function, use mark_as_used() instead';
+
+    warnings::warnif('deprecated',
+                     'obsolete no_warn() function, use mark_as_used() instead');
+
     $self->mark_as_used($key);
 }