How about this:

```
try:
    username, password = get_auth_from_url(new_proxies[scheme])
except KeyError:
    username = password = None

if username and password:
    headers['Proxy-Authorization'] = _basic_auth_str(username, password)
```

In general, I cringe when I see code inside the `try` block that will not raise the exception being caught. Further this will allow you to keep your `KeyError` (=P) and use the except block in a meaningful way. It also is a bit nicer than the original suggestion I had.