Issue39624
Created on 2020-02-13 08:53 by mathstuf, last changed 2020-02-17 13:51 by vstinner.
| Messages (8) | |||
|---|---|---|---|
| msg361949 - (view) | Author: Ben Boeckel (mathstuf) | Date: 2020-02-13 08:53 | |
Previously reported as a sidenote in Issue21016. The `--ignore-dir` option in trace.py replaces `$prefix` and `$exec_prefix` *anywhere* in the path when it really should just replace it in the start of the path and if it is followed by nothing or a path separator (that is, it is a path component). I suspect that there's always a separator though. |
|||
| msg361955 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-02-13 13:41 | |
str.replace() can be replaced with re.sub() and \b marker. Example: >>> re.sub(r'\$prefix\b', '[xxx]', '$prefix $prefixpath') '[xxx] $prefixpath' |
|||
| msg361958 - (view) | Author: Ben Boeckel (mathstuf) | Date: 2020-02-13 15:05 | |
`\b` is a bit too loose. That example should *not* have it replaced because it is not a full path component. (Granted, any of these conflicting paths are "dumb" in general; I'm fine with just leaving this as a low priority, but if it does get modified, it should actually get fixed.) |
|||
| msg361970 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-02-13 21:43 | |
Would you mind to add examples of patterns should be replaced and patterns which should not be replaced? |
|||
| msg362031 - (view) | Author: Ben Boeckel (mathstuf) | Date: 2020-02-15 21:23 | |
Should be replaced (using $prefix here, but equally viable for $exec_prefix). Each quoted line is a path using a raw string. r"$prefix" r"$prefix/foo" and on Windows: r"$prefix\bar" These should *not* be replaced: r"$prefixvar/subdir" r"not/a/$prefix" r"$prefix spacevar/subdir" because here, the `$prefix` is part of another path component. This does leave the directory literally named "$prefix" in a bit of a pickle. Like I said, it's niche, but if we're going to fix it, let's at least consider handling more cases properly. |
|||
| msg362131 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-02-17 09:43 | |
> These should *not* be replaced:
>
> r"not/a/$prefix"
> r"$prefix spacevar/subdir"
Honestly, I don't see an issue to replace $prefix in these examples.
These examples seem artificial. The paths are not user provided: they are hardcoded paths from the sysconfig module:
if opts.ignore_dir:
_prefix = sysconfig.get_path("stdlib")
_exec_prefix = sysconfig.get_path("platstdlib")
I'm not even sure if it's worth it to fix this issue, it's unclear to me how you could get r"$prefixvar/subdir" from sysconfig.get_path("stdlib").
|
|||
| msg362137 - (view) | Author: Ben Boeckel (mathstuf) | Date: 2020-02-17 11:31 | |
> The paths are not user provided: they are hardcoded paths from the sysconfig module: No, those paths are the *replacement* values, not the input. From the trace docs: > trace.py -c -f counts --ignore-dir '$prefix' spam.py eggs This is the string where `$prefix` is replaced with the value retrieved from `sysconfig`. |
|||
| msg362146 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2020-02-17 13:51 | |
Do you want to propose to write a PR to fix this issue? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2020-02-17 13:51:48 | vstinner | set | messages:
+ msg362146 versions: + Python 3.9 |
| 2020-02-17 11:31:44 | mathstuf | set | messages: + msg362137 |
| 2020-02-17 09:43:11 | vstinner | set | messages: + msg362131 |
| 2020-02-15 21:23:34 | mathstuf | set | messages: + msg362031 |
| 2020-02-13 21:43:38 | vstinner | set | messages: + msg361970 |
| 2020-02-13 15:05:11 | mathstuf | set | messages: + msg361958 |
| 2020-02-13 13:41:49 | vstinner | set | messages: + msg361955 |
| 2020-02-13 08:53:15 | mathstuf | create | |
