Is it necessary to check for `package in _registry`?

```python
if package is not None and package in _registry:
```

Otherwise this new code will raise a `KeyError` where it previously did not. I did not study the larger context, so maybe that is desired?