This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve errors related to frozen modules.
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: FFY00, barry, brett.cannon, eric.snow, lukasz.langa
Priority: normal Keywords: patch

Created on 2021-10-05 15:52 by eric.snow, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 29180 open FFY00, 2021-10-22 23:56
PR 29189 merged FFY00, 2021-10-23 12:24
PR 29190 merged FFY00, 2021-10-23 12:49
Messages (5)
msg403246 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2021-10-05 15:51
In Python/import.c there are various situations in which an error state related to frozen modules might result and even lead to an exception.  In gh-28633 we consolidated these cases into a new "frozen_status" enum and added "set_frozen_error()" to set a consistent exception based on a status.

There are several deficiencies to address at this point:

* the conditions for the statuses are unclear [1][2]
* the error messages could be more helpful [3]
* maybe use a different error message for FROZEN_BAD_NAME (and perhaps FROZEN_DISABLED), rather than combining with FROZEN_NOT_FOUND 


[1] https://github.com/python/cpython/pull/28633#discussion_r720503665
[2] https://github.com/python/cpython/pull/28633#discussion_r720504275
[3] https://github.com/python/cpython/pull/28633#discussion_r720987412
msg404845 - (view) Author: Filipe Laíns (FFY00) * (Python triager) Date: 2021-10-22 23:39
I was looking at the code and it seems PyImport_ImportFrozenModuleObject does not set an error on FROZEN_BAD_NAME, it just returns 0, is this intended? If I pass a bogus object, it will just return 0.
This does not seem right.

Currently, FROZEN_BAD_NAME is never passed to set_frozen_error.
msg404867 - (view) Author: Filipe Laíns (FFY00) * (Python triager) Date: 2021-10-23 12:19
FROZEN_EXCLUDED is set when frozen modules have no code associated with them, and the _freeze_module tool doesn't seem to be able to produce such output.

We could remove it and replace it with an assert, but that does not give us much benefit, so we should probably leave it be and just document it a little bit better.
msg405260 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-28 20:20
New changeset 233841ab782953510ad308dc6173072a6cc6a1cd by Filipe Laíns in branch 'main':
bpo-45379: add custom error string for FROZEN_DISABLED (GH-29190)
https://github.com/python/cpython/commit/233841ab782953510ad308dc6173072a6cc6a1cd
msg405345 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-29 20:55
New changeset c2d0ba722a7b3839685af968cf0c304a24cdf525 by Filipe Laíns in branch 'main':
bpo-45379: clarify FROZEN_EXCLUDED and FROZEN_INVALID documentation (GH-29189)
https://github.com/python/cpython/commit/c2d0ba722a7b3839685af968cf0c304a24cdf525
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89542
2021-10-29 20:55:22lukasz.langasetmessages: + msg405345
2021-10-28 20:20:15lukasz.langasetnosy: + lukasz.langa
messages: + msg405260
2021-10-23 12:49:49FFY00setpull_requests: + pull_request27461
2021-10-23 12:24:39FFY00setstage: needs patch -> patch review
pull_requests: + pull_request27460
2021-10-23 12:19:48FFY00setmessages: + msg404867
stage: patch review -> needs patch
2021-10-22 23:56:41FFY00setkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request27454
2021-10-22 23:39:10FFY00setmessages: + msg404845
2021-10-15 18:35:55FFY00setnosy: + FFY00
2021-10-05 15:52:00eric.snowcreate