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- 
31- 
3223@functools .cache  
3324def  _is_case_sensitive (parser ):
3425    return  parser .normcase ('Aa' ) ==  'Aa' 
@@ -353,8 +344,8 @@ class PathBase(PurePathBase):
353344
354345    This class provides dummy implementations for many methods that derived 
355346    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 
347+     NotImplementedError . The most basic methods, such as stat() and open(), 
348+     directly raise NotImplementedError ; these basic methods are called by 
358349    other methods such as is_dir() and read_text(). 
359350
360351    The Path class derives this class to implement local filesystem paths. 
@@ -363,16 +354,12 @@ class PathBase(PurePathBase):
363354    """ 
364355    __slots__  =  ()
365356
366-     @classmethod  
367-     def  _unsupported_msg (cls , attribute ):
368-         return  f"{ cls .__name__ } { attribute }  
369- 
370357    def  stat (self , * , follow_symlinks = True ):
371358        """ 
372359        Return the result of the stat() system call on this path, like 
373360        os.stat() does. 
374361        """ 
375-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'stat()' )) 
362+         raise  NotImplementedError 
376363
377364    # Convenience functions for querying the stat results 
378365
@@ -448,7 +435,7 @@ def open(self, mode='r', buffering=-1, encoding=None,
448435        Open the file pointed to by this path and return a file object, as 
449436        the built-in open() function does. 
450437        """ 
451-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'open()' )) 
438+         raise  NotImplementedError 
452439
453440    def  read_bytes (self ):
454441        """ 
@@ -498,7 +485,7 @@ def iterdir(self):
498485        The children are yielded in arbitrary order, and the 
499486        special entries '.' and '..' are not included. 
500487        """ 
501-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'iterdir()' )) 
488+         raise  NotImplementedError 
502489
503490    def  _glob_selector (self , parts , case_sensitive , recurse_symlinks ):
504491        if  case_sensitive  is  None :
@@ -575,14 +562,14 @@ def readlink(self):
575562        """ 
576563        Return the path to which the symbolic link points. 
577564        """ 
578-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'readlink()' )) 
565+         raise  NotImplementedError 
579566
580567    def  symlink_to (self , target , target_is_directory = False ):
581568        """ 
582569        Make this path a symlink pointing to the target path. 
583570        Note the order of arguments (link, target) is the reverse of os.symlink. 
584571        """ 
585-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'symlink_to()' )) 
572+         raise  NotImplementedError 
586573
587574    def  _symlink_to_target_of (self , link ):
588575        """ 
@@ -595,7 +582,7 @@ def mkdir(self, mode=0o777, parents=False, exist_ok=False):
595582        """ 
596583        Create a new directory at this given path. 
597584        """ 
598-         raise  UnsupportedOperation ( self . _unsupported_msg ( 'mkdir()' )) 
585+         raise  NotImplementedError 
599586
600587    # Metadata keys supported by this path type. 
601588    _readable_metadata  =  _writable_metadata  =  frozenset ()
@@ -604,13 +591,13 @@ def _read_metadata(self, keys=None, *, follow_symlinks=True):
604591        """ 
605592        Returns path metadata as a dict with string keys. 
606593        """ 
607-         raise  UnsupportedOperation ( self . _unsupported_msg ( '_read_metadata()' )) 
594+         raise  NotImplementedError 
608595
609596    def  _write_metadata (self , metadata , * , follow_symlinks = True ):
610597        """ 
611598        Sets path metadata from the given dict with string keys. 
612599        """ 
613-         raise  UnsupportedOperation ( self . _unsupported_msg ( '_write_metadata()' )) 
600+         raise  NotImplementedError 
614601
615602    def  _copy_metadata (self , target , * , follow_symlinks = True ):
616603        """ 
@@ -687,7 +674,7 @@ def _delete(self):
687674        """ 
688675        Delete this file or directory (including all sub-directories). 
689676        """ 
690-         raise  UnsupportedOperation ( self . _unsupported_msg ( '_delete()' )) 
677+         raise  NotImplementedError 
691678
692679    def  move (self , target ):
693680        """ 
0 commit comments