codecov[bot]: # [Codecov](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=h1) Report
> Merging [#817](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=desc) into [master](https://codecov.io/gh/joblib/joblib/commit/7be116a5a6bd4b304c1b0be66bc44fc84cfb0267?src=pr&el=desc) will **increase** coverage by `0.04%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/joblib/joblib/pull/817/graphs/tree.svg?width=650&token=gA6LF5DGTW&height=150&src=pr)](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master    #817      +/-   ##
=========================================
+ Coverage   95.35%   95.4%   +0.04%     
=========================================
  Files          44      44              
  Lines        6307    6328      +21     
=========================================
+ Hits         6014    6037      +23     
+ Misses        293     291       -2
```


| [Impacted Files](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [joblib/test/test\_memory.py](https://codecov.io/gh/joblib/joblib/pull/817/diff?src=pr&el=tree#diff-am9ibGliL3Rlc3QvdGVzdF9tZW1vcnkucHk=) | `98.15% <100%> (+0.04%)` | :arrow_up: |
| [joblib/memory.py](https://codecov.io/gh/joblib/joblib/pull/817/diff?src=pr&el=tree#diff-am9ibGliL21lbW9yeS5weQ==) | `95.69% <100%> (+0.08%)` | :arrow_up: |
| [joblib/test/test\_store\_backends.py](https://codecov.io/gh/joblib/joblib/pull/817/diff?src=pr&el=tree#diff-am9ibGliL3Rlc3QvdGVzdF9zdG9yZV9iYWNrZW5kcy5weQ==) | `91.17% <0%> (-5.89%)` | :arrow_down: |
| [joblib/\_parallel\_backends.py](https://codecov.io/gh/joblib/joblib/pull/817/diff?src=pr&el=tree#diff-am9ibGliL19wYXJhbGxlbF9iYWNrZW5kcy5weQ==) | `97.2% <0%> (+1.2%)` | :arrow_up: |
| [joblib/logger.py](https://codecov.io/gh/joblib/joblib/pull/817/diff?src=pr&el=tree#diff-am9ibGliL2xvZ2dlci5weQ==) | `88.15% <0%> (+1.31%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=footer). Last update [7be116a...104ddab](https://codecov.io/gh/joblib/joblib/pull/817?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/CHANGES.rst b/CHANGES.rst
index 4095118..63054fd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,15 @@
 Latest changes
 ===============
 
+Release 0.13.1
+--------------
+
+Pierre Glaser
+
+   Memory now accepts pathlib.Path objects as ``location`` parameter.
+   Also, a warning is raised if the returned backend is None while
+   ``location`` is not None.
+
 Release 0.13.0
 --------------
 
diff --git a/joblib/memory.py b/joblib/memory.py
index f744aaa..a1c4ff6 100644
--- a/joblib/memory.py
+++ b/joblib/memory.py
@@ -18,6 +18,7 @@ import functools
 import traceback
 import warnings
 import inspect
+import sys
 import weakref
 
 # Local imports
@@ -30,6 +31,9 @@ from .logger import Logger, format_time, pformat
 from ._compat import _basestring, PY3_OR_LATER
 from ._store_backends import StoreBackendBase, FileSystemStoreBackend
 
+if sys.version_info[:2] >= (3, 4):
+    import pathlib
+
 
 FIRST_LINE_TEXT = "# first line:"
 
@@ -101,6 +105,9 @@ def _store_backend_factory(backend, location, verbose=0, backend_options=None):
     if backend_options is None:
         backend_options = {}
 
+    if (sys.version_info[:2] >= (3, 4) and isinstance(location, pathlib.Path)):
+        location = str(location)
+
     if isinstance(location, StoreBackendBase):
         return location
     elif isinstance(location, _basestring):
@@ -124,6 +131,12 @@ def _store_backend_factory(backend, location, verbose=0, backend_options=None):
         obj.configure(location, verbose=verbose,
                       backend_options=backend_options)
         return obj
+    elif location is not None:
+        warnings.warn(
+            "Instanciating a backend using a {} as a location is not "
+            "supported by joblib. Returning None instead.".format(
+                location.__class__.__name__), UserWarning)
+
 
     return None
 

Silent failure if Path("...") is passed - BUG
The following code shows a silent failure when a Path is passed.

```
from pathlib import Path
from joblib import Memory

m1 = Memory(Path('../joblib-cache'), verbose=True)
m2 = Memory('../joblib-cache', verbose=True)

@m1.cache
def foo1(x):
    return x

@m2.cache
def foo2(x):
    return x

foo1(3)
foo2(3)
```

Printing only the verbose joblib output for foo2, and not caching foo1.

`python --version == 3.7 ; joblib.__version__ == 0.13.0`

May have time to produce a pull request tomorrow.
diff --git a/joblib/test/test_memory.py b/joblib/test/test_memory.py
index 65f96dc..fb83725 100644
--- a/joblib/test/test_memory.py
+++ b/joblib/test/test_memory.py
@@ -31,6 +31,9 @@ from joblib.testing import parametrize, raises, warns
 from joblib._compat import PY3_OR_LATER
 from joblib.hashing import hash
 
+if sys.version_info[:2] >= (3, 4):
+    import pathlib
+
 
 ###############################################################################
 # Module-level variables for the tests
@@ -1043,6 +1046,20 @@ def test_memory_default_store_backend():
     excinfo.match(r"Unknown location*")
 
 
+def test_warning_on_unknown_location_type():
+    class NonSupportedLocationClass:
+        pass
+    unsupported_location = NonSupportedLocationClass()
+
+    with warns(UserWarning) as warninfo:
+        _store_backend_factory("local", location=unsupported_location)
+
+    expected_mesage = ("Instanciating a backend using a "
+                       "NonSupportedLocationClass as a location is not "
+                       "supported by joblib")
+    assert expected_mesage in str(warninfo[0].message)
+
+
 def test_instanciate_incomplete_store_backend():
     # Verify that registering an external incomplete store backend raises an
     # exception when one tries to instanciate it.
@@ -1066,6 +1083,15 @@ def test_dummy_store_backend():
     assert isinstance(backend_obj, DummyStoreBackend)
 
 
+@pytest.mark.skipif(sys.version_info[:2] < (3, 4),
+                    reason="pathlib is available for python versions >= 3.4")
+def test_instanciate_store_backend_with_pathlib_path():
+    # Instanciate a FileSystemStoreBackend using a pathlib.Path object
+    path = pathlib.Path("some_folder")
+    backend_obj = _store_backend_factory("local", path)
+    assert backend_obj.location == "some_folder"
+
+
 def test_filesystem_store_backend_repr(tmpdir):
     # Verify string representation of a filesystem store backend.
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
numpy>=1.6.1 matplotlib pillow sphinx-gallery numpydoc pandas lz4 distributed pytest
apt-get update apt-get install -y gcc
3.6
continuous_integration/travis/requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
click==8.0.4
cloudpickle==2.2.1
contextvars==2.4
cycler==0.11.0
dask==2021.3.0
distributed==2021.3.0
docutils==0.18.1
HeapDict==1.0.1
idna==3.10
imagesize==1.4.1
immutables==0.19
importlib-metadata==4.8.3
iniconfig==1.1.1
Jinja2==3.0.3
-e git+https://github.com/joblib/joblib.git@7be116a5a6bd4b304c1b0be66bc44fc84cfb0267#egg=joblib
kiwisolver==1.3.1
lz4==3.1.10
MarkupSafe==2.0.1
matplotlib==3.3.4
msgpack==1.0.5
numpy==1.19.5
numpydoc==1.1.0
packaging==21.3
pandas==1.1.5
Pillow==8.4.0
pluggy==1.0.0
psutil==7.0.0
py==1.11.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
requests==2.27.1
six==1.17.0
snowballstemmer==2.2.0
sortedcontainers==2.4.0
Sphinx==5.3.0
sphinx-gallery==0.10.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tblib==1.7.0
tomli==1.2.3
toolz==0.12.0
tornado==6.1
typing_extensions==4.1.1
urllib3==1.26.20
zict==2.1.0
zipp==3.6.0

name: joblib
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - click==8.0.4
      - cloudpickle==2.2.1
      - contextvars==2.4
      - cycler==0.11.0
      - dask==2021.3.0
      - distributed==2021.3.0
      - docutils==0.18.1
      - heapdict==1.0.1
      - idna==3.10
      - imagesize==1.4.1
      - immutables==0.19
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jinja2==3.0.3
      - kiwisolver==1.3.1
      - lz4==3.1.10
      - markupsafe==2.0.1
      - matplotlib==3.3.4
      - msgpack==1.0.5
      - numpy==1.19.5
      - numpydoc==1.1.0
      - packaging==21.3
      - pandas==1.1.5
      - pillow==8.4.0
      - pluggy==1.0.0
      - psutil==7.0.0
      - py==1.11.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sortedcontainers==2.4.0
      - sphinx==5.3.0
      - sphinx-gallery==0.10.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tblib==1.7.0
      - tomli==1.2.3
      - toolz==0.12.0
      - tornado==6.1
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zict==2.1.0
      - zipp==3.6.0
prefix: /opt/conda/envs/joblib

joblib/test/test_memory.py::test_warning_on_unknown_location_type joblib/test/test_memory.py::test_instanciate_store_backend_with_pathlib_path
joblib/test/test_memory.py::test_memory_integration joblib/test/test_memory.py::test_no_memory joblib/test/test_memory.py::test_memory_kwarg joblib/test/test_memory.py::test_memory_lambda joblib/test/test_memory.py::test_memory_name_collision joblib/test/test_memory.py::test_memory_warning_lambda_collisions joblib/test/test_memory.py::test_memory_warning_collision_detection joblib/test/test_memory.py::test_memory_partial joblib/test/test_memory.py::test_memory_eval joblib/test/test_memory.py::test_argument_change joblib/test/test_memory.py::test_memory_numpy[None] joblib/test/test_memory.py::test_memory_numpy[r] joblib/test/test_memory.py::test_memory_numpy_check_mmap_mode joblib/test/test_memory.py::test_memory_exception joblib/test/test_memory.py::test_memory_ignore joblib/test/test_memory.py::test_memory_args_as_kwargs joblib/test/test_memory.py::test_partial_decoration[ignore0-100-r] joblib/test/test_memory.py::test_partial_decoration[ignore1-10-None] joblib/test/test_memory.py::test_func_dir joblib/test/test_memory.py::test_persistence joblib/test/test_memory.py::test_call_and_shelve joblib/test/test_memory.py::test_call_and_shelve_argument_hash joblib/test/test_memory.py::test_call_and_shelve_lazily_load_stored_result joblib/test/test_memory.py::test_memorized_pickling joblib/test/test_memory.py::test_memorized_repr joblib/test/test_memory.py::test_memory_file_modification joblib/test/test_memory.py::test_memory_in_memory_function_code_change joblib/test/test_memory.py::test_clear_memory_with_none_location joblib/test/test_memory.py::test_memory_func_with_kwonly_args joblib/test/test_memory.py::test_memory_func_with_signature joblib/test/test_memory.py::test__get_items joblib/test/test_memory.py::test__get_items_to_delete joblib/test/test_memory.py::test_memory_reduce_size joblib/test/test_memory.py::test_memory_clear joblib/test/test_memory.py::test_cached_function_race_condition_when_persisting_output joblib/test/test_memory.py::test_cached_function_race_condition_when_persisting_output_2 joblib/test/test_memory.py::test_memory_recomputes_after_an_error_while_loading_results joblib/test/test_memory.py::test_deprecated_cachedir_behaviour joblib/test/test_memory.py::test_register_invalid_store_backends_key[None] joblib/test/test_memory.py::test_register_invalid_store_backends_key[invalid_prefix1] joblib/test/test_memory.py::test_register_invalid_store_backends_key[invalid_prefix2] joblib/test/test_memory.py::test_register_invalid_store_backends_object joblib/test/test_memory.py::test_memory_default_store_backend joblib/test/test_memory.py::test_instanciate_incomplete_store_backend joblib/test/test_memory.py::test_dummy_store_backend joblib/test/test_memory.py::test_filesystem_store_backend_repr joblib/test/test_memory.py::test_memory_objects_repr joblib/test/test_memory.py::test_memorized_result_pickle joblib/test/test_memory.py::test_memory_pickle_dump_load[memory_kwargs0] joblib/test/test_memory.py::test_memory_pickle_dump_load[memory_kwargs1]
joblib/memory.py CHANGES.rst
joblib/memory.py CHANGES.rst