projects/guix·blob python-team · refs

29 lines · 1.2 KiB

1From 8e6f5934541833f15664398f90331f3724e40933 Mon Sep 17 00:00:00 2001
2From: Mamoru TASAKA <[email protected]>
3Date: Tue, 15 Nov 2022 23:22:20 +0900
4Subject: [PATCH] ruby3_2 fix: check if object responds to regex_match op
5
6Object#=~ is already deprecated since ruby2.6 and will be
7removed from ruby3.2. As the result, Array no longer
8respond to =~ from ruby3.2, for example.
9
10Check if the target object really respond to =~ .
11
12Closes #168
13---
14 lib/chunky_png/vector.rb | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/lib/chunky_png/vector.rb b/lib/chunky_png/vector.rb
18index 4ef965f..034104c 100644
19--- a/lib/chunky_png/vector.rb
20+++ b/lib/chunky_png/vector.rb
21@@ -166,7 +166,7 @@ def dimension
22 # @return [Array<ChunkyPNG::Point>] The list of points interpreted from the input array.
23 def self.multiple_from_array(source)
24 return [] if source.empty?
25- if source.first.is_a?(Numeric) || source.first =~ /^\d+$/
26+ if source.first.is_a?(Numeric) || ( source.first.respond_to?(:=~) && source.first =~ /^\d+$/ )
27 raise ArgumentError, "The points array is expected to have an even number of items!" if source.length % 2 != 0
28
29 points = []