Skip to content

Commit b817122

Browse files
committed
[GR-54977] Patch typing_extensions to recognize _py_abc like stdlib typing module.
PullRequest: graalpython/3384
2 parents 406e5b9 + d4a598b commit b817122

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFuncBuiltins.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ static Object staticmethod(Object callable,
8989
abstract static class PyTruffleCFunction_SetDoc extends CApiBinaryBuiltinNode {
9090
@Specialization
9191
@TruffleBoundary
92-
static Object set(Object functionObj, TruffleString doc) {
92+
static Object setString(Object functionObj, TruffleString doc) {
93+
return setDoc(functionObj, doc);
94+
}
95+
96+
@Specialization(guards = "isNoValue(nullValue)")
97+
@TruffleBoundary
98+
static Object setNull(Object functionObj, @SuppressWarnings("unused") PNone nullValue) {
99+
return setDoc(functionObj, null);
100+
}
101+
102+
private static PNone setDoc(Object functionObj, TruffleString doc) {
93103
PBuiltinFunction function;
94104
if (functionObj instanceof PBuiltinFunction builtinFunction) {
95105
function = builtinFunction;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[rules]]
2+
patch = 'typing_extensions.patch'
3+
subdir = 'src'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/typing_extensions.py b/typing_extensions.py
2+
index dec429c..3b711c6 100644
3+
--- a/typing_extensions.py
4+
+++ b/typing_extensions.py
5+
@@ -544,7 +544,7 @@ else:
6+
The abc and functools modules indiscriminately call isinstance() and
7+
issubclass() on the whole MRO of a user class, which may contain protocols.
8+
"""
9+
- return _caller(depth) in {'abc', 'functools', None}
10+
+ return _caller(depth) in {'abc', 'functools', '_py_abc', None}
11+
12+
def _no_init(self, *args, **kwargs):
13+
if type(self)._is_protocol:

mx.graalpython/mx_graalpython.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,8 @@ def _python_checkpatchfiles():
21662166
'autopep8.patch',
21672167
# Whole license in the field. It's MIT
21682168
'tiktoken-0.7.0.patch',
2169+
# License field is null. It's PSF
2170+
'typing_extensions.patch',
21692171
}
21702172
allowed_licenses = [
21712173
"MIT",

0 commit comments

Comments
 (0)