File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ The released versions correspond to PyPI releases.
1111 compatible, we cannot exclude that we missed some problems.
1212* Under macOS, at test start a symlink `/tmp` to the actual temporary directory is
1313 now created in the fake filesystem.
14+ * Patching of parsers for pandas >= 1.2 is removed since pandas now uses Python fs functions
15+ internally even when the engine selected is "c".
1416
1517### Features
1618* added possibility to set a path inaccessible under Windows by using `chown()` with
Original file line number Diff line number Diff line change 1717import sys
1818
1919try :
20+ import pandas as pd
2021 import pandas .io .parsers as parsers
2122except ImportError :
2223 parsers = None
3132except ImportError :
3233 locks = None
3334
35+ # From pandas v 1.2 onwards the python fs functions are used even when the engine
36+ # selected is "c". This means that we don't explicitly have to change the engine.
37+ patch_pandas = parsers is not None and [int (v ) for v in pd .__version__ .split ("." )] < [
38+ 1 ,
39+ 2 ,
40+ 0 ,
41+ ]
42+
3443
3544def get_modules_to_patch ():
3645 modules_to_patch = {}
@@ -43,14 +52,14 @@ def get_modules_to_patch():
4352
4453def get_classes_to_patch ():
4554 classes_to_patch = {}
46- if parsers is not None :
55+ if patch_pandas :
4756 classes_to_patch ["TextFileReader" ] = "pandas.io.parsers"
4857 return classes_to_patch
4958
5059
5160def get_fake_module_classes ():
5261 fake_module_classes = {}
53- if parsers is not None :
62+ if patch_pandas :
5463 fake_module_classes ["TextFileReader" ] = FakeTextFileReader
5564 return fake_module_classes
5665
@@ -94,7 +103,7 @@ def __getattr__(self, name):
94103 return getattr (self ._xlrd_module , name )
95104
96105
97- if parsers is not None :
106+ if patch_pandas :
98107 # we currently need to add fake modules for both the parser module and
99108 # the contained text reader - maybe this can be simplified
100109
You can’t perform that action at this time.
0 commit comments