Subject: | Patch for loading modules. |
When loading serialized modules, YAML fails to load the corresponding code.
jesper@ubuntulap:~$ cat yamltest
--- !perl/DateTime
formatter: ~
local_c:
day: 29
day_of_quarter: 29
day_of_week: 6
day_of_year: 119
hour: 12
minute: 55
month: 4
quarter: 2
second: 10
year: 2006
local_rd_days: 732430
local_rd_secs: 46510
locale: !perl/DateTime::Locale::en_US
default_date_format_length: medium
default_time_format_length: medium
en_complete_name: English United States
en_language: English
en_territory: United States
id: en_US
native_complete_name: English United States
native_language: English
native_territory: United States
offset_modifier: 0
rd_nanosecs: 0
tz: !perl/DateTime::TimeZone::UTC
name: UTC
utc_rd_days: 732430
utc_rd_secs: 46510
utc_year: 2007
jesper@ubuntulap:~$ perl -MYAML -e'my $dt = YAML::LoadFile("yamltest");
print $dt->ymd() . "\n";'
Can't locate object method "ymd" via package "DateTime" at -e line 1.
jesper@ubuntulap:~$
Subject: | yaml.patch |
diff -Nur YAML-0.58/lib/YAML/Loader.pm YAML-0.58-mod/lib/YAML/Loader.pm
--- YAML-0.58/lib/YAML/Loader.pm 2006-02-02 08:03:35.000000000 +0100
+++ YAML-0.58-mod/lib/YAML/Loader.pm 2006-04-29 15:40:16.000000000 +0200
@@ -265,6 +265,7 @@
$explicit =~ m{^perl/(\@|\$)?([a-zA-Z](\w|::)+)$}
) {
$class = $YAML::TagClass->{$explicit} || $2;
+ eval " require $class; import $class; ";
if ($class->can('yaml_load')) {
require YAML::Node;
return $class->yaml_load(YAML::Node->new($node, $explicit));