@@ -271,21 +271,9 @@ def datagram_received(
271
271
self , data : bytes , addrs : Union [Tuple [str , int ], Tuple [str , int , int , int ]]
272
272
) -> None :
273
273
assert self .transport is not None
274
- v6_flow_scope : Union [Tuple [()], Tuple [int , int ]] = ()
275
274
data_len = len (data )
276
275
debug = log .isEnabledFor (logging .DEBUG )
277
276
278
- if len (addrs ) == 2 :
279
- # https://github.com/python/mypy/issues/1178
280
- addr , port = addrs # type: ignore
281
- scope = None
282
- else :
283
- # https://github.com/python/mypy/issues/1178
284
- addr , port , flow , scope = addrs # type: ignore
285
- if debug :
286
- log .debug ('IPv6 scope_id %d associated to the receiving interface' , scope )
287
- v6_flow_scope = (flow , scope )
288
-
289
277
if data_len > _MAX_MSG_ABSOLUTE :
290
278
# Guard against oversized packets to ensure bad implementations cannot overwhelm
291
279
# the system.
@@ -308,15 +296,26 @@ def datagram_received(
308
296
# Guard against duplicate packets
309
297
if debug :
310
298
log .debug (
311
- 'Ignoring duplicate message with no unicast questions received from %r:%r [socket %s] (%d bytes) as [%r]' ,
312
- addr ,
313
- port ,
299
+ 'Ignoring duplicate message with no unicast questions received from %s [socket %s] (%d bytes) as [%r]' ,
300
+ addrs ,
314
301
self .sock_description ,
315
302
data_len ,
316
303
data ,
317
304
)
318
305
return
319
306
307
+ v6_flow_scope : Union [Tuple [()], Tuple [int , int ]] = ()
308
+ if len (addrs ) == 2 :
309
+ # https://github.com/python/mypy/issues/1178
310
+ addr , port = addrs # type: ignore
311
+ scope = None
312
+ else :
313
+ # https://github.com/python/mypy/issues/1178
314
+ addr , port , flow , scope = addrs # type: ignore
315
+ if debug :
316
+ log .debug ('IPv6 scope_id %d associated to the receiving interface' , scope )
317
+ v6_flow_scope = (flow , scope )
318
+
320
319
msg = DNSIncoming (data , (addr , port ), scope , now )
321
320
self .data = data
322
321
self .last_time = now
0 commit comments