Project

General

Profile

Actions

Misc #19088

closed

Complex() method with `exception: false` option still raises exception when String argument is in non-ASCII-compatible encoding

Added by andrykonchin (Andrew Konchin) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
[ruby-core:110525]

Description

I've noticed a minor inconsistency of the Complex() method. When it is called with exception: false option I suppose it shouldn't raise any exception.

For instance it doesn't raise error in the following cases:

Complex("1+2ifoobar", exception: false) # => nil
Complex("1+2i\0", exception: false) # => nil

But it still raises error when argument is in non-ASCII-compatible encoding:

Complex("1+2i".encode("UTF-16"), exception: false)
(irb):4:in `Complex': ASCII incompatible encoding: UTF-16 (Encoding::CompatibilityError)

I am wondering if exception: false is supposed to suppress this exception as well.

Actions #1

Updated by andrykonchin (Andrew Konchin) over 1 year ago

  • Description updated (diff)

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

exception:false is effective only for the content.
ASCII incompatible encoding strings are not subjects of parsing.

Updated by andrykonchin (Andrew Konchin) over 1 year ago

Got it. Thank you.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0