Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
97bdaa2
Make use of find_frozen() more consistent.
ericsnowcurrently Sep 29, 2021
e2e676d
Drop some one-off helper functions.
ericsnowcurrently Sep 29, 2021
6333212
Factor out unmarshal_frozen_code().
ericsnowcurrently Sep 29, 2021
8cd239b
Add a "data" arg to _imp.get_frozen_object().
ericsnowcurrently Sep 29, 2021
7724019
Add _imp.find_frozen().
ericsnowcurrently Sep 29, 2021
0dd3870
Use _imp.find_frozen() in the frozen importer.
ericsnowcurrently Sep 29, 2021
1a0ad16
Clear loader_state to save memory.
ericsnowcurrently Sep 29, 2021
fdf7689
Only call is_frozen() in the fallback case.
ericsnowcurrently Sep 29, 2021
385d412
Add a NEWS entry.
ericsnowcurrently Sep 29, 2021
e0fe501
Add a missing "static" declaration.
ericsnowcurrently Sep 29, 2021
7221e0e
Treat FROZEN_BAD_NAME as FROZEN_NOT_FOUND in some cases.
ericsnowcurrently Sep 29, 2021
5f68ee8
Make frozen_info.size Py_ssize_t.
ericsnowcurrently Sep 29, 2021
7b85a63
Py_ssize_t is never smaller than int.
ericsnowcurrently Sep 29, 2021
cdbc611
name -> nameobj.
ericsnowcurrently Sep 29, 2021
c6e70cc
Add tests.
ericsnowcurrently Sep 30, 2021
f86dcd5
Tweak the tests.
ericsnowcurrently Oct 1, 2021
d1b1868
Default to using _imp.get_frozen_object().
ericsnowcurrently Oct 1, 2021
4e105a9
Do not use <> to mark source package.
ericsnowcurrently Oct 1, 2021
5d6af1e
Drop unused code.
ericsnowcurrently Oct 1, 2021
017c932
Store data in loader_state directly.
ericsnowcurrently Oct 2, 2021
1a833ed
Set "name" on import errors.
ericsnowcurrently Oct 2, 2021
5363708
Use a narrower exception.
ericsnowcurrently Oct 2, 2021
07c947f
Fix a comment.
ericsnowcurrently Oct 2, 2021
cddf089
Clarify a comment.
ericsnowcurrently Oct 2, 2021
ca0500f
Add a note about why we silence an error.
ericsnowcurrently Oct 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add _imp.find_frozen().
  • Loading branch information
ericsnowcurrently committed Oct 1, 2021
commit 77240191d1219ae52ced66d448fd7f8bd3baecba
39 changes: 38 additions & 1 deletion Python/clinic/import.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,43 @@ _imp_init_frozen_impl(PyObject *module, PyObject *name)
return import_add_module(tstate, name);
}

/*[clinic input]
_imp.find_frozen

name: unicode
/

Return info about the corresponding frozen module (if there is one) or None.

The returned info (a 2-tuple):

* data the raw marshalled bytes
* is_package whether or not it is a package
[clinic start generated code]*/

static PyObject *
_imp_find_frozen_impl(PyObject *module, PyObject *name)
/*[clinic end generated code: output=3fd17da90d417e4e input=4e52b3ac95f6d7ab]*/
{
struct frozen_info info;
frozen_status status = find_frozen(name, &info);
if (status == FROZEN_NOT_FOUND || status == FROZEN_DISABLED) {
Py_RETURN_NONE;
}
else if (status != FROZEN_OKAY) {
set_frozen_error(status, name);
return NULL;
}
PyObject *data = PyBytes_FromStringAndSize(info.data, info.size);
if (data == NULL) {
return NULL;
}
PyObject *result = PyTuple_Pack(2, data,
info.is_package ? Py_True : Py_False);
Py_DECREF(data);
return result;
}

/*[clinic input]
_imp.get_frozen_object

Expand Down Expand Up @@ -2276,6 +2313,7 @@ static PyMethodDef imp_methods[] = {
_IMP_LOCK_HELD_METHODDEF
_IMP_ACQUIRE_LOCK_METHODDEF
_IMP_RELEASE_LOCK_METHODDEF
_IMP_FIND_FROZEN_METHODDEF
_IMP_GET_FROZEN_OBJECT_METHODDEF
_IMP_IS_FROZEN_PACKAGE_METHODDEF
_IMP_CREATE_BUILTIN_METHODDEF
Expand Down