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
09f3d080
Kaydet (Commit)
09f3d080
authored
Eki 04, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28350: String constants with null character no longer interned.
üst
b47c9d29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
test_code.py
Lib/test/test_code.py
+17
-3
NEWS
Misc/NEWS
+2
-0
codeobject.c
Objects/codeobject.c
+8
-8
No files found.
Lib/test/test_code.py
Dosyayı görüntüle @
09f3d080
...
...
@@ -135,19 +135,27 @@ class CodeTest(unittest.TestCase):
self
.
assertEqual
(
co
.
co_name
,
"funcname"
)
self
.
assertEqual
(
co
.
co_firstlineno
,
15
)
def
isinterned
(
s
):
return
s
is
sys
.
intern
((
'_'
+
s
+
'_'
)[
1
:
-
1
])
class
CodeConstsTest
(
unittest
.
TestCase
):
def
find_const
(
self
,
consts
,
value
):
for
v
in
consts
:
if
v
==
value
:
return
v
self
.
assertIn
(
value
,
consts
)
# rises an exception
self
.
fail
(
'Should
be never
reached'
)
self
.
assertIn
(
value
,
consts
)
# r
a
ises an exception
self
.
fail
(
'Should
never be
reached'
)
def
assertIsInterned
(
self
,
s
):
if
s
is
not
sys
.
intern
(
s
):
if
not
isinterned
(
s
):
self
.
fail
(
'String
%
r is not interned'
%
(
s
,))
def
assertIsNotInterned
(
self
,
s
):
if
isinterned
(
s
):
self
.
fail
(
'String
%
r is interned'
%
(
s
,))
@cpython_only
def
test_interned_string
(
self
):
co
=
compile
(
'res = "str_value"'
,
'?'
,
'exec'
)
...
...
@@ -172,6 +180,12 @@ class CodeConstsTest(unittest.TestCase):
return
a
self
.
assertIsInterned
(
f
())
@cpython_only
def
test_interned_string_with_null
(
self
):
co
=
compile
(
r'res = "str\0value!"'
,
'?'
,
'exec'
)
v
=
self
.
find_const
(
co
.
co_consts
,
'str
\0
value!'
)
self
.
assertIsNotInterned
(
v
)
class
CodeWeakRefTest
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
09f3d080
...
...
@@ -10,6 +10,8 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #28350: String constants with null character no longer interned.
- Issue #27942: String constants now interned recursively in tuples and frozensets.
- Issue #21578: Fixed misleading error message when ImportError called with
...
...
Objects/codeobject.c
Dosyayı görüntüle @
09f3d080
...
...
@@ -11,21 +11,21 @@ static int
all_name_chars
(
PyObject
*
o
)
{
static
char
ok_name_char
[
256
];
static
unsigned
char
*
name_chars
=
(
unsigned
char
*
)
NAME_CHARS
;
PyUnicodeObject
*
u
=
(
PyUnicodeObject
*
)
o
;
const
unsigned
char
*
s
;
static
const
unsigned
char
*
name_chars
=
(
unsigned
char
*
)
NAME_CHARS
;
const
unsigned
char
*
s
,
*
e
;
if
(
!
PyUnicode_Check
(
o
)
||
PyUnicode_READY
(
u
)
==
-
1
||
PyUnicode_MAX_CHAR_VALUE
(
u
)
>=
128
)
if
(
!
PyUnicode_Check
(
o
)
||
PyUnicode_READY
(
o
)
==
-
1
||
!
PyUnicode_IS_ASCII
(
o
)
)
return
0
;
if
(
ok_name_char
[
*
name_chars
]
==
0
)
{
unsigned
char
*
p
;
const
unsigned
char
*
p
;
for
(
p
=
name_chars
;
*
p
;
p
++
)
ok_name_char
[
*
p
]
=
1
;
}
s
=
PyUnicode_1BYTE_DATA
(
u
);
while
(
*
s
)
{
s
=
PyUnicode_1BYTE_DATA
(
o
);
e
=
s
+
PyUnicode_GET_LENGTH
(
o
);
while
(
s
!=
e
)
{
if
(
ok_name_char
[
*
s
++
]
==
0
)
return
0
;
}
...
...
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