Skip to content

Commit 3b09630

Browse files
committed
[GR-67568] Intrinsify datetime module
PullRequest: graalpython/3935
2 parents 072047b + e4c7fa4 commit 3b09630

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+14018
-124
lines changed

graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Builtin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959

6060
boolean takesVarKeywordArgs() default false;
6161

62+
/** positional parameter names */
6263
String[] parameterNames() default {};
6364

65+
/** parameters that cannot be passed as positional ones */
6466
String[] keywordOnlyNames() default {};
6567

6668
boolean isClassmethod() default false;

graalpython/com.oracle.graal.python.frozen/freeze_modules.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ def add_graalpython_core():
113113
for name in [
114114
"modules/_sysconfigdata",
115115
"modules/_polyglot",
116-
"modules/_polyglot_datetime",
117116
"modules/_polyglot_time",
118117
]:
119118
modname = os.path.basename(name)

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_datetime.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -40,6 +40,9 @@
4040
import unittest
4141

4242
from . import CPyExtType, CPyExtTestCase, CPyExtFunction, unhandled_error_compare, is_native_object
43+
import sys
44+
45+
GRAALPYTHON = sys.implementation.name == "graalpy"
4346

4447

4548
def create_datetime_subclass(typename):
@@ -617,24 +620,60 @@ class TestNativeSubclasses(unittest.TestCase):
617620
def test_time(self):
618621
for t in (NativeTimeSubclass, ManagedNativeTimeSubclass):
619622
x = t(hour=6)
620-
assert is_native_object(x)
621623
assert x.hour == 6
622624

625+
if GRAALPYTHON:
626+
x = NativeTimeSubclass()
627+
assert not is_native_object(x)
628+
assert is_native_object(type(x))
629+
630+
x = ManagedNativeTimeSubclass()
631+
assert not is_native_object(x)
632+
assert not is_native_object(type(x))
633+
assert is_native_object(type(x).__bases__[0])
634+
623635
def test_date(self):
624636
for t in (NativeDateSubclass, ManagedNativeDateSubclass):
625637
x = t(1992, 4, 11)
626-
assert is_native_object(x)
627638
assert x.day == 11
628639

640+
if GRAALPYTHON:
641+
x = NativeDateSubclass(1992, 4, 11)
642+
assert not is_native_object(x)
643+
assert is_native_object(type(x))
644+
645+
x = ManagedNativeDateSubclass(1992, 4, 11)
646+
assert not is_native_object(x)
647+
assert not is_native_object(type(x))
648+
assert is_native_object(type(x).__bases__[0])
649+
629650
def test_datetime(self):
630651
for t in (NativeDateTimeSubclass, ManagedNativeDateTimeSubclass):
631652
x = t(1992, 4, 11, hour=13)
632-
assert is_native_object(x)
633653
assert x.day == 11
634654
assert x.hour == 13
635655

656+
if GRAALPYTHON:
657+
x = NativeDateTimeSubclass(1992, 4, 11)
658+
assert not is_native_object(x)
659+
assert is_native_object(type(x))
660+
661+
x = ManagedNativeDateTimeSubclass(1992, 4, 11)
662+
assert not is_native_object(x)
663+
assert not is_native_object(type(x))
664+
assert is_native_object(type(x).__bases__[0])
665+
636666
def test_timedelta(self):
637667
for t in (NativeDeltaSubclass, ManagedNativeDeltaSubclass):
638668
x = t(hours=6)
639-
assert is_native_object(x)
640669
assert x.seconds == 21600
670+
671+
if GRAALPYTHON:
672+
x = NativeDeltaSubclass()
673+
assert not is_native_object(x)
674+
assert is_native_object(type(x))
675+
676+
x = ManagedNativeDeltaSubclass()
677+
assert not is_native_object(x)
678+
assert not is_native_object(type(x))
679+
assert is_native_object(type(x).__bases__[0])

0 commit comments

Comments
 (0)