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
73363e81
Kaydet (Commit)
73363e81
authored
Tem 28, 2010
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #6213: Implement getstate() and setstate() methods of utf-8-sig and
utf-16 incremental encoders.
üst
3ff4463b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
utf_16.py
Lib/encodings/utf_16.py
+16
-0
utf_8_sig.py
Lib/encodings/utf_8_sig.py
+9
-3
test_io.py
Lib/test/test_io.py
+0
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/encodings/utf_16.py
Dosyayı görüntüle @
73363e81
...
...
@@ -34,6 +34,22 @@ class IncrementalEncoder(codecs.IncrementalEncoder):
codecs
.
IncrementalEncoder
.
reset
(
self
)
self
.
encoder
=
None
def
getstate
(
self
):
# state info we return to the caller:
# 0: stream is in natural order for this platform
# 2: endianness hasn't been determined yet
# (we're never writing in unnatural order)
return
(
2
if
self
.
encoder
is
None
else
0
)
def
setstate
(
self
,
state
):
if
state
:
self
.
encoder
=
None
else
:
if
sys
.
byteorder
==
'little'
:
self
.
encoder
=
codecs
.
utf_16_le_encode
else
:
self
.
encoder
=
codecs
.
utf_16_be_encode
class
IncrementalDecoder
(
codecs
.
BufferedIncrementalDecoder
):
def
__init__
(
self
,
errors
=
'strict'
):
codecs
.
BufferedIncrementalDecoder
.
__init__
(
self
,
errors
)
...
...
Lib/encodings/utf_8_sig.py
Dosyayı görüntüle @
73363e81
...
...
@@ -25,18 +25,24 @@ def decode(input, errors='strict'):
class
IncrementalEncoder
(
codecs
.
IncrementalEncoder
):
def
__init__
(
self
,
errors
=
'strict'
):
codecs
.
IncrementalEncoder
.
__init__
(
self
,
errors
)
self
.
first
=
True
self
.
first
=
1
def
encode
(
self
,
input
,
final
=
False
):
if
self
.
first
:
self
.
first
=
False
self
.
first
=
0
return
codecs
.
BOM_UTF8
+
codecs
.
utf_8_encode
(
input
,
self
.
errors
)[
0
]
else
:
return
codecs
.
utf_8_encode
(
input
,
self
.
errors
)[
0
]
def
reset
(
self
):
codecs
.
IncrementalEncoder
.
reset
(
self
)
self
.
first
=
True
self
.
first
=
1
def
getstate
(
self
):
return
self
.
first
def
setstate
(
self
,
state
):
self
.
first
=
state
class
IncrementalDecoder
(
codecs
.
BufferedIncrementalDecoder
):
def
__init__
(
self
,
errors
=
'strict'
):
...
...
Lib/test/test_io.py
Dosyayı görüntüle @
73363e81
...
...
@@ -2087,7 +2087,6 @@ class TextIOWrapperTest(unittest.TestCase):
self
.
assertEqual
(
buffer
.
seekable
(),
txt
.
seekable
())
@unittest.skip
(
"Issue #6213 with incremental encoders"
)
def
test_append_bom
(
self
):
# The BOM is not written again when appending to a non-empty file
filename
=
support
.
TESTFN
...
...
@@ -2103,7 +2102,6 @@ class TextIOWrapperTest(unittest.TestCase):
with
self
.
open
(
filename
,
'rb'
)
as
f
:
self
.
assertEquals
(
f
.
read
(),
'aaaxxx'
.
encode
(
charset
))
@unittest.skip
(
"Issue #6213 with incremental encoders"
)
def
test_seek_bom
(
self
):
# Same test, but when seeking manually
filename
=
support
.
TESTFN
...
...
Misc/NEWS
Dosyayı görüntüle @
73363e81
...
...
@@ -18,6 +18,9 @@ Core and Builtins
Library
-------
- Issue #6213: Implement getstate() and setstate() methods of utf-8-sig and
utf-16 incremental encoders.
- Issue #7113: Speed up loading in ConfigParser. Patch by Łukasz Langa.
- Issue #3704: cookielib was not properly handling URLs with a / in the
...
...
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