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
70efbefc
Kaydet (Commit)
70efbefc
authored
Ock 01, 2012
tarafından
Sandro Tosi
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #13594: various fixes to aifc module; patch by Oleg Plakhotnyuk
üst
bdd53547
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
17 deletions
+41
-17
aifc.py
Lib/aifc.py
+18
-17
test_aifc.py
Lib/test/test_aifc.py
+23
-0
No files found.
Lib/aifc.py
Dosyayı görüntüle @
70efbefc
...
...
@@ -539,8 +539,7 @@ class Aifc_write:
self
.
_aifc
=
1
# AIFF-C is default
def
__del__
(
self
):
if
self
.
_file
:
self
.
close
()
self
.
close
()
#
# User visible methods.
...
...
@@ -643,8 +642,8 @@ class Aifc_write:
raise
Error
(
'marker ID must be > 0'
)
if
pos
<
0
:
raise
Error
(
'marker position must be >= 0'
)
if
not
isinstance
(
name
,
str
):
raise
Error
(
'marker name must be
a string
'
)
if
not
isinstance
(
name
,
bytes
):
raise
Error
(
'marker name must be
bytes
'
)
for
i
in
range
(
len
(
self
.
_markers
)):
if
id
==
self
.
_markers
[
i
][
0
]:
self
.
_markers
[
i
]
=
id
,
pos
,
name
...
...
@@ -681,19 +680,21 @@ class Aifc_write:
self
.
_patchheader
()
def
close
(
self
):
self
.
_ensure_header_written
(
0
)
if
self
.
_datawritten
&
1
:
# quick pad to even size
self
.
_file
.
write
(
b
'
\x00
'
)
self
.
_datawritten
=
self
.
_datawritten
+
1
self
.
_writemarkers
()
if
self
.
_nframeswritten
!=
self
.
_nframes
or
\
self
.
_datalength
!=
self
.
_datawritten
or
\
self
.
_marklength
:
self
.
_patchheader
()
# Prevent ref cycles
self
.
_convert
=
None
self
.
_file
.
close
()
if
self
.
_file
:
self
.
_ensure_header_written
(
0
)
if
self
.
_datawritten
&
1
:
# quick pad to even size
self
.
_file
.
write
(
b
'
\x00
'
)
self
.
_datawritten
=
self
.
_datawritten
+
1
self
.
_writemarkers
()
if
self
.
_nframeswritten
!=
self
.
_nframes
or
\
self
.
_datalength
!=
self
.
_datawritten
or
\
self
.
_marklength
:
self
.
_patchheader
()
# Prevent ref cycles
self
.
_convert
=
None
self
.
_file
.
close
()
self
.
_file
=
None
#
# Internal methods.
...
...
Lib/test/test_aifc.py
Dosyayı görüntüle @
70efbefc
...
...
@@ -120,6 +120,29 @@ class AIFCTest(unittest.TestCase):
self
.
assertEqual
(
fout
.
getsampwidth
(),
2
)
fout
.
initfp
(
None
)
def
test_write_markers_values
(
self
):
fout
=
self
.
fout
=
aifc
.
open
(
io
.
BytesIO
(),
'wb'
)
self
.
assertEqual
(
fout
.
getmarkers
(),
None
)
fout
.
setmark
(
1
,
0
,
b
'foo1'
)
fout
.
setmark
(
1
,
1
,
b
'foo2'
)
self
.
assertEqual
(
fout
.
getmark
(
1
),
(
1
,
1
,
b
'foo2'
))
self
.
assertEqual
(
fout
.
getmarkers
(),
[(
1
,
1
,
b
'foo2'
)])
fout
.
initfp
(
None
)
def
test_read_markers
(
self
):
fout
=
self
.
fout
=
aifc
.
open
(
TESTFN
,
'wb'
)
fout
.
aiff
()
fout
.
setparams
((
1
,
1
,
1
,
1
,
b
'NONE'
,
b
''
))
fout
.
setmark
(
1
,
0
,
b
'odd'
)
fout
.
setmark
(
2
,
0
,
b
'even'
)
fout
.
writeframes
(
b
'
\x00
'
)
fout
.
close
()
f
=
self
.
f
=
aifc
.
open
(
TESTFN
,
'rb'
)
self
.
assertEqual
(
f
.
getmarkers
(),
[(
1
,
0
,
b
'odd'
),
(
2
,
0
,
b
'even'
)])
self
.
assertEqual
(
f
.
getmark
(
1
),
(
1
,
0
,
b
'odd'
))
self
.
assertEqual
(
f
.
getmark
(
2
),
(
2
,
0
,
b
'even'
))
self
.
assertRaises
(
aifc
.
Error
,
f
.
getmark
,
3
)
def
test_main
():
run_unittest
(
AIFCTest
)
...
...
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