blib/lib/Python/Serialise/Pickle.pm

filter: Statementstmt 92.7% 218 / 235 Branchbran 75.0% 54 / 72 Conditioncond 72.5% 29 / 40 MC/DCmcdc 52.1% 12 / 23 Subroutinesub 92.8% 26 / 28 Podpod 100% 4 / 4 totaltotal 85.3% 343 / 402 CC 54 SCAR 15.7
CC
54
Cov
87%
_get_tuple
9.3
_get_dict
8.3
_get_list
7.1
CRAP 4.8
↑ Summary
1 package Python::Serialise::Pickle;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 $VERSION = '0.01';
9  
10  
11  
12 7 my %_set_handlers = (
13 'NUMBER' => \&_set_num,
14 'STRING' => \&_set_string,
15 'HASH' => \&_set_dict,
16 'ARRAY' => \&_set_list,
17 );
18  
19  
20 7 my %_get_handlers = (
21 'I' => \&_get_num,
22 'L' => \&_get_num,
23 'F' => \&_get_num,
24 'S' => \&_get_string,
25 'N' => \&_get_none,
26 'l' => \&_get_list,
27 'd' => \&_get_dict,
28 'c' => \&_get_raw,
29 'p' => \&_get_id,
30 'i' => \&_get_raw,
31 '(' => \&_get_compound,
32 );
33  
34  
35 =head1 NAME
36  
37 Python::Serialise::Pickle - a file for reading and writing pickled Python files
38  
39 =head1 SYNOPSIS
40  
41  
42 use Python::Serialise::Pickle;
43  
44 my $pr = Python::Serialise::Pickle->new("file/for/reading");
45 while (my $data = $pr->load()) {
46 print Dumper $data;
47 }
48  
49 my $pw = Python::Serialise::Pickle->new(">file/for/writing");
50
51 $pw->dump(['a' 'list']);
52 $pw->dump("a string");
53 $pw->dump(42);
54 $pw->dump({'a'=>'hash'});
55  
56 $pw->close();
57  
58 =head1 DESCRIPTION
59  
60 Pickling is a method of serialising files in Python (another method,
61 Marshalling, is also available).
62  
63 This module is an attempt to write a pure Perl implementation of the algorithm.
64  
65  
66 =head1 METHODS
67  
68 =head2 new <filename>
69  
70 Open a file for reading or writing. Can take any arguments that C<IO::File> can.
71  
72 =cut
73  
74 18 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod documented
75 18 my $class = shift;
76 18 ▶ my $file = shift || die "You must pass a file\n";
Condition50%1/2
shift() || die("You must pass a file\n")
l!l
180
MC/DC0%0/1
shift() || die("You must pass a file\n")
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
77  
78 ## FIXME error here
79 18 ▶ my $fh = IO::File->new($file) || die "Couldn't open file\n";
Condition50%1/2
'IO::File'->new($file) || die("Couldn't open file\n")
l!l
180
MC/DC0%0/1
'IO::File'->new($file) || die("Couldn't open file\n")
'IO::File'->new($file)
Truth table50%1/2
A
A= 'IO::File'->new($file)
Aresult
11
00
80 18 my $self = { _fh => $fh };
81  
82 18 return bless $self, $class;
83
84 }
85  
86 =head2 load
87  
88 Returns the next data structure from the pickle file or undef.
89  
90 =cut
91  
92 47 ▶sub load {
Subroutine load: called CC=4 SCAR=14.8
Pod documented
93 47 my $self = shift;
94 47 $self->{_cur_id} = 0;
95  
96 47 print "LOAD\n";
97  
98 47 my $id = $self->_get_char();
99 47 ▶ return undef if (!defined $id or $id eq "");
Branch: 1 branch
BranchTrueFalseTotal
if not defined $id or $id eq "" 0 47 47
Condition33%1/3
not defined $id or $id eq ""
l!l&&r!l&&!r
0047
MC/DC0%0/2
not defined $id or $id eq ""
not defined $id $id eq ""
Truth table33%1/3
not(A) or B
A= not defined $idB= $id eq ""
ABresult
1X1
011
000
100  
101 47 ▶ my $sub = $_get_handlers{$id} || die "We have no handler to deal with '$id'\n";
Condition50%1/2
$_get_handlers{$id} || die("We have no handler to deal with '${id}'\n")
l!l
470
MC/DC0%0/1
$_get_handlers{$id} || die("We have no handler to deal with '${id}'\n")
$_get_handlers{$id}
Truth table50%1/2
A
A= $_get_handlers{$id}
Aresult
11
00
102 47 return $self->$sub();
103  
104 }
105  
106  
107 =head2 dump <data structure>
108  
109 Takes a ref to an array or a hash or a number or string and pickles it.
110  
111 Structures may be nested.
112  
113 =cut
114  
115 24 ▶sub dump {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
116 24 my $self = shift;
117 24 my $val = shift;
118  
119  
120  
121 24 my $sub = $_set_handlers{$self->_type($val)};
122
123 24 my $line = $self->$sub($val);
124 24 $line .= ".";
125
126 24 $self->_write($line);
127 24 return $line;
128  
129 }
130  
131  
132 10 ▶sub _backup {
Subroutine _backup: called CC=1 SCAR=0.0
133 10 my $self = shift;
134 10 print "BACKUP\n";
135 10 $self->{_fh}->seek(-1,1);
136 }
137  
138  
139 sub _get_char
140 1082 ▶{
Subroutine _get_char: called CC=1 SCAR=0.0
141 1082 my $self = shift;
142 1082 $self->{_fh}->read(my $data, 1);
143 1082 print "C=$data\n";
144  
145 1082 return $data;
146 }
147  
148 183 ▶sub _get_line {
Subroutine _get_line: called CC=3 SCAR=11.0
149 183 my $self = shift;
150 183 my $line = "";
151  
152 183 while (1) {
153 716 my $char = $self->_get_char();
154 716 ▶ last unless defined $char;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char 0 716 716
155 716 ▶ last if $char eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "\n" 183 533 716
156 533 $line .= $char;
157 }
158  
159 183 return $line;
160 }
161  
162 24 ▶sub _write {
Subroutine _write: called CC=1 SCAR=0.0
163 24 my $self = shift;
164 24 my $val = shift;
165  
166 24 $self->{_fh}->write($val);
167 }
168  
169  
170 sub _get_num
171 46 ▶{
Subroutine _get_num: called CC=3 SCAR=11.0
172 46 my $self = shift;
173 46 my %opts = @_;
174  
175 46 my $num = $self->_get_line();
176  
177 46 ▶ unless (defined $opts{'ignore_end_marker'} && $opts{'ignore_end_marker'} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1) 34 12 46
Condition100%3/3
defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1
!ll&&!rl&&r
112312
MC/DC100%2/2
defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1
defined $opts{"ignore_end_marker"} $opts{"ignore_end_marker"} == 1
Truth table100%3/3
A and B
A= defined $opts{"ignore_end_marker"}B= $opts{"ignore_end_marker"} == 1
ABresult
0X0
100
111
178 34 $self->_get_char();
179 }
180  
181  
182 46 return $num;
183 }
184  
185 sub _set_num
186 24 ▶{
Subroutine _set_num: called CC=3 SCAR=11.0
187 24 my $self = shift;
188 24 my $num = shift;
189 24 my %opts = @_;
190  
191  
192 24 my $return;
193 24 ▶ if (int $num != $num) {
Branch: 1 branch
BranchTrueFalseTotal
if (int $num != $num) { } 2 22 24
194 2 $return = "F$num\n";
195 } else {
196 22 $return = "I$num\n";
197 }
198  
199 24 ▶ $return .= $opts{'terminator'} if ($opts{'terminator'});
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"terminator"} 20 4 24
200  
201 24 return $return;
202 }
203  
204  
205 sub _get_string
206 51 ▶{
Subroutine _get_string: called CC=4 SCAR=13.9
207 51 my $self = shift;
208 51 my %opts = @_;
209  
210  
211 51 my $string = $self->_get_line();
212 51 $string =~ s!^(['"])(.*)['"]$!$2!;
213 51 $string =~ s!"!\\"!g;
214 51 eval "\$string = \"$string\";";
215  
216 51 my $id = $self->_get_id();
217 51 ▶ die "No id!\n" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 51 51
218  
219 51 ▶ unless (defined $opts{'ignore_end_marker'} && $opts{'ignore_end_marker'} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1) 38 13 51
Condition100%3/3
defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1
!ll&&!rl&&r
162213
MC/DC100%2/2
defined $opts{"ignore_end_marker"} and $opts{"ignore_end_marker"} == 1
defined $opts{"ignore_end_marker"} $opts{"ignore_end_marker"} == 1
Truth table100%3/3
A and B
A= defined $opts{"ignore_end_marker"}B= $opts{"ignore_end_marker"} == 1
ABresult
0X0
100
111
220 38 $self->_get_char();
221 }
222  
223  
224 51 return $string;
225
226  
227 }
228  
229 sub _set_string
230 45 ▶{
Subroutine _set_string: called CC=5 SCAR=16.1
231 45 my $self = shift;
232 45 my $string = shift;
233 45 my %opts = @_;
234  
235 # escape some control chars
236 45 $string =~ s{
237 (.)
238 }{
239 171 ▶ (ord($1)<33 || ord($1)>126)?sprintf '\\%.3o',ord($1):$1
Branch: 1 branch
BranchTrueFalseTotal
ord $1 < 33 || ord $1 > 126 ? : 5 166 171
Condition66%2/3
ord $1 < 33 or ord $1 > 126
l!l&&r!l&&!r
50166
MC/DC50%1/2
ord $1 < 33 or ord $1 > 126
ord $1 < 33 ord $1 > 126
Truth table66%2/3
A or B
A= ord $1 < 33B= ord $1 > 126
ABresult
1X1
011
000
240 }sxeg;
241
242 45 my $return = "S";
243 45 ▶ if ($string =~ /^'.+'$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /^'.+'$/) { } 1 44 45
244 1 $return .= "\"$string\"\n";
245 } else {
246 44 $return .= "'$string'\n";
247 }
248
249  
250  
251 45 $return .= $self->_set_id();
252 45 ▶ $return .= $opts{'terminator'} if ($opts{'terminator'});
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"terminator"} 25 20 45
253  
254  
255 45 return $return;
256  
257 }
258  
259  
260 86 ▶sub _get_id {
Subroutine _get_id: called CC=2 SCAR=7.0
261 86 my $self = shift;
262 86 my %opts = @_;
263  
264 86 my $char = $self->_get_char();
265 86 ▶ die "Got $char - was expecting 'p' for id" unless $char eq 'p';
Branch: 1 branch
BranchTrueFalseTotal
unless $char eq "p" 0 86 86
266 86 return $self->_get_line();
267 }
268  
269 68 ▶sub _set_id {
Subroutine _set_id: called CC=1 SCAR=0.0
270 68 my $self = shift;
271
272 68 my $id = $self->{_cur_id}++;
273 68 return "p$id\n";
274 }
275  
276 20 ▶sub _get_list {
Subroutine _get_list: called CC=7 SCAR=19.6
277 20 my $self = shift;
278 20 my %opts = @_;
279  
280 20 print "GET LIST\n";
281  
282 20 my $oid = $self->_get_id();
283 20 my @vals;
284  
285 20 while (1) {
286 71 my $id = $self->_get_char();
287 71 ▶ if ($id eq '.' || $id eq 's' || $id eq 'a') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "." or $id eq "s" or $id eq "a") 19 52 71
Condition83%5/6
$id eq "." or $id eq "s" or $id eq "a"
l!l&&r!l&&!r
13652
$id eq "." or $id eq "s"
l!l&&r!l&&!r
13058
MC/DC66%2/3
$id eq "." or $id eq "s" or $id eq "a"
$id eq "." $id eq "s" $id eq "a"
Truth table75%3/4
A or B or C
A= $id eq "."B= $id eq "s"C= $id eq "a"
ABCresult
1XX1
01X1
0011
0000
288 19 last;
289 }
290 52 ▶ if ($id eq 'g') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "g") 0 52 52
291 0 my $tmp = $self->_get_line();
292 0 last;
293 }
294  
295 52 ▶ if ($id eq 't') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "t") 1 51 52
296 1 $self->_backup;
297 1 last;
298 }
299  
300
301 51 my $sub = $_get_handlers{$id};
302 51 print "ID=$id\n";
303 51 $opts{'ignore_end_marker'}=0;
304 51 ▶ die "No handler for '$id' in get_list ",(join ",",@vals),"" unless defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub 0 51 51
305 51 push @vals, $self->$sub(%opts);
306
307  
308 }
309 20 print "END LIST\n";
310 20 return \@vals;
311 }
312  
313 18 ▶sub _set_list {
Subroutine _set_list: called CC=5 SCAR=16.1
314 18 my $self = shift;
315 18 my $list = shift;
316 18 my %opts = @_;
317
318 18 ▶ my $terminator = $opts{'terminator'} || "";
Condition100%2/2
$opts{'terminator'} || ''
l!l
513
MC/DC100%1/1
$opts{'terminator'} || ''
$opts{'terminator'}
Truth table100%2/2
A
A= $opts{'terminator'}
Aresult
11
00
319  
320 18 my $return = "";
321 18 ▶ $return .= "(" unless ($opts{ignore_compound});
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"ignore_compound"} 18 0 18
322 18 $return .= "l";
323 18 $return .= $self->_set_id();
324  
325 18 $opts{'terminator'} = 'a';
326  
327 18 foreach my $val (@$list) {
328 52 my $sub = $_set_handlers{$self->_type($val)};
329 52 ▶ die "No handler to set '$val'" unless defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub 0 52 52
330 52 $return .= $self->$sub($val, %opts);
331  
332 }
333  
334 18 $return .= $terminator;
335 18 return $return;
336  
337 }
338  
339  
340  
341 35 ▶sub _get_compound {
Subroutine _get_compound: called CC=3 SCAR=11.0
342 35 my $self = shift;
343 35 my %opts = @_;
344  
345  
346 35 my $id = $self->_get_char();
347
348 35 ▶ if ($id eq 'l') {
Branch: 2 branches
BranchTrueFalseTotal
if ($id eq 'l') { } 20 15 35
elsif ($id eq 'd') { } 6 9 15
349 20 $self->_get_list(%opts);
350 } elsif ($id eq 'd') {
351 6 $self->_get_dict(%opts);
352 } else {
353 9 $self->_backup();
354 9 $self->_get_tuple(%opts);
355 }
356 }
357  
358  
359 9 ▶sub _get_tuple {
Subroutine _get_tuple: called CC=9 SCAR=22.3
360 9 my $self = shift;
361 9 my %opts = @_;
362 9 ▶ my $last_id = $opts{'last_tuple_marker'} || ".";
Condition50%1/2
$opts{'last_tuple_marker'} || '.'
l!l
09
MC/DC0%0/1
$opts{'last_tuple_marker'} || '.'
$opts{'last_tuple_marker'}
Truth table50%1/2
A
A= $opts{'last_tuple_marker'}
Aresult
11
00
363  
364 9 my @vals;
365  
366 9 print "GET TUPLE\n";
367  
368 9 while (1) {
369 39 my $id = $self->_get_char();
370 39 ▶ if ($id eq '.' || $id eq 'a' || $id eq 's') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "." or $id eq "a" or $id eq "s") 6 33 39
Condition83%5/6
$id eq "." or $id eq "a" or $id eq "s"
l!l&&r!l&&!r
5133
$id eq "." or $id eq "a"
l!l&&r!l&&!r
5034
MC/DC66%2/3
$id eq "." or $id eq "a" or $id eq "s"
$id eq "." $id eq "a" $id eq "s"
Truth table75%3/4
A or B or C
A= $id eq "."B= $id eq "a"C= $id eq "s"
ABCresult
1XX1
01X1
0011
0000
371 6 last;
372 }
373  
374 33 ▶ if ($id eq 'g') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "g") 0 33 33
375 0 $self->_get_line();
376 0 next;
377 }
378
379 33 ▶ if ($id eq 't') {
Branch: 1 branch
BranchTrueFalseTotal
if ($id eq "t") 9 24 33
380 9 $self->_get_id();
381 9 print "Getting ID\n";
382 9 ▶ if ($opts{'ignore_end_marker'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'ignore_end_marker'}) { } 3 6 9
383 3 last;
384 } else {
385 6 next;
386 }
387 }
388
389 24 my $sub = $_get_handlers{$id};
390 24 ▶ die "No handler for type '$id'" unless defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub 0 24 24
391 24 push @vals, $self->$sub(ignore_end_marker=>1);
392
393 }
394 9 print "END TUPLE\n";
395 9 return \@vals;
396 }
397  
398  
399 sub _get_dict
400 6 ▶{
Subroutine _get_dict: called CC=8 SCAR=21.2
401 6 my $self = shift;
402 6 my %opts = @_;
403 6 my %dict;
404  
405 6 print "GET DICT\n";
406 6 print "IGNORE END MARKER = ",$opts{'ignore_end_marker'},"\n";
407 #$opts{'ignore_end_marker'}=1;
408  
409
410 6 my $id = $self->_get_id();
411  
412  
413  
414 6 while (1) {
415 11 my $key_id = $self->_get_char();
416
417
418  
419  
420 11 ▶ if ($key_id eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key_id eq ".") 5 6 11
421 5 ▶ $self->_backup() if $opts{'ignore_end_marker'};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"ignore_end_marker"} 0 5 5
422 5 last;
423 }
424 6 ▶ last if ($key_id eq 's' || $key_id eq 'a');
Branch: 1 branch
BranchTrueFalseTotal
if $key_id eq "s" or $key_id eq "a" 1 5 6
Condition66%2/3
$key_id eq "s" or $key_id eq "a"
l!l&&r!l&&!r
105
MC/DC50%1/2
$key_id eq "s" or $key_id eq "a"
$key_id eq "s" $key_id eq "a"
Truth table66%2/3
A or B
A= $key_id eq "s"B= $key_id eq "a"
ABresult
1X1
011
000
425
426 5 ▶ if ($key_id eq 'g') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key_id eq "g") 0 5 5
427 0 my $tmp = $self->_get_line();
428 0 next;
429 }
430  
431  
432 5 my $key_sub = $_get_handlers{$key_id};
433 5 ▶ die "No handler for key '$key_id'" unless defined $key_sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key_sub 0 5 5
434
435 5 my $key = $self->$key_sub( ignore_end_marker => 1);
436
437 5 print "GOT KEY\n";
438
439 5 my $val_id = $self->_get_char();
440 5 my $val_sub = $_get_handlers{$val_id};
441 5 ▶ die "No handler for value '$val_id'" unless defined $val_sub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val_sub 0 5 5
442 5 my $val = $self->$val_sub(%opts);
443  
444 5 $dict{$key} = $val;
445  
446  
447  
448 }
449 6 print "END DICT\n";
450
451  
452 6 return \%dict;
453  
454 }
455  
456 sub _set_dict
457 5 ▶{
Subroutine _set_dict: called CC=4 SCAR=13.9
458 5 my $self = shift;
459 5 my $hash = shift;
460 5 my %opts = @_;
461  
462 5 my $return = "";
463 5 $return .= "(";
464 5 $return .= "d";
465 5 $return .= $self->_set_id();
466
467  
468 5 $opts{'ignore_compound'} = 0;
469 5 $opts{'ignore_end_marker'} = 1;
470 5 $opts{'terminator'} = "";
471  
472 5 foreach my $key (keys %{$hash}) {
473 8 my $val = $hash->{$key};
474
475 8 my $keysub = $_set_handlers{$self->_type($key)};
476 8 ▶ die "No handler for setting key '$key'" unless defined $keysub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $keysub 0 8 8
477 8 $return .= $self->$keysub($key, %opts);
478  
479 8 my $valsub = $_set_handlers{$self->_type($val)};
480 8 ▶ die "No handler for setting val '$val'" unless defined $valsub;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $valsub 0 8 8
481 8 $return .= $self->$valsub($val, %opts);
482
483  
484 8 $return .= "s";
485 }
486  
487 5 return $return;
488  
489 }
490  
491  
492  
493  
494  
495 0 ▶sub _get_none {
Subroutine _get_none: not called CC=1 SCAR=6.9
496 0 my $self = shift;
497 0 return $self->_get_raw;
498  
499 }
500  
501 0 ▶sub _get_raw {
Subroutine _get_raw: not called CC=2 SCAR=17.9
502 0 my $self = shift;
503 0 $self->_backup;
504  
505  
506 0 my $val = "";
507 0 while (1) {
508 0 my $char = $self->_get_char();
509 0 ▶ last if ($char eq ".");
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "." 0 0 0
510 0 $val .= $char;
511 0 $val .= $self->_get_line();
512 }
513 0 return $val;
514
515 }
516  
517 92 ▶sub _type {
Subroutine _type: called CC=4 SCAR=13.9
518 92 my $self = shift;
519 92 my $val = shift;
520  
521 92 my $ref = ref $val;
522  
523 92 ▶ return $ref if defined $ref && $ref ne "";
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref and $ref ne "" 23 69 92
Condition66%2/3
defined $ref and $ref ne ""
!ll&&!rl&&r
06923
MC/DC50%1/2
defined $ref and $ref ne ""
defined $ref $ref ne ""
Truth table66%2/3
A and B
A= defined $refB= $ref ne ""
ABresult
0X0
100
111
524  
525 69 ▶ return "NUMBER" if ($val =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/ 24 45 69
526 45 return "STRING";
527  
528 }
529  
530  
531 =head2 close
532  
533 Closes the current file.
534  
535 =cut
536  
537 23 ▶sub close {
Subroutine close: called CC=1 SCAR=0.0
Pod documented
538 23 my $self = shift;
539 23 $self->{_fh}->close();
540 }
541  
542 17 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
543 17 my $self = shift;
544 17 $self->close();
545 }
546  
547  
548 =head1 BUGS
549  
550 Almost certainly lots and lots.
551  
552 =over 4
553  
554 =item Serialised objects
555  
556 At the moment we don't deal with serialised objects very well.
557 Should probably just take or return a Python::Serialise::Pickle::Object
558 object.
559  
560 =item The 'None' object
561  
562 Similar to Perl's undef but an object. At the moment we deal with it badly
563 because if we returned undef then that would signify the end of the Pickle file.
564  
565 Should probably be returned as a special object or something.
566  
567 =item Longs
568  
569 There's no testing for longs
570  
571 =item Unicode
572  
573 Ditto
574  
575 =item Some nested dictionaries
576  
577 Dictionaries are the Python equivalent of hashes. This module can deal with most nested
578 dictionaries but, for some reason, this one :
579  
580 a={'a':['two',{'goof':'foo', 'a':[1,2,3]}]}
581  
582 causes it to fail.
583  
584 Chnaging it slightly starts it working again.
585  
586 =item Bad reading of specs
587  
588 This is entirely my fault
589  
590 =back
591  
592 =head1 ALTERNATIVES
593  
594 You could always dump the data structure out as YAML in Python
595 and then read it back in with YAML in Perl.
596  
597 =head1 AUTHOR
598  
599 Simon Wistow <simon@thegestalt.org>
600  
601 =head1 COPYRIGHT
602  
603 (c) 2003 Simon Wistow
604  
605 Distributed under the same terms as Perl itself.
606  
607 This software is under no warranty and will probably ruin your life,
608 kill your friends, burn your house and bring about the apocalypse.
609  
610 =head1 SEE ALSO
611  
612 http://www.python.org, L<YAML>, L<IO::File> and the RESOURCES file in
613 this distribution.
614  
615 =cut
616  
617 7 1;
↑ Summary