diff options
author | Sutou Kouhei <kou@clear-code.com> | 2022-09-03 22:01:59 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-05-25 01:44:17 +0900 |
commit | 73c56e06c429ca713d3b612437d2087314a1062f (patch) | |
tree | c502786926012418692e7696988054cb001534a4 /lib | |
parent | a0709d0aae9609688f13e16bbae7ef84da78b24b (diff) |
[ruby/csv] CSV#read consumes the same lines with other methods like CSV#shift
GitHub: fix https://github.com/ruby/csv/pull/258
Reported by Lhoussaine Ghallou. Thanks!!!
https://github.com/ruby/csv/commit/71e6d24e28
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7851
Diffstat (limited to 'lib')
-rw-r--r-- | lib/csv.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index d4dc569b83..78c3029e7b 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -2592,7 +2592,14 @@ class CSV # # Raises IOError (not opened for reading) # csv.read def read - rows = to_a + rows = [] + enumerator = parser_enumerator + begin + while true + rows << enumerator.next + end + rescue StopIteration + end if parser.use_headers? Table.new(rows, headers: parser.headers) else |