Skip to content

Commit f394f79

Browse files
committed
CSV.read: Add support for integer mode again
Fix GH-336 Reported by Dave Burgess. Thanks!!!
1 parent 34e21fa commit f394f79

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/csv.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ def may_enable_bom_detection_automatically(filename_or_io,
19761976
return unless Encoding.default_external == Encoding::UTF_8
19771977
return if options.key?(:encoding)
19781978
return if options.key?(:external_encoding)
1979-
return if mode.include?(":")
1979+
return if mode.is_a?(String) and mode.include?(":")
19801980
file_opts[:encoding] = "bom|utf-8"
19811981
end
19821982

test/csv/interface/test_read.rb

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ def test_open_block_return_value
112112
assert_equal("Return value.", return_value)
113113
end
114114

115+
def test_open_mode_integer
116+
CSV.open(@input.path, File::RDONLY, col_sep: "\t") do |csv|
117+
assert_equal(@rows, csv.read)
118+
end
119+
end
120+
115121
def test_open_encoding_valid
116122
# U+1F600 GRINNING FACE
117123
# U+1F601 GRINNING FACE WITH SMILING EYES

0 commit comments

Comments
 (0)