File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -272,13 +272,15 @@ def _infer_compression(filepath_or_buffer, compression):
272272 if compression is None :
273273 return None
274274
275- # Cannot infer compression of a buffer. Hence assume no compression.
276- is_path = isinstance (filepath_or_buffer , compat .string_types )
277- if compression == 'infer' and not is_path :
278- return None
279-
280- # Infer compression from the filename/URL extension
275+ # Infer compression
281276 if compression == 'infer' :
277+ # Convert all path types (e.g. pathlib.Path) to strings
278+ filepath_or_buffer = _stringify_path (filepath_or_buffer )
279+ if not isinstance (filepath_or_buffer , compat .string_types ):
280+ # Cannot infer compression of a buffer, assume no compression
281+ return None
282+
283+ # Infer compression from the filename/URL extension
282284 for compression , extension in _compression_to_extension .items ():
283285 if filepath_or_buffer .endswith (extension ):
284286 return compression
You can’t perform that action at this time.
0 commit comments