Title: MRO conflict on Set and Comparable · Issue #391 · jython/jython · GitHub
Open Graph Title: MRO conflict on Set and Comparable · Issue #391 · jython/jython
X Title: MRO conflict on Set and Comparable · Issue #391 · jython/jython
Description: I'm trying to use custom class implementing Set and Comparable interface in Jython but have the following error : Exception in thread "main" TypeError: Supertypes that share a modified attribute have an MRO conflict[attribute=__le__, sup...
Open Graph Description: I'm trying to use custom class implementing Set and Comparable interface in Jython but have the following error : Exception in thread "main" TypeError: Supertypes that share a modified attribute ha...
X Description: I'm trying to use custom class implementing Set and Comparable interface in Jython but have the following error : Exception in thread "main" TypeError: Supertypes that share a modifie...
Opengraph URL: https://github.com/jython/jython/issues/391
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MRO conflict on Set and Comparable","articleBody":"I'm trying to use custom class implementing Set and Comparable interface in Jython but have the following error : \n`Exception in thread \"main\" TypeError: Supertypes that share a modified attribute have an MRO conflict[attribute=__le__, supertypes=[\u003ctype 'java.util.Set'\u003e], type=Scratch$MyCollection]`\n\nI am using java temurin 21.0.6 and jython-standalone 2.7.4.\n\nI prepared a simple code example to reproduce : \n\n```java\n public static void main(String[] args) {\n try (PythonInterpreter interpreter = new PythonInterpreter()) {\n interpreter.set(\"c\", new MyCollection());\n }\n }\n```\n(Please note that you can just use `Py.java2py(new MyCollection())` and will achieve the same result)\n\nWhere MyCollection is a basic implementation :\n\n```java\n private static class MyCollection implements Set, Comparable {\n @Override\n public int compareTo(@NotNull Object o) {\n return 0;\n }\n\n @Override\n public int size() {\n return 0;\n }\n\n @Override\n public boolean isEmpty() {\n return false;\n }\n\n @Override\n public boolean contains(Object o) {\n return false;\n }\n\n @Override\n public @NotNull Iterator iterator() {\n return null;\n }\n\n @Override\n public @NotNull Object[] toArray() {\n return new Object[0];\n }\n\n @Override\n public boolean add(Object o) {\n return false;\n }\n\n @Override\n public boolean remove(Object o) {\n return false;\n }\n\n @Override\n public boolean addAll(@NotNull Collection c) {\n return false;\n }\n\n @Override\n public void clear() {\n\n }\n\n @Override\n public boolean removeAll(@NotNull Collection c) {\n return false;\n }\n\n @Override\n public boolean retainAll(@NotNull Collection c) {\n return false;\n }\n\n @Override\n public boolean containsAll(@NotNull Collection c) {\n return false;\n }\n\n @Override\n public @NotNull Object[] toArray(@NotNull Object[] a) {\n return new Object[0];\n }\n }\n```\n\nAlso, I tried in previous version 2.7.3 to 2.7.0 this even simpler code and has a similar error yet not the same :\n\n```java\n public static void main(String[] args) {\n try (PythonInterpreter interpreter = new PythonInterpreter()) {\n interpreter.set(\"c\", new TreeSet\u003c\u003e());\n }\n }\n```\n\n`Exception in thread \"main\" TypeError: Supertypes that share a modified attribute have an MRO conflict[attribute=remove, supertypes=[\u003ctype 'java.util.SequencedSet'\u003e, \u003ctype 'java.util.Set'\u003e], type=SortedSet]`\n\nI tried to look a bit into it but failed to grasp exactly what is wrong, I feel like the PyJavaType.bases field is the key here, it's an array and from what I see, the order of the element inside it determine if the MRO will crash or not.","author":{"url":"https://github.com/bomboleo","@type":"Person","name":"bomboleo"},"datePublished":"2025-07-16T12:34:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/391/jython/issues/391"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a569f8d3-c726-84c9-9ba7-1241b220e200 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D5DA:DA736:CD317:1199B4:696E6117 |
| html-safe-nonce | 52c247c72df5b024a06831ad421a4bb5eee16c4281fadd7ba9f0c2b535f840bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENURBOkRBNzM2OkNEMzE3OjExOTlCNDo2OTZFNjExNyIsInZpc2l0b3JfaWQiOiIxMTI5NDUxMzk1NTkzNjkxNDE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a0a6007cb1f9bbd9c65152fd1ef0ff3d5850ab175dd56443b583ab7d03502aeb |
| hovercard-subject-tag | issue:3235782386 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/jython/jython/391/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd29999742f89a3890bf065a7849d59d9eb7e0b318aed04b1be5139074fcf6bf/jython/jython/issues/391 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd29999742f89a3890bf065a7849d59d9eb7e0b318aed04b1be5139074fcf6bf/jython/jython/issues/391 |
| og:image:alt | I'm trying to use custom class implementing Set and Comparable interface in Jython but have the following error : Exception in thread "main" TypeError: Supertypes that share a modified attribute ha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bomboleo |
| hostname | github.com |
| expected-hostname | github.com |
| None | f68b42d371252b0f236260d6234f4304a806fe5ac43d59faa21fb59d80df103b |
| turbo-cache-control | no-preview |
| go-import | github.com/jython/jython git https://github.com/jython/jython.git |
| octolytics-dimension-user_id | 10533356 |
| octolytics-dimension-user_login | jython |
| octolytics-dimension-repository_id | 282480317 |
| octolytics-dimension-repository_nwo | jython/jython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 282480317 |
| octolytics-dimension-repository_network_root_nwo | jython/jython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6b74bc8dbcd10b5d69fd9ee9d2cfdc8b35e18a4c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width