Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
place import _datetime upper its usage
  • Loading branch information
youknowone committed Jan 21, 2026
commit c9fa18d0c2d9b99615a76a359bd437d2146ed651
3 changes: 1 addition & 2 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,6 @@ def test_default(self):
self.assertEqual(sys.getsizeof(True, -1), size('') + self.longdigit)

def test_objecttypes(self):
import _datetime

# check all types defined in Objects/
calcsize = struct.calcsize
size = test.support.calcobjsize
Expand Down Expand Up @@ -1743,6 +1741,7 @@ def delx(self): del self.__x
x = property(getx, setx, delx, "")
check(x, size('5Pi'))
# PyCapsule
import _datetime
check(_datetime.datetime_CAPI, size('6P'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @serhiy-storchaka requested, this line should only be run if _datetime is available. Something like:

try:
    import _datetime
except ImportError:
    pass
else:
    check(_datetime.datetime_CAPI, size('6P'))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

# rangeiterator
check(iter(range(1)), size('3l'))
Expand Down
Loading