bpo-43988: Add test.support.check_disallow_instantiation by erlend-aasland · Pull Request #25757 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation17 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

erlend-aasland

@erlend-aasland

vstinner

See bpo-43916.
"""
msg = f"cannot create '{tp.__module__}\.{tp.__name__}' instances"

Choose a reason for hiding this comment

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

You should use f"xxx\.xxx" or fr"xxx.xxx". Or maybe use re.escape().

Choose a reason for hiding this comment

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

Since these tests are decorated with cpython_only, it should be ok to match the exact string, as produced by Objects/typeobject.c? Just matching the type module/name could in theory generate wrong result; maybe not in practice though.

Choose a reason for hiding this comment

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

What about setting the match pattern depending on what test.support.check_impl_detail() says?

vstinner

vstinner

@vstinner

Enough nitpicking, you can always enhance the code later ;-) I merged your PR, thanks. I guess that the next step is to modify existing tests to use it.

@erlend-aasland

Backport to 3.10? I guess not.

@vstinner

Backport to 3.10? I guess not.

It seems like more changes are coming. Once they all landed into main, maybe write a backport to 3.10 PR including all of them at once (git cherry-pick -x all commits in the right order). Or we can leave 3.10 as it is: it's more up to you.

@erlend-aasland

Lets leave 3.10 as it is.

@erlend-aasland

@pablogsal, should we backport this? grep -r disallow_insta Lib/test | wc -l gives me 14 hits on the 3.10 branch, including the recently backported sqlite3 test.

@pablogsal

@pablogsal, should we backport this? grep -r disallow_insta Lib/test | wc -l gives me 14 hits on the 3.10 branch, including the recently backported sqlite3 test.

I would prefer to backport it, yep

erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request

Jun 23, 2021

…thonGH-25757).

(cherry picked from commit 4f72526)

Co-authored-by: Erlend Egeberg Aasland erlend.aasland@innova.no

@erlend-aasland

Once they all landed into main, maybe write a backport to 3.10 PR including all of them at once (git cherry-pick -x all commits in the right order)

@vstinner: I've opened GH-26885 which is a backport of this PR, GH-26394 (docs for this PR), and GH-26392 (apply this PR to Lib/test).