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
e15dce3d
Kaydet (Commit)
e15dce3d
authored
May 30, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #12171: IncrementalEncoder.reset() of CJK codecs (multibytecodec) calls
encreset() instead of decreset().
üst
ebbb3b79
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
codecs.rst
Doc/library/codecs.rst
+2
-1
test_multibytecodec.py
Lib/test/test_multibytecodec.py
+7
-2
NEWS
Misc/NEWS
+3
-0
multibytecodec.c
Modules/cjkcodecs/multibytecodec.c
+9
-3
No files found.
Doc/library/codecs.rst
Dosyayı görüntüle @
e15dce3d
...
@@ -458,7 +458,8 @@ define in order to be compatible with the Python codec registry.
...
@@ -458,7 +458,8 @@ define in order to be compatible with the Python codec registry.
.. method:: reset()
.. method:: reset()
Reset the encoder to the initial state.
Reset the encoder to the initial state. The output is discarded: call
``.encode('', final=True)`` to reset the encoder and to get the output.
.. method:: IncrementalEncoder.getstate()
.. method:: IncrementalEncoder.getstate()
...
...
Lib/test/test_multibytecodec.py
Dosyayı görüntüle @
e15dce3d
...
@@ -260,7 +260,8 @@ class TestStateful(unittest.TestCase):
...
@@ -260,7 +260,8 @@ class TestStateful(unittest.TestCase):
text
=
'
\u4E16\u4E16
'
text
=
'
\u4E16\u4E16
'
encoding
=
'iso-2022-jp'
encoding
=
'iso-2022-jp'
expected
=
b
'
\x1b
$B@$@$'
expected
=
b
'
\x1b
$B@$@$'
expected_reset
=
b
'
\x1b
$B@$@$
\x1b
(B'
reset
=
b
'
\x1b
(B'
expected_reset
=
expected
+
reset
def
test_encode
(
self
):
def
test_encode
(
self
):
self
.
assertEqual
(
self
.
text
.
encode
(
self
.
encoding
),
self
.
expected_reset
)
self
.
assertEqual
(
self
.
text
.
encode
(
self
.
encoding
),
self
.
expected_reset
)
...
@@ -271,6 +272,8 @@ class TestStateful(unittest.TestCase):
...
@@ -271,6 +272,8 @@ class TestStateful(unittest.TestCase):
encoder
.
encode
(
char
)
encoder
.
encode
(
char
)
for
char
in
self
.
text
)
for
char
in
self
.
text
)
self
.
assertEqual
(
output
,
self
.
expected
)
self
.
assertEqual
(
output
,
self
.
expected
)
self
.
assertEqual
(
encoder
.
encode
(
''
,
final
=
True
),
self
.
reset
)
self
.
assertEqual
(
encoder
.
encode
(
''
,
final
=
True
),
b
''
)
def
test_incrementalencoder_final
(
self
):
def
test_incrementalencoder_final
(
self
):
encoder
=
codecs
.
getincrementalencoder
(
self
.
encoding
)()
encoder
=
codecs
.
getincrementalencoder
(
self
.
encoding
)()
...
@@ -279,12 +282,14 @@ class TestStateful(unittest.TestCase):
...
@@ -279,12 +282,14 @@ class TestStateful(unittest.TestCase):
encoder
.
encode
(
char
,
index
==
last_index
)
encoder
.
encode
(
char
,
index
==
last_index
)
for
index
,
char
in
enumerate
(
self
.
text
))
for
index
,
char
in
enumerate
(
self
.
text
))
self
.
assertEqual
(
output
,
self
.
expected_reset
)
self
.
assertEqual
(
output
,
self
.
expected_reset
)
self
.
assertEqual
(
encoder
.
encode
(
''
,
final
=
True
),
b
''
)
class
TestHZStateful
(
TestStateful
):
class
TestHZStateful
(
TestStateful
):
text
=
'
\u804a\u804a
'
text
=
'
\u804a\u804a
'
encoding
=
'hz'
encoding
=
'hz'
expected
=
b
'~{ADAD'
expected
=
b
'~{ADAD'
expected_reset
=
b
'~{ADAD~}'
reset
=
b
'~}'
expected_reset
=
expected
+
reset
def
test_main
():
def
test_main
():
support
.
run_unittest
(
__name__
)
support
.
run_unittest
(
__name__
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e15dce3d
...
@@ -177,6 +177,9 @@ Core and Builtins
...
@@ -177,6 +177,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #12171: IncrementalEncoder.reset() of CJK codecs (multibytecodec) calls
encreset() instead of decreset().
- Issue #12218: Removed wsgiref.egg-info.
- Issue #12218: Removed wsgiref.egg-info.
- Issue #12196: Add pipe2() to the os module.
- Issue #12196: Add pipe2() to the os module.
...
...
Modules/cjkcodecs/multibytecodec.c
Dosyayı görüntüle @
e15dce3d
...
@@ -901,11 +901,17 @@ mbiencoder_encode(MultibyteIncrementalEncoderObject *self,
...
@@ -901,11 +901,17 @@ mbiencoder_encode(MultibyteIncrementalEncoderObject *self,
static
PyObject
*
static
PyObject
*
mbiencoder_reset
(
MultibyteIncrementalEncoderObject
*
self
)
mbiencoder_reset
(
MultibyteIncrementalEncoderObject
*
self
)
{
{
if
(
self
->
codec
->
decreset
!=
NULL
&&
/* Longest output: 4 bytes (b'\x0F\x1F(B') with ISO 2022 */
self
->
codec
->
decreset
(
&
self
->
state
,
self
->
codec
->
config
)
!=
0
)
unsigned
char
buffer
[
4
],
*
outbuf
;
Py_ssize_t
r
;
if
(
self
->
codec
->
encreset
!=
NULL
)
{
outbuf
=
buffer
;
r
=
self
->
codec
->
encreset
(
&
self
->
state
,
self
->
codec
->
config
,
&
outbuf
,
sizeof
(
buffer
));
if
(
r
!=
0
)
return
NULL
;
return
NULL
;
}
self
->
pendingsize
=
0
;
self
->
pendingsize
=
0
;
Py_RETURN_NONE
;
Py_RETURN_NONE
;
}
}
...
...
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