mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	[rh:requests] Handle both bytes and int for IncompleteRead.partial (Fix 8a8b54523a) (#8348)
				
					
				
			Authored by: bashonly, coletdjnz, Grub4K
This commit is contained in:
		| @@ -142,18 +142,17 @@ class RequestsResponseAdapter(Response): | ||||
|         except urllib3.exceptions.SSLError as e: | ||||
|             raise SSLError(cause=e) from e | ||||
| 
 | ||||
|         except urllib3.exceptions.IncompleteRead as e: | ||||
|             # urllib3 IncompleteRead.partial is always an integer | ||||
|             raise IncompleteRead(partial=e.partial, expected=e.expected) from e | ||||
| 
 | ||||
|         except urllib3.exceptions.ProtocolError as e: | ||||
|             # http.client.IncompleteRead may be contained within ProtocolError | ||||
|             # IncompleteRead is always contained within ProtocolError | ||||
|             # See urllib3.response.HTTPResponse._error_catcher() | ||||
|             ir_err = next( | ||||
|                 (err for err in (e.__context__, e.__cause__, *variadic(e.args)) | ||||
|                  if isinstance(err, http.client.IncompleteRead)), None) | ||||
|             if ir_err is not None: | ||||
|                 raise IncompleteRead(partial=len(ir_err.partial), expected=ir_err.expected) from e | ||||
|                 # `urllib3.exceptions.IncompleteRead` is subclass of `http.client.IncompleteRead` | ||||
|                 # but uses an `int` for its `partial` property. | ||||
|                 partial = ir_err.partial if isinstance(ir_err.partial, int) else len(ir_err.partial) | ||||
|                 raise IncompleteRead(partial=partial, expected=ir_err.expected) from e | ||||
|             raise TransportError(cause=e) from e | ||||
| 
 | ||||
|         except urllib3.exceptions.HTTPError as e: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Simon Sawicki
					Simon Sawicki