PEP476: Updated based on proposed API from Nick. Also note that #22366 has been landed.