You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2020-06-05.21:01:25.172>created_at=<Date2013-11-01.03:16:53.747>labels= ['type-feature', 'library']
title='Relax the type restriction on reloaded modules'updated_at=<Date2020-06-05.21:01:25.171>user='https://github.com/ericsnowcurrently'
The first thing that importlib.reload() does is to verify that the passed module is an instance of types.ModuleType (Lib/importlib/init.py:107). This check seems unnecessary to me. We really don't have a functional need for the check (that I know of). Furthermore, there has been at least one serious proposal recently that suggested using custom module types.
The only benefit that I can think of to the type check is it makes the failure more clear when someone tries to "reload" an attribute in a module (thinking just the attribute will get reloaded!). However, does that matter all that much now that reload() is not a builtin (ergo less likely to get misused very often)?
I'm not invested in removing these 2 lines (or at least loosening the restriction). I've brought it up simply because it keeps staring me in the face lately. :-) If anyone has any objections, I'll drop it (at least it will be recorded here in the tracker). That said, I'm glad to remove the restriction otherwise.