Skip to content

Commit 572eb2f

Browse files
authored
Merge pull request #106 from archonic/master
Fix TypeError on comparing classes with non-class or non-module to examine the class tree - This fixes #98 - CI failures due to Python 3.4. I'll drop Python 3.4 support later.
2 parents e4de5b1 + 7e29df8 commit 572eb2f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/pycall/pytypeobject_wrapper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ def ===(other)
5151

5252
def <(other)
5353
case other
54+
when self
55+
false
5456
when PyTypeObjectWrapper
5557
__pyptr__ < other.__pyptr__
58+
when Class
59+
false if other.ancestors.include?(self)
60+
when Module
61+
if ancestors.include?(other)
62+
true
63+
elsif other.ancestors.include?(self)
64+
false
65+
end
5666
else
5767
raise TypeError, "compared with non class/module"
5868
end

0 commit comments

Comments
 (0)