Raise OSError(EINVAL) if both paths refer to the same file.
(source, target)
| 231 | |
| 232 | |
| 233 | def ensure_different_files(source, target): |
| 234 | """ |
| 235 | Raise OSError(EINVAL) if both paths refer to the same file. |
| 236 | """ |
| 237 | try: |
| 238 | source_file_id = source.info._file_id |
| 239 | target_file_id = target.info._file_id |
| 240 | except AttributeError: |
| 241 | if source != target: |
| 242 | return |
| 243 | else: |
| 244 | try: |
| 245 | if source_file_id() != target_file_id(): |
| 246 | return |
| 247 | except (OSError, ValueError): |
| 248 | return |
| 249 | err = OSError(EINVAL, "Source and target are the same file") |
| 250 | err.filename = str(source) |
| 251 | err.filename2 = str(target) |
| 252 | raise err |
| 253 | |
| 254 | |
| 255 | def copy_info(info, target, follow_symlinks=True): |
no test coverage detected