Skip to content

Commit abd79fb

Browse files
committed
Remove unsafe_object_new
1 parent 633d573 commit abd79fb

2 files changed

Lines changed: 7 additions & 30 deletions

File tree

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
124124
import com.oracle.graal.python.builtins.objects.method.PMethod;
125125
import com.oracle.graal.python.builtins.objects.module.PythonModule;
126-
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
127126
import com.oracle.graal.python.builtins.objects.object.PythonObject;
128127
import com.oracle.graal.python.builtins.objects.set.PSet;
129128
import com.oracle.graal.python.builtins.objects.str.StringUtils;
@@ -1395,19 +1394,4 @@ static PTuple doCreate(long arrowArrayAddr, long arrowSchemaAddr,
13951394
return PFactory.createTuple(ctx.getLanguage(inliningTarget), new Object[]{arrowSchemaCapsule, arrowArrayCapsule});
13961395
}
13971396
}
1398-
1399-
/**
1400-
* Used from datetime module to create new instances of objects that we allow subclassing from
1401-
* native. It's necessary, because the __new__ wrapper would reject native subclasses that
1402-
* override tp_new.
1403-
*/
1404-
@Builtin(name = "unsafe_object_new", minNumOfPositionalArgs = 1)
1405-
@GenerateNodeFactory
1406-
abstract static class UnsafeObjectNewNode extends PythonUnaryBuiltinNode {
1407-
@Specialization
1408-
static Object create(VirtualFrame frame, Object cls,
1409-
@Cached ObjectBuiltins.ObjectNode objectNode) {
1410-
return objectNode.execute(frame, cls, PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS);
1411-
}
1412-
}
14131397
}

graalpython/lib-python/3/_pydatetime.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,7 @@ def __new__(cls, days=0, seconds=0, microseconds=0,
696696
if abs(d) > 999999999:
697697
raise OverflowError("timedelta # of days is too large: %d" % d)
698698

699-
# GraalPy change: unsafe ctor to allow native subclasses
700-
self = __graalpython__.unsafe_object_new(cls)
699+
self = object.__new__(cls)
701700
self._days = d
702701
self._seconds = s
703702
self._microseconds = us
@@ -954,14 +953,12 @@ def __new__(cls, year, month=None, day=None):
954953
"Failed to encode latin1 string when unpickling "
955954
"a date object. "
956955
"pickle.load(data, encoding='latin1') is assumed.")
957-
# GraalPy change: unsafe ctor to allow native subclasses
958-
self = __graalpython__.unsafe_object_new(cls)
956+
self = object.__new__(cls)
959957
self.__setstate(year)
960958
self._hashcode = -1
961959
return self
962960
year, month, day = _check_date_fields(year, month, day)
963-
# GraalPy change: unsafe ctor to allow native subclasses
964-
self = __graalpython__.unsafe_object_new(cls)
961+
self = object.__new__(cls)
965962
self._year = year
966963
self._month = month
967964
self._day = day
@@ -1373,16 +1370,14 @@ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold
13731370
"Failed to encode latin1 string when unpickling "
13741371
"a time object. "
13751372
"pickle.load(data, encoding='latin1') is assumed.")
1376-
# GraalPy change: unsafe ctor to allow native subclasses
1377-
self = __graalpython__.unsafe_object_new(cls)
1373+
self = object.__new__(cls)
13781374
self.__setstate(hour, minute or None)
13791375
self._hashcode = -1
13801376
return self
13811377
hour, minute, second, microsecond, fold = _check_time_fields(
13821378
hour, minute, second, microsecond, fold)
13831379
_check_tzinfo_arg(tzinfo)
1384-
# GraalPy change: unsafe ctor to allow native subclasses
1385-
self = __graalpython__.unsafe_object_new(cls)
1380+
self = object.__new__(cls)
13861381
self._hour = hour
13871382
self._minute = minute
13881383
self._second = second
@@ -1703,17 +1698,15 @@ def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
17031698
"Failed to encode latin1 string when unpickling "
17041699
"a datetime object. "
17051700
"pickle.load(data, encoding='latin1') is assumed.")
1706-
# GraalPy change: unsafe ctor to allow native subclasses
1707-
self = __graalpython__.unsafe_object_new(cls)
1701+
self = object.__new__(cls)
17081702
self.__setstate(year, month)
17091703
self._hashcode = -1
17101704
return self
17111705
year, month, day = _check_date_fields(year, month, day)
17121706
hour, minute, second, microsecond, fold = _check_time_fields(
17131707
hour, minute, second, microsecond, fold)
17141708
_check_tzinfo_arg(tzinfo)
1715-
# GraalPy change: unsafe ctor to allow native subclasses
1716-
self = __graalpython__.unsafe_object_new(cls)
1709+
self = object.__new__(cls)
17171710
self._year = year
17181711
self._month = month
17191712
self._day = day

0 commit comments

Comments
 (0)