Commit 20f38687 authored by Jason R. Coombs's avatar Jason R. Coombs

Update docs to match implementation that resource names are rooted at the package. Ref #1635.

parent bfe286c3
Resource paths are passed to ``pkg_resources.resource_string`` and similar no longer accept paths that traverse parents. Violations of this expectation raise DeprecationWarnings and will become errors.
......@@ -1132,8 +1132,8 @@ relative to the root of the identified distribution; i.e. its first path
segment will be treated as a peer of the top-level modules or packages in the
distribution.
Note that resource names must be ``/``-separated paths and cannot be absolute
(i.e. no leading ``/``) or contain relative names like ``".."``. Do *not* use
Note that resource names must be ``/``-separated paths rooted at the package
and cannot contain relative names like ``".."``. Do *not* use
``os.path`` routines to manipulate resource paths, as they are *not* filesystem
paths.
......
......@@ -1489,8 +1489,7 @@ class NullProvider:
>>> warned.clear()
>>> vrp('/foo/bar.txt')
>>> bool(warned)
True
>>> warned.clear()
False
>>> vrp('foo/../../bar.txt')
>>> bool(warned)
True
......@@ -1499,14 +1498,11 @@ class NullProvider:
>>> bool(warned)
False
"""
invalid = (
path.startswith('/') or
re.search(r'\B\.\.\B', path)
)
invalid = '..' in path.split('/')
if not invalid:
return
msg = "Use of .. or leading / in a resource path is not allowed."
msg = "Use of .. in a resource path is not allowed."
# for compatibility, warn; in future
# raise ValueError(msg)
warnings.warn(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment