interpreter: Revert old path joining behavior (fixes #9450)

pull/9460/head
Daniel Mensinger 3 years ago committed by Xavier Claessens
parent 89e9b50292
commit 0fea9965ad
  1. 3
      mesonbuild/interpreter/primitives/string.py
  2. 3
      test cases/common/111 pathjoin/meson.build

@ -2,6 +2,7 @@
# SPDX-license-identifier: Apache-2.0
import re
import os
from pathlib import PurePath
import typing as T
@ -159,7 +160,7 @@ class StringHolder(ObjectHolder[str]):
@FeatureNew('/ with string arguments', '0.49.0')
@typed_operator(MesonOperator.DIV, str)
def op_div(self, other: str) -> str:
return (PurePath(self.held_object) / other).as_posix()
return os.path.join(self.held_object, other).replace('\\', '/')
@typed_operator(MesonOperator.INDEX, int)
def op_index(self, other: int) -> str:

@ -7,6 +7,7 @@ assert(join_paths('foo', 'bar', 'baz') == 'foo/bar/baz', 'Path joining is broken
assert(join_paths('/foo', 'bar') == '/foo/bar', 'Path joining is broken')
assert(join_paths('foo', '/bar') == '/bar', 'Absolute path joining is broken')
assert(join_paths('/foo', '/bar') == '/bar', 'Absolute path joining is broken')
assert(join_paths('/foo', '') == '/foo/', 'Trailing / on path')
# Test array form since people are using that too
assert(join_paths(['foo']) == 'foo', 'Single argument join is broken')
@ -15,6 +16,7 @@ assert(join_paths(['foo', 'bar', 'baz']) == 'foo/bar/baz', 'Path joining is brok
assert(join_paths(['/foo', 'bar']) == '/foo/bar', 'Path joining is broken')
assert(join_paths(['foo', '/bar']) == '/bar', 'Absolute path joining is broken')
assert(join_paths(['/foo', '/bar']) == '/bar', 'Absolute path joining is broken')
assert(join_paths(['/foo', '']) == '/foo/', 'Trailing / on path')
# Division operator should do the same as join_paths
assert('foo' / 'bar' == 'foo/bar', 'Path division is broken')
@ -22,3 +24,4 @@ assert('foo' /'bar' /'baz' == 'foo/bar/baz', 'Path division is broken')
assert('/foo' / 'bar' == '/foo/bar', 'Path division is broken')
assert('foo' / '/bar' == '/bar', 'Absolute path division is broken')
assert('/foo' / '/bar' == '/bar', 'Absolute path division is broken')
assert('/foo' / '' == '/foo/', 'Trailing / on path')

Loading…
Cancel
Save