GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-143959: Make _datetime optional for test_sys by youknowone · Pull Request #144003 · python/cpython

Conversation

@youknowone

@youknowone youknowone commented Jan 18, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The _datetime dependency of test_sys is only required for @cpython_only decorated test.

  • Issue: test_sys globally requires _datetime for cpython_only test #143959

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
pythongh-143959 make test_sys import _datetime inside the test
c881be5
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Jan 18, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jan 18, 2026
test_sys globally requires _datetime for cpython_only test #143959
Open
@bedevere-app bedevere-app Bot added the awaiting review label Jan 18, 2026
vstinner
vstinner approved these changes Jan 19, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jan 19, 2026
@vstinner vstinner added skip news awaiting merge and removed awaiting merge labels Jan 19, 2026
serhiy-storchaka
serhiy-storchaka reviewed Jan 20, 2026
View reviewed changes
Comment thread Lib/test/test_sys.py Outdated
self.assertEqual(sys.getsizeof(True, -1), size('') + self.longdigit)

def test_objecttypes(self):
import _datetime

@serhiy-storchaka serhiy-storchaka Jan 20, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest to import it just before it is used, like collections.

And since it is optional, skip the corresponding test if the import fails.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@youknowone youknowone Jan 21, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! Fixed it

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Jan 21, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And since it is optional, skip the corresponding test if the import fails.

_datetime is now a built-in module, it's not really optional.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Jan 21, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Isn't it just an implementation detail? It was made builtin to solve a particular technical issue which can be solved in other way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Jan 20, 2026
@youknowone
place import _datetime upper its usage
c9fa18d
vstinner
vstinner reviewed Jan 21, 2026
View reviewed changes
Comment thread Lib/test/test_sys.py Outdated
check(x, size('5Pi'))
# PyCapsule
import _datetime
check(_datetime.datetime_CAPI, size('6P'))

@vstinner vstinner Jan 21, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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'))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@youknowone youknowone Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
try _datetime and run check
102aae2
vstinner
vstinner approved these changes Jan 22, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka approved these changes Jan 22, 2026
View reviewed changes
@serhiy-storchaka
serhiy-storchaka merged commit c447d1b into python:main Jan 22, 2026
45 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 22, 2026
@miss-islington-app

miss-islington-app Bot commented Jan 22, 2026

Copy link
Copy Markdown

Thanks @youknowone for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 22, 2026
@youknowone @miss-islington
pythongh-143959: Make _datetime optional for test_sys (pythonGH-144003)
e67612e
(cherry picked from commit c447d1b)

Co-authored-by: Jeong, YunWon <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 22, 2026
@youknowone @miss-islington
pythongh-143959: Make _datetime optional for test_sys (pythonGH-144003)
97bef04
(cherry picked from commit c447d1b)

Co-authored-by: Jeong, YunWon <[email protected]>
@bedevere-app

bedevere-app Bot commented Jan 22, 2026

Copy link
Copy Markdown

GH-144143 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jan 22, 2026
@bedevere-app

bedevere-app Bot commented Jan 22, 2026

Copy link
Copy Markdown

GH-144144 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jan 22, 2026
vstinner pushed a commit that referenced this pull request Jan 22, 2026
@miss-islington @youknowone
[3.13] gh-143959: Make _datetime optional for test_sys (GH-144003) (#…
015b90d
…144144)

gh-143959: Make _datetime optional for test_sys (GH-144003)
(cherry picked from commit c447d1b)

Co-authored-by: Jeong, YunWon <[email protected]>
vstinner pushed a commit that referenced this pull request Jan 22, 2026
@miss-islington @youknowone
[3.14] gh-143959: Make _datetime optional for test_sys (GH-144003) (#…
6ec9485
…144143)

gh-143959: Make _datetime optional for test_sys (GH-144003)
(cherry picked from commit c447d1b)

Co-authored-by: Jeong, YunWon <[email protected]>
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@youknowone @thunder-coding
pythongh-143959: Make _datetime optional for test_sys (pythonGH-144003)
8efd009
@vstinner vstinner changed the title gh-143959 make test_sys import _datetime inside the test gh-143959: Make _datetime optional for test_sys Feb 19, 2026
@youknowone youknowone mentioned this pull request Feb 21, 2026
test_sys globally requires _datetime for cpython_only test youknowone/cpython#26
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@youknowone @vstinner @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.