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
bfa3470b
Kaydet (Commit)
bfa3470b
authored
Eki 30, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10246: uu.encode didn't close file objects explicitly when filenames
were given to it. Patch by Brian Brazil.
üst
b046b807
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
31 deletions
+41
-31
uu.py
Lib/uu.py
+38
-31
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/uu.py
Dosyayı görüntüle @
bfa3470b
...
...
@@ -44,40 +44,47 @@ def encode(in_file, out_file, name=None, mode=None):
#
# If in_file is a pathname open it and change defaults
#
if
in_file
==
'-'
:
in_file
=
sys
.
stdin
.
buffer
elif
isinstance
(
in_file
,
str
):
opened_files
=
[]
try
:
if
in_file
==
'-'
:
in_file
=
sys
.
stdin
.
buffer
elif
isinstance
(
in_file
,
str
):
if
name
is
None
:
name
=
os
.
path
.
basename
(
in_file
)
if
mode
is
None
:
try
:
mode
=
os
.
stat
(
in_file
)
.
st_mode
except
AttributeError
:
pass
in_file
=
open
(
in_file
,
'rb'
)
opened_files
.
append
(
in_file
)
#
# Open out_file if it is a pathname
#
if
out_file
==
'-'
:
out_file
=
sys
.
stdout
.
buffer
elif
isinstance
(
out_file
,
str
):
out_file
=
open
(
out_file
,
'wb'
)
opened_files
.
append
(
out_file
)
#
# Set defaults for name and mode
#
if
name
is
None
:
name
=
os
.
path
.
basename
(
in_file
)
name
=
'-'
if
mode
is
None
:
try
:
mode
=
os
.
stat
(
in_file
)
.
st_mode
except
AttributeError
:
pass
in_file
=
open
(
in_file
,
'rb'
)
#
# Open out_file if it is a pathname
#
if
out_file
==
'-'
:
out_file
=
sys
.
stdout
.
buffer
elif
isinstance
(
out_file
,
str
):
out_file
=
open
(
out_file
,
'wb'
)
#
# Set defaults for name and mode
#
if
name
is
None
:
name
=
'-'
if
mode
is
None
:
mode
=
0
o666
#
# Write the data
#
out_file
.
write
((
'begin
%
o
%
s
\n
'
%
((
mode
&
0
o777
),
name
))
.
encode
(
"ascii"
))
data
=
in_file
.
read
(
45
)
while
len
(
data
)
>
0
:
out_file
.
write
(
binascii
.
b2a_uu
(
data
))
mode
=
0
o666
#
# Write the data
#
out_file
.
write
((
'begin
%
o
%
s
\n
'
%
((
mode
&
0
o777
),
name
))
.
encode
(
"ascii"
))
data
=
in_file
.
read
(
45
)
out_file
.
write
(
b
'
\n
end
\n
'
)
while
len
(
data
)
>
0
:
out_file
.
write
(
binascii
.
b2a_uu
(
data
))
data
=
in_file
.
read
(
45
)
out_file
.
write
(
b
'
\n
end
\n
'
)
finally
:
for
f
in
opened_files
:
f
.
close
()
def
decode
(
in_file
,
out_file
=
None
,
mode
=
None
,
quiet
=
False
):
...
...
Misc/NEWS
Dosyayı görüntüle @
bfa3470b
...
...
@@ -57,6 +57,9 @@ Core and Builtins
Library
-------
- Issue #10246: uu.encode didn't close file objects explicitly when filenames
were given to it. Patch by Brian Brazil.
- Issue #10198: fix duplicate header written to wave files when writeframes()
is called without data.
...
...
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