Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
958b3e40
Kaydet (Commit)
958b3e40
authored
Haz 04, 2016
tarafından
Ethan Furman
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
issue27186: add PathLike ABC
üst
8bc9378c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
os.py
Lib/os.py
+16
-1
test_os.py
Lib/test/test_os.py
+2
-0
No files found.
Lib/os.py
Dosyayı görüntüle @
958b3e40
...
@@ -22,7 +22,7 @@ and opendir), and leave all pathname manipulation to os.path
...
@@ -22,7 +22,7 @@ and opendir), and leave all pathname manipulation to os.path
"""
"""
#'
#'
import
abc
import
sys
,
errno
import
sys
,
errno
import
stat
as
st
import
stat
as
st
...
@@ -1125,3 +1125,18 @@ if not _exists('fspath'):
...
@@ -1125,3 +1125,18 @@ if not _exists('fspath'):
raise
TypeError
(
"expected str, bytes or os.PathLike object, not "
raise
TypeError
(
"expected str, bytes or os.PathLike object, not "
+
path_type
.
__name__
)
+
path_type
.
__name__
)
class
PathLike
(
abc
.
ABC
):
"""
Abstract base class for implementing the file system path protocol.
"""
@abc.abstractmethod
def
__fspath__
(
self
):
"""
Return the file system path representation of the object.
"""
raise
NotImplementedError
@classmethod
def
__subclasshook__
(
cls
,
subclass
):
return
hasattr
(
subclass
,
'__fspath__'
)
Lib/test/test_os.py
Dosyayı görüntüle @
958b3e40
...
@@ -3127,6 +3127,8 @@ class TestPEP519(unittest.TestCase):
...
@@ -3127,6 +3127,8 @@ class TestPEP519(unittest.TestCase):
return
'#feelthegil'
return
'#feelthegil'
self
.
assertEqual
(
'#feelthegil'
,
os
.
fspath
(
PathLike
()))
self
.
assertEqual
(
'#feelthegil'
,
os
.
fspath
(
PathLike
()))
self
.
assertTrue
(
issubclass
(
PathLike
,
os
.
PathLike
))
self
.
assertTrue
(
isinstance
(
PathLike
(),
os
.
PathLike
))
def
test_garbage_in_exception_out
(
self
):
def
test_garbage_in_exception_out
(
self
):
vapor
=
type
(
'blah'
,
(),
{})
vapor
=
type
(
'blah'
,
(),
{})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment