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
bbbac2ec
Kaydet (Commit)
bbbac2ec
authored
Şub 07, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
üst
2efdc90b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
test_unicode.py
Lib/test/test_unicode.py
+15
-0
NEWS
Misc/NEWS
+3
-0
unicodeobject.c
Objects/unicodeobject.c
+4
-0
No files found.
Lib/test/test_unicode.py
Dosyayı görüntüle @
bbbac2ec
...
...
@@ -2167,6 +2167,21 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
args
[
0
],
text
)
self
.
assertEqual
(
len
(
args
),
1
)
def
test_resize
(
self
):
for
length
in
range
(
1
,
100
,
7
):
# generate a fresh string (refcount=1)
text
=
'a'
*
length
+
'b'
# fill wstr internal field
abc
=
text
.
encode
(
'unicode_internal'
)
self
.
assertEqual
(
abc
.
decode
(
'unicode_internal'
),
text
)
# resize text: wstr field must be cleared and then recomputed
text
+=
'c'
abcdef
=
text
.
encode
(
'unicode_internal'
)
self
.
assertNotEqual
(
abc
,
abcdef
)
self
.
assertEqual
(
abcdef
.
decode
(
'unicode_internal'
),
text
)
class
StringModuleTest
(
unittest
.
TestCase
):
def
test_formatter_parser
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
bbbac2ec
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
Core and Builtins
-----------------
- Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
- Issue #17043: The unicode-internal decoder no longer read past the end of
input buffer.
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
bbbac2ec
...
...
@@ -702,6 +702,10 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
if (!PyUnicode_IS_ASCII(unicode))
_PyUnicode_WSTR_LENGTH(unicode) = length;
}
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
}
PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode),
length, 0);
assert(_PyUnicode_CheckConsistency(unicode, 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