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
d4eda825
Kaydet (Commit)
d4eda825
authored
Tem 21, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF patch# 1757839 by Alexandre Vassalotti -- make test_mailbox and
test_old_mailbox pass.
üst
bf4806ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
generator.py
Lib/email/generator.py
+8
-2
header.py
Lib/email/header.py
+2
-2
mailbox.py
Lib/mailbox.py
+6
-6
test_mailbox.py
Lib/test/test_mailbox.py
+1
-4
No files found.
Lib/email/generator.py
Dosyayı görüntüle @
d4eda825
...
...
@@ -21,14 +21,20 @@ NL = '\n'
fcre
=
re
.
compile
(
r'^From '
,
re
.
MULTILINE
)
def
_is8bitstring
(
s
):
if
isinstance
(
s
,
str
):
if
isinstance
(
s
,
bytes
):
try
:
str
(
s
,
'us-ascii'
)
return
True
except
UnicodeError
:
pass
elif
isinstance
(
s
,
str
):
try
:
s
.
decode
(
'us-ascii'
)
return
True
except
UnicodeError
:
pass
return
False
class
Generator
:
"""Generates output from a Message object tree.
...
...
Lib/email/header.py
Dosyayı görüntüle @
d4eda825
...
...
@@ -253,7 +253,7 @@ class Header:
# We need to test that the string can be converted to unicode and
# back to a byte string, given the input and output codecs of the
# charset.
if
isinstance
(
s
,
str
):
if
isinstance
(
s
,
bytes
):
# Possibly raise UnicodeError if the byte string can't be
# converted to a unicode with the input codec of the charset.
incodec
=
charset
.
input_codec
or
'us-ascii'
...
...
@@ -263,7 +263,7 @@ class Header:
# than the iput coded. Still, use the original byte string.
outcodec
=
charset
.
output_codec
or
'us-ascii'
ustr
.
encode
(
outcodec
,
errors
)
elif
isinstance
(
s
,
str
):
elif
isinstance
(
s
,
bytes
):
# Now we have to be sure the unicode string can be converted
# to a byte string with a reasonable output codec. We want to
# use the byte string in the chunk.
...
...
Lib/mailbox.py
Dosyayı görüntüle @
d4eda825
...
...
@@ -498,15 +498,15 @@ class _singlefileMailbox(Mailbox):
"""Initialize a single-file mailbox."""
Mailbox
.
__init__
(
self
,
path
,
factory
,
create
)
try
:
f
=
open
(
self
.
_path
,
'r
b
+'
)
f
=
open
(
self
.
_path
,
'r+'
)
except
IOError
as
e
:
if
e
.
errno
==
errno
.
ENOENT
:
if
create
:
f
=
open
(
self
.
_path
,
'w
b
+'
)
f
=
open
(
self
.
_path
,
'w+'
)
else
:
raise
NoSuchMailboxError
(
self
.
_path
)
elif
e
.
errno
==
errno
.
EACCES
:
f
=
open
(
self
.
_path
,
'r
b
'
)
f
=
open
(
self
.
_path
,
'r'
)
else
:
raise
self
.
_file
=
f
...
...
@@ -1761,11 +1761,11 @@ class _ProxyFile:
def
read
(
self
,
size
=
None
):
"""Read bytes."""
return
s
elf
.
_read
(
size
,
self
.
_file
.
read
)
return
s
tr
(
self
.
_read
(
size
,
self
.
_file
.
read
)
)
def
readline
(
self
,
size
=
None
):
"""Read a line."""
return
s
elf
.
_read
(
size
,
self
.
_file
.
readline
)
return
s
tr
(
self
.
_read
(
size
,
self
.
_file
.
readline
)
)
def
readlines
(
self
,
sizehint
=
None
):
"""Read multiple lines."""
...
...
@@ -1900,7 +1900,7 @@ def _create_carefully(path):
"""Create a file if it doesn't exist and open for reading and writing."""
fd
=
os
.
open
(
path
,
os
.
O_CREAT
|
os
.
O_EXCL
|
os
.
O_RDWR
)
try
:
return
open
(
path
,
'r
b
+'
)
return
open
(
path
,
'r+'
)
finally
:
os
.
close
(
fd
)
...
...
Lib/test/test_mailbox.py
Dosyayı görüntüle @
d4eda825
...
...
@@ -58,7 +58,6 @@ class TestMailbox(TestBase):
self
.
_box
=
self
.
_factory
(
self
.
_path
)
def
tearDown
(
self
):
self
.
_box
.
close
()
self
.
_delete_recursively
(
self
.
_path
)
def
test_add
(
self
):
...
...
@@ -695,7 +694,6 @@ class TestMaildir(TestMailbox):
class
_TestMboxMMDF
(
TestMailbox
):
def
tearDown
(
self
):
self
.
_box
.
close
()
self
.
_delete_recursively
(
self
.
_path
)
for
lock_remnant
in
glob
.
glob
(
self
.
_path
+
'.*'
):
test_support
.
unlink
(
lock_remnant
)
...
...
@@ -736,7 +734,7 @@ class _TestMboxMMDF(TestMailbox):
self
.
_box
.
_file
.
seek
(
0
)
contents
=
self
.
_box
.
_file
.
read
()
self
.
_box
.
close
()
self
.
assert_
(
contents
==
open
(
self
.
_path
,
'r
b
'
)
.
read
())
self
.
assert_
(
contents
==
open
(
self
.
_path
,
'r'
)
.
read
())
self
.
_box
=
self
.
_factory
(
self
.
_path
)
def
test_lock_conflict
(
self
):
...
...
@@ -918,7 +916,6 @@ class TestBabyl(TestMailbox):
_factory
=
lambda
self
,
path
,
factory
=
None
:
mailbox
.
Babyl
(
path
,
factory
)
def
tearDown
(
self
):
self
.
_box
.
close
()
self
.
_delete_recursively
(
self
.
_path
)
for
lock_remnant
in
glob
.
glob
(
self
.
_path
+
'.*'
):
test_support
.
unlink
(
lock_remnant
)
...
...
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