@@ -134,14 +134,17 @@ def async_get_unique(self, entry: _UniqueRecordsType) -> Optional[DNSRecord]:
|
134 | 134 | return None |
135 | 135 | return store.get(entry) |
136 | 136 | |
137 | | -def async_all_by_details(self, name: str, type_: int, class_: int) -> Iterator[DNSRecord]: |
| 137 | +def async_all_by_details(self, name: _str, type_: int, class_: int) -> Iterator[DNSRecord]: |
138 | 138 | """Gets all matching entries by details. |
139 | 139 | |
140 | 140 | This function is not threadsafe and must be called from |
141 | 141 | the event loop. |
142 | 142 | """ |
143 | 143 | key = name.lower() |
144 | | -for entry in self.cache.get(key, []): |
| 144 | +records = self.cache.get(key) |
| 145 | +if records is None: |
| 146 | +return |
| 147 | +for entry in records: |
145 | 148 | if _dns_record_matches(entry, key, type_, class_): |
146 | 149 | yield entry |
147 | 150 | |
@@ -151,15 +154,15 @@ def async_entries_with_name(self, name: str) -> Dict[DNSRecord, DNSRecord]:
|
151 | 154 | This function is not threadsafe and must be called from |
152 | 155 | the event loop. |
153 | 156 | """ |
154 | | -return self.cache.get(name.lower(), {}) |
| 157 | +return self.cache.get(name.lower()) or {} |
155 | 158 | |
156 | 159 | def async_entries_with_server(self, name: str) -> Dict[DNSRecord, DNSRecord]: |
157 | 160 | """Returns a dict of entries whose key matches the server. |
158 | 161 | |
159 | 162 | This function is not threadsafe and must be called from |
160 | 163 | the event loop. |
161 | 164 | """ |
162 | | -return self.service_cache.get(name.lower(), {}) |
| 165 | +return self.service_cache.get(name.lower()) or {} |
163 | 166 | |
164 | 167 | # The below functions are threadsafe and do not need to be run in the |
165 | 168 | # event loop, however they all make copies so they significantly |
|