Commits

Antoine Pitrou committed aa7e335

Kill as_bytes()

  • Participants
  • Parent commits e9fbf45
  • Branches pep428

Comments (0)

Files changed (3)

File docs/index.rst

       'library'
 
 
-.. method:: PurePath.as_bytes()
-
-   Equivalent to calling ``bytes()`` on the path object::
-
-      >>> PurePosixPath('/etc').as_bytes()
-      b'/etc'
-
-
 .. method:: PurePath.as_posix()
 
    Return a string representation of the path with forward slashes (``/``)::
     def make_uri(self, path):
         # We represent the path using the local filesystem encoding,
         # for portability to other applications.
-        bpath = path.as_bytes()
+        bpath = bytes(path)
         return 'file://' + urlquote_from_bytes(bpath)
 
 
         f = self._flavour
         return str(self).replace(f.sep, '/')
 
-    def as_bytes(self):
+    def __bytes__(self):
         """Return the bytes representation of the path.  This is only
         recommended to use under Unix."""
         if sys.version_info < (3, 2):
             raise NotImplementedError("needs Python 3.2 or later")
         return os.fsencode(str(self))
 
-    __bytes__ = as_bytes
-
     def __repr__(self):
         return "{}({!r})".format(self.__class__.__name__, str(self))
 

File test_pathlib.py

     def test_as_bytes_common(self):
         sep = os.fsencode(self.sep)
         P = self.cls
-        self.assertEqual(P('a/b').as_bytes(), b'a' + sep + b'b')
         self.assertEqual(bytes(P('a/b')), b'a' + sep + b'b')
 
     @with_fsencode