summaryrefslogtreecommitdiff
path: root/lib/timeout.rb
diff options
context:
space:
mode:
authorCosmicOppai <cosmicoppai@protonmail.com>2024-10-14 16:23:53 +0530
committergit <svn-admin@ruby-lang.org>2024-12-03 06:49:54 +0000
commit0f2cd39e680c9b15ddd94d34770a8a17d0c5a0ae (patch)
tree7e2b5eb69ba1aac6a0b6d799bf725cce4e85153c /lib/timeout.rb
parent203a02344766bdab347c82e7fd082248cad38364 (diff)
[ruby/timeout] refactor the change to keep the compatability with nil and type-errror and added tests
https://github.com/ruby/timeout/commit/8342544979
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r--lib/timeout.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index c8c3d501b6..59437f490e 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -164,7 +164,7 @@ module Timeout
# Timeout</tt> into your classes so they have a #timeout method, as well as
# a module method, so you can call it directly as Timeout.timeout().
def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
- raise ArgumentError, "Timeout sec must be a positive number" unless sec.is_a?(Numeric) && sec >= 0
+ raise ArgumentError, "Timeout sec must be a positive number" if sec.is_a?(Numeric) && sec < 0
return yield(sec) if sec == nil or sec.zero?
message ||= "execution expired"