2020from pathlib ._os import copyfileobj
2121
2222
23- __all__ = ["UnsupportedOperation" ]
24-
25-
26- class UnsupportedOperation (NotImplementedError ):
27- """An exception that is raised when an unsupported operation is attempted.
28- """
29- pass
30-
3123
3224@functools .cache
3325def _is_case_sensitive (parser ):
@@ -353,8 +345,8 @@ class PathBase(PurePathBase):
353345
354346 This class provides dummy implementations for many methods that derived
355347 classes can override selectively; the default implementations raise
356- UnsupportedOperation . The most basic methods, such as stat() and open(),
357- directly raise UnsupportedOperation ; these basic methods are called by
348+ NotImplementedError . The most basic methods, such as stat() and open(),
349+ directly raise NotImplementedError ; these basic methods are called by
358350 other methods such as is_dir() and read_text().
359351
360352 The Path class derives this class to implement local filesystem paths.
@@ -363,16 +355,12 @@ class PathBase(PurePathBase):
363355 """
364356 __slots__ = ()
365357
366- @classmethod
367- def _unsupported_msg (cls , attribute ):
368- return f"{ cls .__name__ } .{ attribute } is unsupported"
369-
370358 def stat (self , * , follow_symlinks = True ):
371359 """
372360 Return the result of the stat() system call on this path, like
373361 os.stat() does.
374362 """
375- raise UnsupportedOperation ( self . _unsupported_msg ( 'stat()' ))
363+ raise NotImplementedError
376364
377365 # Convenience functions for querying the stat results
378366
@@ -448,7 +436,7 @@ def open(self, mode='r', buffering=-1, encoding=None,
448436 Open the file pointed to by this path and return a file object, as
449437 the built-in open() function does.
450438 """
451- raise UnsupportedOperation ( self . _unsupported_msg ( 'open()' ))
439+ raise NotImplementedError
452440
453441 def read_bytes (self ):
454442 """
@@ -498,7 +486,7 @@ def iterdir(self):
498486 The children are yielded in arbitrary order, and the
499487 special entries '.' and '..' are not included.
500488 """
501- raise UnsupportedOperation ( self . _unsupported_msg ( 'iterdir()' ))
489+ raise NotImplementedError
502490
503491 def _glob_selector (self , parts , case_sensitive , recurse_symlinks ):
504492 if case_sensitive is None :
@@ -575,14 +563,14 @@ def readlink(self):
575563 """
576564 Return the path to which the symbolic link points.
577565 """
578- raise UnsupportedOperation ( self . _unsupported_msg ( 'readlink()' ))
566+ raise NotImplementedError
579567
580568 def symlink_to (self , target , target_is_directory = False ):
581569 """
582570 Make this path a symlink pointing to the target path.
583571 Note the order of arguments (link, target) is the reverse of os.symlink.
584572 """
585- raise UnsupportedOperation ( self . _unsupported_msg ( 'symlink_to()' ))
573+ raise NotImplementedError
586574
587575 def _symlink_to_target_of (self , link ):
588576 """
@@ -595,7 +583,7 @@ def mkdir(self, mode=0o777, parents=False, exist_ok=False):
595583 """
596584 Create a new directory at this given path.
597585 """
598- raise UnsupportedOperation ( self . _unsupported_msg ( 'mkdir()' ))
586+ raise NotImplementedError
599587
600588 # Metadata keys supported by this path type.
601589 _readable_metadata = _writable_metadata = frozenset ()
@@ -604,13 +592,13 @@ def _read_metadata(self, keys=None, *, follow_symlinks=True):
604592 """
605593 Returns path metadata as a dict with string keys.
606594 """
607- raise UnsupportedOperation ( self . _unsupported_msg ( '_read_metadata()' ))
595+ raise NotImplementedError
608596
609597 def _write_metadata (self , metadata , * , follow_symlinks = True ):
610598 """
611599 Sets path metadata from the given dict with string keys.
612600 """
613- raise UnsupportedOperation ( self . _unsupported_msg ( '_write_metadata()' ))
601+ raise NotImplementedError
614602
615603 def _copy_metadata (self , target , * , follow_symlinks = True ):
616604 """
@@ -687,7 +675,7 @@ def _delete(self):
687675 """
688676 Delete this file or directory (including all sub-directories).
689677 """
690- raise UnsupportedOperation ( self . _unsupported_msg ( '_delete()' ))
678+ raise NotImplementedError
691679
692680 def move (self , target ):
693681 """
0 commit comments