-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Consider the following code:
class TestClass
def self.parsing_method
CSV.parse_line("\"foo")
end
endCalling TestClass.parsing_method should raise a CSV::MalformedCSVError because there is an unclosed quoted field which makes perfect sense.
However, if we execute this code on version 3.1, we end up with this:
> TestClass.parsing_method
CSV::MalformedCSVError: Unclosed quoted field in line 1.
from /Users/kd/code/csv/lib/csv/parser.rb:263:in `block in each'
from /Users/kd/code/csv/lib/csv/parser.rb:92:in `loop'
from /Users/kd/code/csv/lib/csv/parser.rb:92:in `each'
from /Users/kd/.rbenv/versions/2.4.3/bin/bundle:1:in `each'
Notice that the stacktrace is incomplete. We don't see any reference to parsing_method or even irb
I have isolated it to this commit: 11f126e#diff-ad40fdf9392e934708ed9ee9ec79bde3R73
It seems to have something to do with the to_enum call but I haven't been able to figure out what yet.
As of that commit, the stacktrace is partially present, but before that commit, it the stack trace is different:
> TestClass.parsing_method
CSV::MalformedCSVError: Unclosed quoted field in line 1.
from /Users/kd/code/csv/lib/csv/parser.rb:264:in `block in shift'
from /Users/kd/code/csv/lib/csv/parser.rb:93:in `loop'
from /Users/kd/code/csv/lib/csv/parser.rb:93:in `shift'
from /Users/kd/code/csv/lib/csv.rb:1208:in `shift'
from /Users/kd/code/csv/lib/csv.rb:1171:in `each'
from /Users/kd/code/csv/lib/csv.rb:1185:in `to_a'
from /Users/kd/code/csv/lib/csv.rb:1185:in `read'
from /Users/kd/code/csv/lib/csv.rb:683:in `parse'
from (irb):3:in `parsing_method'
from (irb):6
Notice on this one we do have reference to parsing_method.
This means that for any application that is using CSV that is affected, if there is a parsing error that occurs, it is very difficult to track down where that exception is coming from since the stacktrace what seems like everything outside of the parser file.