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
2a0c0814
Kaydet (Commit)
2a0c0814
authored
Haz 05, 2007
tarafından
Walter Dörwald
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change sys.intern() so that unicode strings can be
interned too. Add a test for this.
üst
360b01a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
test_sys.py
Lib/test/test_sys.py
+12
-1
sysmodule.c
Python/sysmodule.c
+13
-6
No files found.
Lib/test/test_sys.py
Dosyayı görüntüle @
2a0c0814
...
...
@@ -356,7 +356,7 @@ class SysModuleTest(unittest.TestCase):
# We don't want them in the interned dict and if they aren't
# actually interned, we don't want to create the appearance
# that they are by allowing intern() to succeeed.
class
S
(
str
):
class
S
(
str
8
):
def
__hash__
(
self
):
return
123
...
...
@@ -368,6 +368,17 @@ class SysModuleTest(unittest.TestCase):
setattr
(
s
,
s
,
s
)
self
.
assertEqual
(
getattr
(
s
,
s
),
s
)
s
=
"never interned as unicode before"
self
.
assert_
(
sys
.
intern
(
s
)
is
s
)
s2
=
s
.
swapcase
()
.
swapcase
()
self
.
assert_
(
sys
.
intern
(
s2
)
is
s
)
class
U
(
str
):
def
__hash__
(
self
):
return
123
self
.
assertRaises
(
TypeError
,
sys
.
intern
,
U
(
"abc"
))
def
test_main
():
test
.
test_support
.
run_unittest
(
SysModuleTest
)
...
...
Python/sysmodule.c
Dosyayı görüntüle @
2a0c0814
...
...
@@ -266,14 +266,21 @@ sys_intern(PyObject *self, PyObject *args)
PyObject
*
s
;
if
(
!
PyArg_ParseTuple
(
args
,
"S:intern"
,
&
s
))
return
NULL
;
if
(
!
PyString_CheckExact
(
s
))
{
PyErr_SetString
(
PyExc_TypeError
,
"can't intern subclass of string"
);
if
(
PyString_CheckExact
(
s
))
{
Py_INCREF
(
s
);
PyString_InternInPlace
(
&
s
);
return
s
;
}
else
if
(
PyUnicode_CheckExact
(
s
))
{
Py_INCREF
(
s
);
PyUnicode_InternInPlace
(
&
s
);
return
s
;
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"can't intern %.400s"
,
s
->
ob_type
->
tp_name
);
return
NULL
;
}
Py_INCREF
(
s
);
PyString_InternInPlace
(
&
s
);
return
s
;
}
PyDoc_STRVAR
(
intern_doc
,
...
...
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