| 135 | return object.__new__(cls) |
| 136 | |
| 137 | def __init__(self, *args): |
| 138 | paths = [] |
| 139 | for arg in args: |
| 140 | if isinstance(arg, PurePath): |
| 141 | if arg.parser is not self.parser: |
| 142 | # GH-103631: Convert separators for backwards compatibility. |
| 143 | paths.append(arg.as_posix()) |
| 144 | else: |
| 145 | paths.extend(arg._raw_paths) |
| 146 | else: |
| 147 | try: |
| 148 | path = os.fspath(arg) |
| 149 | except TypeError: |
| 150 | path = arg |
| 151 | if not isinstance(path, str): |
| 152 | raise TypeError( |
| 153 | "argument should be a str or an os.PathLike " |
| 154 | "object where __fspath__ returns a str, " |
| 155 | f"not {type(path).__name__!r}") |
| 156 | paths.append(path) |
| 157 | self._raw_paths = paths |
| 158 | |
| 159 | def with_segments(self, *pathsegments): |
| 160 | """Construct a new path object from any number of path-like objects. |