-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Make sure isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar)
is unaffected by sys.setprofile()
#407
Conversation
cd ${path_to_file%.tar.gz}/src | ||
python test_typing_extensions.py |
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 raising ModuleNotFoundError
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.
With your change it uses the copy of typing_extensions
in the repo instead of the installed one; that is incorrect. We shouldn't do this.
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_extensions
prior 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_extensions
we want into an src/
directory, but never cd
into that src
directory, 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.
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 |
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 tried running this in an isolated scope using exec()
, but it was still causing some pollution of the global environment that was causing other, unrelated tests to fail. This seems to be the only way of doing a test with total interpreter isolation.
isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar)
is unaffected by profiling functionsisinstance(typing_extensions.ParamSpec("P"), typing.TypeVar)
is unaffected by sys.setprofile()
The 4.12.0 release should go out today, do you think it's better to merge this in now or wait for the next release? The change seems pretty safe so I think it's fine to merge now in the RC phase. |
Oh shoot, sorry -- I merged before seeing this. I think it's okay to put it into the next release; I agree that this change seems pretty safe. But I also don't think that this issue affects many people, so I would also be fine with cutting the release based on the commit prior to this. |
Fixes #318. The workaround here is to avoid the
super()
call -- thesuper()
call accesses the__class__
variable from the__init__
method, which due to a CPython bug on Python <=3.10 means that__class__
is removed fromParamSpec.__dict__
if a profiling function has been set.