Project

General

Profile

Actions

Bug #18407

closed

Behavior difference between integer and string flags to File creation

Added by deivid (David Rodríguez) almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:106634]

Description

Hi!

I was under the impression that these two commands should either both work of both fail, however they behave differently.

$ ruby -ropen-uri -EUTF-8:UTF-8 -e 'f = File.new("foo", "wb"); f.write URI.open("https://rubygems.org/gems/rake-13.0.6.gem").read'

$ ruby -ropen-uri -EUTF-8:UTF-8 -e 'f = File.new("foo", File::WRONLY | File::TRUNC | File::BINARY); f.write URI.open("https://rubygems.org/gems/rake-13.0.6.gem").read'
-e:1:in `write': "\\x8B" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
	from -e:1:in `<main>'

Could be an actual bug, and me misunderstanding the documentation. In any case it seemed worth reporting.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0