From 7797e2775675260ace7b28eeef0154eb4d89fa08 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 7 Feb 2018 11:40:31 -0600 Subject: [PATCH 1/3] Ignore warnings when reading pickle files Silences a warning from our tests about ``` pandas/tests/io/test_common.py::TestCommonIOCapabilities::()::test_read_fspath_all[reader10-os-/home/travis/build/pandas-dev/pandas/pandas/tests/io/data/categorical_0_14_1.pickle] /home/travis/build/pandas-dev/pandas/pandas/io/pickle.py:99: FutureWarning: 'pandas.core' is private. Use 'pandas.Categorical' return read_wrapper(lambda f: pkl.load(f)) ``` --- pandas/io/pickle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/io/pickle.py b/pandas/io/pickle.py index fa953f7d876cc..fe0973f304552 100644 --- a/pandas/io/pickle.py +++ b/pandas/io/pickle.py @@ -1,4 +1,5 @@ """ pickle compat """ +import warnings import numpy as np from numpy.lib.format import read_array, write_array @@ -96,7 +97,8 @@ def try_read(path, encoding=None): # cpickle # GH 6899 try: - return read_wrapper(lambda f: pkl.load(f)) + with warnings.simplefilter('ignore'): + return read_wrapper(lambda f: pkl.load(f)) except Exception: # reg/patched pickle try: From cecbe2391bceb1ba2555c22fed37f9e26324e095 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 7 Feb 2018 20:33:36 -0600 Subject: [PATCH 2/3] Fix warning filter --- pandas/io/pickle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/pickle.py b/pandas/io/pickle.py index fe0973f304552..998d888368f94 100644 --- a/pandas/io/pickle.py +++ b/pandas/io/pickle.py @@ -97,7 +97,8 @@ def try_read(path, encoding=None): # cpickle # GH 6899 try: - with warnings.simplefilter('ignore'): + with warnings.catch_warnings(): + warnings.simplefilter('ignore') return read_wrapper(lambda f: pkl.load(f)) except Exception: # reg/patched pickle From b0b37ff3148113e244df928590a0361bc2c95984 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Thu, 8 Feb 2018 06:11:31 -0600 Subject: [PATCH 3/3] Simpler --- pandas/io/pickle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/pickle.py b/pandas/io/pickle.py index 998d888368f94..756096dd0c9ce 100644 --- a/pandas/io/pickle.py +++ b/pandas/io/pickle.py @@ -97,8 +97,8 @@ def try_read(path, encoding=None): # cpickle # GH 6899 try: - with warnings.catch_warnings(): - warnings.simplefilter('ignore') + with warnings.catch_warnings(record=True): + # We want to silencce any warnings about, e.g. moved modules. return read_wrapper(lambda f: pkl.load(f)) except Exception: # reg/patched pickle