Raise OSError(EINVAL) if both paths refer to the same file.
(source, target)
| 282 | |
| 283 | |
| 284 | def ensure_different_files(source, target): |
| 285 | """ |
| 286 | Raise OSError(EINVAL) if both paths refer to the same file. |
| 287 | """ |
| 288 | try: |
| 289 | source_file_id = source.info._file_id |
| 290 | target_file_id = target.info._file_id |
| 291 | except AttributeError: |
| 292 | if source != target: |
| 293 | return |
| 294 | else: |
| 295 | try: |
| 296 | if source_file_id() != target_file_id(): |
| 297 | return |
| 298 | except (OSError, ValueError): |
| 299 | return |
| 300 | err = OSError(EINVAL, "Source and target are the same file") |
| 301 | err.filename = vfspath(source) |
| 302 | err.filename2 = vfspath(target) |
| 303 | raise err |
no test coverage detected
searching dependent graphs…