Last active
December 18, 2015 22:49
-
-
Save senny/5857653 to your computer and use it in GitHub Desktop.
Wierd problem when an exception is raised inside a template that has a UTF-8 encoded identifier.
Using module_eval with an UTF-8 filename as in (https://github.com/rails/rails/blob/master/actionview/lib/action_view/template.rb#L295), will result in ASCII-8Bit entries in the `e.backtrace` array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EncodingBug | |
end | |
filename = ARGV[0] | |
puts "using encoding: #{filename.encoding}" | |
EncodingBug.module_eval "def self.say; raise end", filename, 1 | |
begin | |
EncodingBug.say | |
rescue => e | |
frame = e.backtrace.first | |
puts "frame: #{frame}" | |
puts "backtrace encoding: #{frame.encoding}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
activesupport :: (master*) » ruby reproduction.rb ä | |
using encoding: UTF-8 | |
frame: ä:1:in `say' | |
backtrace encoding: ASCII-8BIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment