| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -13,6 +13,7 @@ | |
| import re | ||
| import struct | ||
| import sys | ||
| import textwrap | ||
| import unittest | ||
| import warnings | ||
|
|
||
| Expand All | @@ -22,7 +23,7 @@ | |
|
|
||
| from test import support | ||
| from test.support import is_resource_enabled, ALWAYS_EQ, LARGEST, SMALLEST | ||
| from test.support import warnings_helper | ||
| from test.support import script_helper, warnings_helper | ||
|
|
||
| import datetime as datetime_module | ||
| from datetime import MINYEAR, MAXYEAR | ||
| Expand Down Expand Up | @@ -6781,6 +6782,48 @@ def test_datetime_from_timestamp(self): | |
| self.assertEqual(dt_orig, dt_rt) | ||
|
|
||
|
|
||
| class ExtensionModuleTests(unittest.TestCase): | ||
|
|
||
| def setUp(self): | ||
| if self.__class__.__name__.endswith('Pure'): | ||
| self.skipTest('Not relevant in pure Python') | ||
|
|
||
| @support.cpython_only | ||
| def test_gh_120161(self): | ||
| with self.subTest('simple'): | ||
| script = textwrap.dedent(""" | ||
| import datetime | ||
| from _ast import Tuple | ||
| f = lambda: None | ||
| Tuple.dims = property(f, f) | ||
|
|
||
| class tzutc(datetime.tzinfo): | ||
| pass | ||
| """) | ||
| script_helper.assert_python_ok('-c', script) | ||
|
|
||
| with self.subTest('complex'): | ||
| script = textwrap.dedent(""" | ||
| import asyncio | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would separate this test into its own method, it imports asyncio. Which means that it needs @requires_working_socket() decorator
Sorry, something went wrong.
ericsnowcurrently reacted with thumbs up emoji
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBtw, why does it need asyncio? 🤔
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBecause of the original issue (the snippet is taken almost verbatim).
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityImporting asyncio on its own is not enough to be a problem. I was able to verify that it works fine on a WASI build (where @requires_working_socket() would skip). This is also verified by the WASI CI check passing. Unless there is another reason to do so, I'd rather not add that decorator.
Sorry, something went wrong.
sobolevn reacted with thumbs up emoji
All reactions
|
||
| import datetime | ||
| from typing import Type | ||
|
|
||
| class tzutc(datetime.tzinfo): | ||
| pass | ||
| _EPOCHTZ = datetime.datetime(1970, 1, 1, tzinfo=tzutc()) | ||
|
|
||
| class FakeDateMeta(type): | ||
| def __instancecheck__(self, obj): | ||
| return True | ||
| class FakeDate(datetime.date, metaclass=FakeDateMeta): | ||
| pass | ||
| def pickle_fake_date(datetime_) -> Type[FakeDate]: | ||
| # A pickle function for FakeDate | ||
| return FakeDate | ||
| """) | ||
| script_helper.assert_python_ok('-c', script) | ||
|
|
||
|
|
||
| def load_tests(loader, standard_tests, pattern): | ||
| standard_tests.addTest(ZoneInfoCompleteTest()) | ||
| return standard_tests | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| :mod:`datetime` no longer crashes in certain complex reference cycle | ||
| situations. |
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@cpython_only?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWe could, but currently there's mostly no need. If the extension module ("_datetime") doesn't exist then the "fast" version of the test is never created, and the pure-Python version of the test already always skips. (See Lib/test/test_datetime.py.) Also note that @cpython_only would mean the test wouldn't be run for Python implementations that do provide a _datetime accelerator module.
All that said, I don't see any harm with adding @cpython_only on the new test method. I would certainly only expect it to fail on CPython. Thanks for bringing this up.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.