ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:118432] [Ruby master Bug#20607] Exception messages are inconsistent when thread-local variables are accessed
@ 2024-07-03 16:41 andrykonchin (Andrew Konchin) via ruby-core
  2024-07-03 20:34 ` [ruby-core:118433] " jeremyevans0 (Jeremy Evans) via ruby-core
  0 siblings, 1 reply; 2+ messages in thread
From: andrykonchin (Andrew Konchin) via ruby-core @ 2024-07-03 16:41 UTC (permalink / raw)
  To: ruby-core; +Cc: andrykonchin (Andrew Konchin)

Issue #20607 has been reported by andrykonchin (Andrew Konchin).

----------------------------------------
Bug #20607: Exception messages are inconsistent when thread-local variables are accessed
https://bugs.ruby-lang.org/issues/20607

* Author: andrykonchin (Andrew Konchin)
* Status: Open
* ruby -v: 3.2.4
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
`Thread`'s methods to manipulate thread-local variables raise `TypeError` exceptions with slightly different messages when the `key` argument is not a String or a Symbol. The message is either `is not a symbol` or `is not a symbol nor a string`. As far as both String and Symbol arguments are correct it seems the `is not a symbol nor a string` message is more accurate and should be used consistently.

The following methods raise `is not a symbol` error:

```ruby
@t.thread_variable_set(:a, 0) # for some methods it's important to have some thread-local variables assigned

@t.thread_variable_get(123) # => 123 is not a symbol (TypeError)
t.thread_variable_set(123, 1) # => 123 is not a symbol (TypeError)
t.thread_variable?(123) # => 123 is not a symbol (TypeError)
t[123] = 1 # => 123 is not a symbol (TypeError)
```

The following methods raise `is not a symbol nor a string` error:

```ruby
t.fetch(123) # => 123 is not a symbol nor a string (TypeError)
t.key?(123) # => 123 is not a symbol nor a string (TypeError)
t[123] # => 123 is not a symbol nor a string (TypeError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:118433] [Ruby master Bug#20607] Exception messages are inconsistent when thread-local variables are accessed
  2024-07-03 16:41 [ruby-core:118432] [Ruby master Bug#20607] Exception messages are inconsistent when thread-local variables are accessed andrykonchin (Andrew Konchin) via ruby-core
@ 2024-07-03 20:34 ` jeremyevans0 (Jeremy Evans) via ruby-core
  0 siblings, 0 replies; 2+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-07-03 20:34 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20607 has been updated by jeremyevans0 (Jeremy Evans).


I submitted a pull request to make the error message consistent: https://github.com/ruby/ruby/pull/11097

----------------------------------------
Bug #20607: Exception messages are inconsistent when thread-local variables are accessed
https://bugs.ruby-lang.org/issues/20607#change-108948

* Author: andrykonchin (Andrew Konchin)
* Status: Open
* ruby -v: 3.2.4
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
`Thread`'s methods to manipulate thread-local variables raise `TypeError` exceptions with slightly different messages when the `key` argument is not a String or a Symbol. The message is either `is not a symbol` or `is not a symbol nor a string`. As far as both String and Symbol arguments are correct it seems the `is not a symbol nor a string` message is more accurate and should be used consistently.

The following methods raise `is not a symbol` error:

```ruby
@t.thread_variable_set(:a, 0) # for some methods it's important to have some thread-local variables assigned

@t.thread_variable_get(123) # => 123 is not a symbol (TypeError)
t.thread_variable_set(123, 1) # => 123 is not a symbol (TypeError)
t.thread_variable?(123) # => 123 is not a symbol (TypeError)
t[123] = 1 # => 123 is not a symbol (TypeError)
```

The following methods raise `is not a symbol nor a string` error:

```ruby
t.fetch(123) # => 123 is not a symbol nor a string (TypeError)
t.key?(123) # => 123 is not a symbol nor a string (TypeError)
t[123] # => 123 is not a symbol nor a string (TypeError)
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-03 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-03 16:41 [ruby-core:118432] [Ruby master Bug#20607] Exception messages are inconsistent when thread-local variables are accessed andrykonchin (Andrew Konchin) via ruby-core
2024-07-03 20:34 ` [ruby-core:118433] " jeremyevans0 (Jeremy Evans) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).