Index: Glib.pm =================================================================== --- Glib.pm (revision 1084) +++ Glib.pm (working copy) @@ -89,8 +89,20 @@ package Glib::Error; +# location() is normally the perl "at filename.pl line 123" string with the +# filename part as raw bytes. Put it through filename_display_name() before +# combining with the wide-char message() part. A plain "." concat would +# only do utf8::upgrade(), which would mean always treating the filename +# bytes as latin-1. +# use overload - '""' => sub { $_[0]->message.$_[0]->location }, + '""' => sub { + my $location = $_[0]->location; + unless (utf8::is_utf8($location)) { + $location = Glib::filename_display_name($location); + } + return $_[0]->message . $location + }, fallback => 1; sub location { $_[0]->{location} } @@ -662,7 +674,7 @@ =head1 COPYRIGHT AND LICENSE -Copyright 2003-2008 by muppet and the gtk2-perl team +Copyright 2003-2009 by muppet and the gtk2-perl team This library is free software; you can redistribute it and/or modify it under the terms of the Lesser General Public License (LGPL). For Index: t/d.t =================================================================== --- t/d.t (revision 1084) +++ t/d.t (working copy) @@ -23,7 +23,11 @@ is ($ ->domain, 'g_convert_error', 'error domain (implies class)'); ok ($ ->message, "should have an error message, may be translated"); ok ($ ->location, "should have an error location, may be translated"); -is ($@, $ ->message $ ->location, "stringification operator is overloaded"); +{ my $expect = $ ->message; + # location part utf8-ized by filename_display_name, bit hard to check what + # that should come out as + like ($@, qr/\Q$expect/, "stringification operator is overloaded"); +} # # create a new exception class... @@ -83,5 +87,5 @@ __END__ -Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the +Copyright (C) 2003, 2009 by the gtk2-perl team (see the file AUTHORS for the full list). See LICENSE for more information.