Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 138
Make sure isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar) is unaffected by sys.setprofile()#407
New issue
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9cc0985211e953652df9c4ebaa084c3ac104c54e15b1d713749cc06aae33db803a2ade53112080327e20729c942File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5020,6 +5020,48 @@ def test_eq(self): | ||
| # won't be the same. | ||
| self.assertNotEqual(hash(ParamSpec('P')), hash(P)) | ||
| def test_isinstance_results_unaffected_by_presence_of_tracing_function(self): | ||
| # See https://github.com/python/typing_extensions/issues/318 | ||
| code = textwrap.dedent( | ||
| """\ | ||
| import sys, typing | ||
| def trace_call(*args): | ||
| return trace_call | ||
| def run(): | ||
| sys.modules.pop("typing_extensions", None) | ||
| from typing_extensions import ParamSpec | ||
| return isinstance(ParamSpec("P"), typing.TypeVar) | ||
| isinstance_result_1 = run() | ||
| sys.setprofile(trace_call) | ||
| isinstance_result_2 = run() | ||
| sys.stdout.write(f"{isinstance_result_1} {isinstance_result_2}") | ||
| """ | ||
| ) | ||
| # Run this in an isolated process or it pollutes the environment | ||
| # and makes other tests fail: | ||
| try: | ||
| proc = subprocess.run( | ||
| [sys.executable, "-c", code], check=True, capture_output=True, text=True, | ||
| ) | ||
| except subprocess.CalledProcessError as exc: | ||
| print("stdout", exc.stdout, sep="\n") | ||
| print("stderr", exc.stderr, sep="\n") | ||
| raise | ||
Comment on lines
+5047
to
+5054
MemberAuthor 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. I tried running this in an isolated scope using | ||
| # Sanity checks that assert the test is working as expected | ||
| self.assertIsInstance(proc.stdout, str) | ||
| result1, result2 = proc.stdout.split(" ") | ||
| self.assertIn(result1, {"True", "False"}) | ||
| self.assertIn(result2, {"True", "False"}) | ||
| # The actual test: | ||
| self.assertEqual(result1, result2) | ||
| class ConcatenateTests(BaseTestCase): | ||
| def test_basics(self): | ||
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 had to make this change or the subprocess wasn't able to
import typing_extensions. It was raisingModuleNotFoundErrorThere 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.
With your change it uses the copy of
typing_extensionsin the repo instead of the installed one; that is incorrect. We shouldn't do this.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.
I see, thanks. Do you have any idea why the subprocess wasn't able to import
typing_extensionsprior to this change, but only for this CI job? I don't fully understand that (see https://github.com/python/typing_extensions/actions/runs/9197903212/job/25299411282?pr=407)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.
Oh actually, this might be fine, since in this job we're not attempting to test an installed version of typing_extensions. I'm not actually sure why this doesn't work in CI though. Possibly the test itself is picking up the wrong copy of
typing_extensions.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'm actually not sure how the pre-existing tests currently pass without this? I think it's correct? Otherwise we unpack the version of
typing_extensionswe want into ansrc/directory, but nevercdinto thatsrcdirectory, right?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.
Yes, that's what it looks like.