Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graalpython/com.oracle.graal.python.cext/src/datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -7669,7 +7669,7 @@ GraalPyPrivate_InitNativeDateTime(void)
(intptr_t)&PyDateTime_DateTimeType, (intptr_t)"datetime.datetime",
(intptr_t)&PyDateTime_TimeType, (intptr_t)"datetime.time",
(intptr_t)&PyDateTime_DeltaType, (intptr_t)"datetime.timedelta",
(intptr_t)&PyDateTime_TZInfoType, (intptr_t)"datetime.timezone",
(intptr_t)&PyDateTime_TZInfoType, (intptr_t)"datetime.tzinfo",
0, 0
};
GraalPyPrivate_InitBuiltinTypesAndStructs(datetime_types);
Expand Down
32 changes: 32 additions & 0 deletions graalpython/com.oracle.graal.python.test/src/tests/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,20 @@ def __new__(cls, x, y):
@skipIf(sys.implementation.name == 'cpython' and sys.version_info[0:2] < (3, 8), "skipping for cPython versions < 3.8")
def test_flags():
import functools
import typing

def testfunction(self):
"""some doc"""
return self

TPFLAGS_SEQUENCE = 1 << 5
TPFLAGS_MAPPING = 1 << 6
TPFLAGS_HEAPTYPE = 1 << 9
TPFLAGS_BASETYPE = 1 << 10
TPFLAGS_HAVE_GC = 1 << 14
TPFLAGS_METHOD_DESCRIPTOR = 1 << 17
TPFLAGS_MATCH_SELF = 1 << 22
TPFLAGS_ITEMS_AT_END = 1 << 23
TPFLAGS_LONG_SUBCLASS = 1 << 24
TPFLAGS_LIST_SUBCLASS = 1 << 25
TPFLAGS_TUPLE_SUBCLASS = 1 << 26
Expand All @@ -231,6 +239,18 @@ def testfunction(self):

cached = functools.lru_cache(1)(testfunction)

assert typing.Generic.__flags__ & TPFLAGS_HEAPTYPE
assert object.__flags__ & TPFLAGS_BASETYPE
assert not slice.__flags__ & TPFLAGS_BASETYPE
assert type.__flags__ & TPFLAGS_HAVE_GC
assert list.__flags__ & TPFLAGS_SEQUENCE
assert list.__flags__ & TPFLAGS_MATCH_SELF
assert dict.__flags__ & TPFLAGS_MAPPING
assert BaseException.__flags__ & TPFLAGS_BASE_EXC_SUBCLASS
assert ValueError.__flags__ & TPFLAGS_BASE_EXC_SUBCLASS
assert ValueError.__flags__ & TPFLAGS_HAVE_GC
assert type.__flags__ & TPFLAGS_ITEMS_AT_END
assert type.__flags__ & TPFLAGS_TYPE_SUBCLASS
assert not type(repr).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, "masked __flags__ = {}, expected {}".format(type(repr).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, 0)
assert type(list.append).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, "masked __flags__ = {}, expected {}".format(type(repr).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, TPFLAGS_METHOD_DESCRIPTOR)
assert type(list.__add__).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, "masked __flags__ = {}, expected {}".format(type(repr).__flags__ & TPFLAGS_METHOD_DESCRIPTOR, TPFLAGS_METHOD_DESCRIPTOR)
Expand Down Expand Up @@ -322,10 +342,22 @@ class SubSlots(BaseSlots, Base):


def test_itemsize():
import types

assert object.__itemsize__ == 0
assert list.__itemsize__ == 0
assert type.__itemsize__ == 40
assert bytes.__itemsize__ == 1
assert int.__itemsize__ == 4
assert bool.__itemsize__ == 4
assert tuple.__itemsize__ == 8
assert types.CodeType.__itemsize__ == 2
assert types.GeneratorType.__itemsize__ == 8
assert types.CoroutineType.__itemsize__ == 8
assert types.AsyncGeneratorType.__itemsize__ == 8
assert types.FrameType.__itemsize__ == 8
assert memoryview.__itemsize__ == 8
assert type(sys.version_info).__itemsize__ == 8

class C: pass
assert C.__itemsize__ == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ test.test_typing.GenericTests.test_pep_695_generic_function_with_future_annotati
test.test_typing.GenericTests.test_pep_695_generic_method_with_future_annotations @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.GenericTests.test_pep_695_generic_method_with_future_annotations_name_clash_with_global_vars @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.GenericTests.test_pep_695_generics_with_future_annotations_nested_in_function @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.GenericTests.test_pickle @ linux-x86_64
test.test_typing.GenericTests.test_repr @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.GenericTests.test_repr_2 @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.GenericTests.test_repr_3 @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
Expand Down Expand Up @@ -452,6 +453,7 @@ test.test_typing.ProtocolTests.test_protocols_isinstance_properties_and_descript
test.test_typing.ProtocolTests.test_protocols_isinstance_py36 @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.ProtocolTests.test_protocols_issubclass @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.ProtocolTests.test_protocols_issubclass_non_callable @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.ProtocolTests.test_protocols_pickleable @ linux-x86_64
test.test_typing.ProtocolTests.test_protocols_support_register @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.ProtocolTests.test_reversible @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
test.test_typing.ProtocolTests.test_runtime_checkable_generic @ darwin-arm64,linux-aarch64,linux-aarch64-github,linux-x86_64,linux-x86_64-github,win32-AMD64,win32-AMD64-github
Expand Down
Loading
Loading