J
jonT
Hi,
Here's a tricky one:
Goal: I want to see test whether I'm going to have problems bringing
back some marshaled data in a new Ruby instance, and take necessary
action if so. So before I save my marshaled data to disk, I'd like to
attempt loading it and see if I get an Arguement error. Makes sense?
I'd hoped that the following would suffice: evaluate the Marshal
dumping in the current binding, then attempt the load in another. Since
the executions should be seperate, the second binding shouldn't know
what went on in the first and I should have the equivilent of dumping
and loading in two seperate Ruby instances?
Anyway, running the below code results in f being loaded fine .
* Any ideas for how I can fix this?
* Any better / alternative ways of solving the problem?
Cheers,
jonT
def jim
binding
end
def bob
binding
end
jim_b=jim
bob_b=bob
puts jim_b
puts bob_b
eval("class F;end",jim_b)
eval("f=F.new",jim_b)
data=eval("Marshal.dump(f)",jim_b)
# i want this to fail with an Argument error
puts eval("Marshal.load('" + data + "')",bob_b)
Here's a tricky one:
Goal: I want to see test whether I'm going to have problems bringing
back some marshaled data in a new Ruby instance, and take necessary
action if so. So before I save my marshaled data to disk, I'd like to
attempt loading it and see if I get an Arguement error. Makes sense?
I'd hoped that the following would suffice: evaluate the Marshal
dumping in the current binding, then attempt the load in another. Since
the executions should be seperate, the second binding shouldn't know
what went on in the first and I should have the equivilent of dumping
and loading in two seperate Ruby instances?
Anyway, running the below code results in f being loaded fine .
* Any ideas for how I can fix this?
* Any better / alternative ways of solving the problem?
Cheers,
jonT
def jim
binding
end
def bob
binding
end
jim_b=jim
bob_b=bob
puts jim_b
puts bob_b
eval("class F;end",jim_b)
eval("f=F.new",jim_b)
data=eval("Marshal.dump(f)",jim_b)
# i want this to fail with an Argument error
puts eval("Marshal.load('" + data + "')",bob_b)