@@ -1034,9 +1034,10 @@ class FIFO
1034
1034
def initialize ( from_encoding , encoding , log , max_line_size = nil )
1035
1035
@from_encoding = from_encoding
1036
1036
@encoding = encoding
1037
- @need_enc = from_encoding != encoding
1038
- @buffer = '' . force_encoding ( from_encoding )
1039
- @eol = "\n " . encode ( from_encoding ) . freeze
1037
+ @encoding_for_appending = from_encoding || encoding || Encoding ::ASCII_8BIT
1038
+ @need_enc = from_encoding && encoding && ( from_encoding != encoding )
1039
+ @buffer = '' . force_encoding ( @encoding_for_appending )
1040
+ @eol = "\n " . encode ( @encoding_for_appending ) . freeze
1040
1041
@max_line_size = max_line_size
1041
1042
@skip_current_line = false
1042
1043
@skipping_current_line_bytesize = 0
@@ -1057,7 +1058,7 @@ def <<(chunk)
1057
1058
# quad-byte encoding to IO#readpartial as the second arguments results in an
1058
1059
# assertion failure on Ruby < 2.4.0 for unknown reasons.
1059
1060
orig_encoding = chunk . encoding
1060
- chunk . force_encoding ( from_encoding )
1061
+ chunk . force_encoding ( @encoding_for_appending )
1061
1062
@buffer << chunk
1062
1063
# Thus the encoding needs to be reverted back here
1063
1064
chunk . force_encoding ( orig_encoding )
@@ -1143,7 +1144,7 @@ def initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:,
1143
1144
@read_bytes_limit_per_second = read_bytes_limit_per_second
1144
1145
@receive_lines = receive_lines
1145
1146
@open_on_every_update = open_on_every_update
1146
- @fifo = FIFO . new ( from_encoding || Encoding :: ASCII_8BIT , encoding || Encoding :: ASCII_8BIT , log , max_line_size )
1147
+ @fifo = FIFO . new ( from_encoding , encoding , log , max_line_size )
1147
1148
@lines = [ ]
1148
1149
@io = nil
1149
1150
@notify_mutex = Mutex . new
0 commit comments