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
84d28b4e
Kaydet (Commit)
84d28b4e
authored
Ara 14, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19623: Fixed writing to unseekable files in the aifc module.
üst
5da107ac
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
62 deletions
+103
-62
aifc.py
Lib/aifc.py
+8
-3
audiotests.py
Lib/test/audiotests.py
+62
-0
test_aifc.py
Lib/test/test_aifc.py
+12
-29
test_sunau.py
Lib/test/test_sunau.py
+8
-15
test_wave.py
Lib/test/test_wave.py
+11
-15
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/aifc.py
Dosyayı görüntüle @
84d28b4e
...
@@ -771,7 +771,10 @@ class Aifc_write:
...
@@ -771,7 +771,10 @@ class Aifc_write:
self
.
_datalength
=
(
self
.
_datalength
+
3
)
//
4
self
.
_datalength
=
(
self
.
_datalength
+
3
)
//
4
if
self
.
_datalength
&
1
:
if
self
.
_datalength
&
1
:
self
.
_datalength
=
self
.
_datalength
+
1
self
.
_datalength
=
self
.
_datalength
+
1
self
.
_form_length_pos
=
self
.
_file
.
tell
()
try
:
self
.
_form_length_pos
=
self
.
_file
.
tell
()
except
(
AttributeError
,
OSError
):
self
.
_form_length_pos
=
None
commlength
=
self
.
_write_form_length
(
self
.
_datalength
)
commlength
=
self
.
_write_form_length
(
self
.
_datalength
)
if
self
.
_aifc
:
if
self
.
_aifc
:
self
.
_file
.
write
(
b
'AIFC'
)
self
.
_file
.
write
(
b
'AIFC'
)
...
@@ -783,7 +786,8 @@ class Aifc_write:
...
@@ -783,7 +786,8 @@ class Aifc_write:
self
.
_file
.
write
(
b
'COMM'
)
self
.
_file
.
write
(
b
'COMM'
)
_write_ulong
(
self
.
_file
,
commlength
)
_write_ulong
(
self
.
_file
,
commlength
)
_write_short
(
self
.
_file
,
self
.
_nchannels
)
_write_short
(
self
.
_file
,
self
.
_nchannels
)
self
.
_nframes_pos
=
self
.
_file
.
tell
()
if
self
.
_form_length_pos
is
not
None
:
self
.
_nframes_pos
=
self
.
_file
.
tell
()
_write_ulong
(
self
.
_file
,
self
.
_nframes
)
_write_ulong
(
self
.
_file
,
self
.
_nframes
)
if
self
.
_comptype
in
(
b
'ULAW'
,
b
'ulaw'
,
b
'ALAW'
,
b
'alaw'
,
b
'G722'
):
if
self
.
_comptype
in
(
b
'ULAW'
,
b
'ulaw'
,
b
'ALAW'
,
b
'alaw'
,
b
'G722'
):
_write_short
(
self
.
_file
,
8
)
_write_short
(
self
.
_file
,
8
)
...
@@ -794,7 +798,8 @@ class Aifc_write:
...
@@ -794,7 +798,8 @@ class Aifc_write:
self
.
_file
.
write
(
self
.
_comptype
)
self
.
_file
.
write
(
self
.
_comptype
)
_write_string
(
self
.
_file
,
self
.
_compname
)
_write_string
(
self
.
_file
,
self
.
_compname
)
self
.
_file
.
write
(
b
'SSND'
)
self
.
_file
.
write
(
b
'SSND'
)
self
.
_ssnd_length_pos
=
self
.
_file
.
tell
()
if
self
.
_form_length_pos
is
not
None
:
self
.
_ssnd_length_pos
=
self
.
_file
.
tell
()
_write_ulong
(
self
.
_file
,
self
.
_datalength
+
8
)
_write_ulong
(
self
.
_file
,
self
.
_datalength
+
8
)
_write_ulong
(
self
.
_file
,
0
)
_write_ulong
(
self
.
_file
,
0
)
_write_ulong
(
self
.
_file
,
0
)
_write_ulong
(
self
.
_file
,
0
)
...
...
Lib/test/audiotests.py
Dosyayı görüntüle @
84d28b4e
...
@@ -5,6 +5,13 @@ import io
...
@@ -5,6 +5,13 @@ import io
import
pickle
import
pickle
import
sys
import
sys
class
UnseekableIO
(
io
.
FileIO
):
def
tell
(
self
):
raise
io
.
UnsupportedOperation
def
seek
(
self
,
*
args
,
**
kwargs
):
raise
io
.
UnsupportedOperation
def
byteswap2
(
data
):
def
byteswap2
(
data
):
a
=
array
.
array
(
'h'
)
a
=
array
.
array
(
'h'
)
a
.
frombytes
(
data
)
a
.
frombytes
(
data
)
...
@@ -129,6 +136,61 @@ class AudioWriteTests(AudioTests):
...
@@ -129,6 +136,61 @@ class AudioWriteTests(AudioTests):
self
.
assertEqual
(
testfile
.
read
(
13
),
b
'ababagalamaga'
)
self
.
assertEqual
(
testfile
.
read
(
13
),
b
'ababagalamaga'
)
self
.
check_file
(
testfile
,
self
.
nframes
,
self
.
frames
)
self
.
check_file
(
testfile
,
self
.
nframes
,
self
.
frames
)
def
test_unseekable_read
(
self
):
f
=
self
.
create_file
(
TESTFN
)
f
.
setnframes
(
self
.
nframes
)
f
.
writeframes
(
self
.
frames
)
f
.
close
()
with
UnseekableIO
(
TESTFN
,
'rb'
)
as
testfile
:
self
.
check_file
(
testfile
,
self
.
nframes
,
self
.
frames
)
def
test_unseekable_write
(
self
):
with
UnseekableIO
(
TESTFN
,
'wb'
)
as
testfile
:
f
=
self
.
create_file
(
testfile
)
f
.
setnframes
(
self
.
nframes
)
f
.
writeframes
(
self
.
frames
)
f
.
close
()
self
.
check_file
(
TESTFN
,
self
.
nframes
,
self
.
frames
)
def
test_unseekable_incompleted_write
(
self
):
with
UnseekableIO
(
TESTFN
,
'wb'
)
as
testfile
:
testfile
.
write
(
b
'ababagalamaga'
)
f
=
self
.
create_file
(
testfile
)
f
.
setnframes
(
self
.
nframes
+
1
)
try
:
f
.
writeframes
(
self
.
frames
)
except
OSError
:
pass
try
:
f
.
close
()
except
OSError
:
pass
with
open
(
TESTFN
,
'rb'
)
as
testfile
:
self
.
assertEqual
(
testfile
.
read
(
13
),
b
'ababagalamaga'
)
self
.
check_file
(
testfile
,
self
.
nframes
+
1
,
self
.
frames
)
def
test_unseekable_overflowed_write
(
self
):
with
UnseekableIO
(
TESTFN
,
'wb'
)
as
testfile
:
testfile
.
write
(
b
'ababagalamaga'
)
f
=
self
.
create_file
(
testfile
)
f
.
setnframes
(
self
.
nframes
-
1
)
try
:
f
.
writeframes
(
self
.
frames
)
except
OSError
:
pass
try
:
f
.
close
()
except
OSError
:
pass
with
open
(
TESTFN
,
'rb'
)
as
testfile
:
self
.
assertEqual
(
testfile
.
read
(
13
),
b
'ababagalamaga'
)
framesize
=
self
.
nchannels
*
self
.
sampwidth
self
.
check_file
(
testfile
,
self
.
nframes
-
1
,
self
.
frames
[:
-
framesize
])
class
AudioTestsWithSourceFile
(
AudioTests
):
class
AudioTestsWithSourceFile
(
AudioTests
):
...
...
Lib/test/test_aifc.py
Dosyayı görüntüle @
84d28b4e
...
@@ -8,10 +8,14 @@ import struct
...
@@ -8,10 +8,14 @@ import struct
import
aifc
import
aifc
class
AifcPCM8Test
(
audiotests
.
AudioWriteTests
,
class
AifcTest
(
audiotests
.
AudioWriteTests
,
audiotests
.
AudioTestsWithSourceFile
,
audiotests
.
AudioTestsWithSourceFile
):
unittest
.
TestCase
):
module
=
aifc
module
=
aifc
close_fd
=
True
test_unseekable_read
=
None
class
AifcPCM8Test
(
AifcTest
,
unittest
.
TestCase
):
sndfilename
=
'pluck-pcm8.aiff'
sndfilename
=
'pluck-pcm8.aiff'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -26,13 +30,9 @@ class AifcPCM8Test(audiotests.AudioWriteTests,
...
@@ -26,13 +30,9 @@ class AifcPCM8Test(audiotests.AudioWriteTests,
11FA 3EFB BCFC 66FF CF04 4309 C10E 5112 EE17 8216 7F14 8012
\
11FA 3EFB BCFC 66FF CF04 4309 C10E 5112 EE17 8216 7F14 8012
\
490E 520D EF0F CE0F E40C 630A 080A 2B0B 510E 8B11 B60E 440A
\
490E 520D EF0F CE0F E40C 630A 080A 2B0B 510E 8B11 B60E 440A
\
"""
)
"""
)
close_fd
=
True
class
AifcPCM16Test
(
audiotests
.
AudioWriteTests
,
class
AifcPCM16Test
(
AifcTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
aifc
sndfilename
=
'pluck-pcm16.aiff'
sndfilename
=
'pluck-pcm16.aiff'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -49,13 +49,9 @@ class AifcPCM16Test(audiotests.AudioWriteTests,
...
@@ -49,13 +49,9 @@ class AifcPCM16Test(audiotests.AudioWriteTests,
EEE21753 82071665 7FFF1443 8004128F 49A20EAF 52BB0DBA EFB40F60 CE3C0FBF
\
EEE21753 82071665 7FFF1443 8004128F 49A20EAF 52BB0DBA EFB40F60 CE3C0FBF
\
E4B30CEC 63430A5C 08C80A20 2BBB0B08 514A0E43 8BCF1139 B6F60EEB 44120A5E
\
E4B30CEC 63430A5C 08C80A20 2BBB0B08 514A0E43 8BCF1139 B6F60EEB 44120A5E
\
"""
)
"""
)
close_fd
=
True
class
AifcPCM24Test
(
audiotests
.
AudioWriteTests
,
class
AifcPCM24Test
(
AifcTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
aifc
sndfilename
=
'pluck-pcm24.aiff'
sndfilename
=
'pluck-pcm24.aiff'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -78,13 +74,9 @@ class AifcPCM24Test(audiotests.AudioWriteTests,
...
@@ -78,13 +74,9 @@ class AifcPCM24Test(audiotests.AudioWriteTests,
E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E
\
E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E
\
51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48
\
51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48
\
"""
)
"""
)
close_fd
=
True
class
AifcPCM32Test
(
audiotests
.
AudioWriteTests
,
class
AifcPCM32Test
(
AifcTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
aifc
sndfilename
=
'pluck-pcm32.aiff'
sndfilename
=
'pluck-pcm32.aiff'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -107,13 +99,9 @@ class AifcPCM32Test(audiotests.AudioWriteTests,
...
@@ -107,13 +99,9 @@ class AifcPCM32Test(audiotests.AudioWriteTests,
E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00
\
E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00
\
51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0
\
51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0
\
"""
)
"""
)
close_fd
=
True
class
AifcULAWTest
(
audiotests
.
AudioWriteTests
,
class
AifcULAWTest
(
AifcTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
aifc
sndfilename
=
'pluck-ulaw.aifc'
sndfilename
=
'pluck-ulaw.aifc'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -132,13 +120,9 @@ class AifcULAWTest(audiotests.AudioWriteTests,
...
@@ -132,13 +120,9 @@ class AifcULAWTest(audiotests.AudioWriteTests,
"""
)
"""
)
if
sys
.
byteorder
!=
'big'
:
if
sys
.
byteorder
!=
'big'
:
frames
=
audiotests
.
byteswap2
(
frames
)
frames
=
audiotests
.
byteswap2
(
frames
)
close_fd
=
True
class
AifcALAWTest
(
audiotests
.
AudioWriteTests
,
class
AifcALAWTest
(
AifcTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
aifc
sndfilename
=
'pluck-alaw.aifc'
sndfilename
=
'pluck-alaw.aifc'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -157,7 +141,6 @@ class AifcALAWTest(audiotests.AudioWriteTests,
...
@@ -157,7 +141,6 @@ class AifcALAWTest(audiotests.AudioWriteTests,
"""
)
"""
)
if
sys
.
byteorder
!=
'big'
:
if
sys
.
byteorder
!=
'big'
:
frames
=
audiotests
.
byteswap2
(
frames
)
frames
=
audiotests
.
byteswap2
(
frames
)
close_fd
=
True
class
AifcMiscTest
(
audiotests
.
AudioTests
,
unittest
.
TestCase
):
class
AifcMiscTest
(
audiotests
.
AudioTests
,
unittest
.
TestCase
):
...
...
Lib/test/test_sunau.py
Dosyayı görüntüle @
84d28b4e
...
@@ -5,10 +5,12 @@ import sys
...
@@ -5,10 +5,12 @@ import sys
import
sunau
import
sunau
class
SunauPCM8Test
(
audiotests
.
AudioWriteTests
,
class
SunauTest
(
audiotests
.
AudioWriteTests
,
audiotests
.
AudioTestsWithSourceFile
,
audiotests
.
AudioTestsWithSourceFile
):
unittest
.
TestCase
):
module
=
sunau
module
=
sunau
class
SunauPCM8Test
(
SunauTest
,
unittest
.
TestCase
):
sndfilename
=
'pluck-pcm8.au'
sndfilename
=
'pluck-pcm8.au'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -25,10 +27,7 @@ class SunauPCM8Test(audiotests.AudioWriteTests,
...
@@ -25,10 +27,7 @@ class SunauPCM8Test(audiotests.AudioWriteTests,
"""
)
"""
)
class
SunauPCM16Test
(
audiotests
.
AudioWriteTests
,
class
SunauPCM16Test
(
SunauTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
sunau
sndfilename
=
'pluck-pcm16.au'
sndfilename
=
'pluck-pcm16.au'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -47,10 +46,7 @@ class SunauPCM16Test(audiotests.AudioWriteTests,
...
@@ -47,10 +46,7 @@ class SunauPCM16Test(audiotests.AudioWriteTests,
"""
)
"""
)
class
SunauPCM32Test
(
audiotests
.
AudioWriteTests
,
class
SunauPCM32Test
(
SunauTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
sunau
sndfilename
=
'pluck-pcm32.au'
sndfilename
=
'pluck-pcm32.au'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -75,10 +71,7 @@ class SunauPCM32Test(audiotests.AudioWriteTests,
...
@@ -75,10 +71,7 @@ class SunauPCM32Test(audiotests.AudioWriteTests,
"""
)
"""
)
class
SunauULAWTest
(
audiotests
.
AudioWriteTests
,
class
SunauULAWTest
(
SunauTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
sunau
sndfilename
=
'pluck-ulaw.au'
sndfilename
=
'pluck-ulaw.au'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
...
Lib/test/test_wave.py
Dosyayı görüntüle @
84d28b4e
...
@@ -5,10 +5,15 @@ import sys
...
@@ -5,10 +5,15 @@ import sys
import
wave
import
wave
class
WavePCM8Test
(
audiotests
.
AudioWriteTests
,
class
WaveTest
(
audiotests
.
AudioWriteTests
,
audiotests
.
AudioTestsWithSourceFile
,
audiotests
.
AudioTestsWithSourceFile
):
unittest
.
TestCase
):
module
=
wave
module
=
wave
test_unseekable_write
=
None
test_unseekable_overflowed_write
=
None
test_unseekable_incompleted_write
=
None
class
WavePCM8Test
(
WaveTest
,
unittest
.
TestCase
):
sndfilename
=
'pluck-pcm8.wav'
sndfilename
=
'pluck-pcm8.wav'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -25,10 +30,7 @@ class WavePCM8Test(audiotests.AudioWriteTests,
...
@@ -25,10 +30,7 @@ class WavePCM8Test(audiotests.AudioWriteTests,
"""
)
"""
)
class
WavePCM16Test
(
audiotests
.
AudioWriteTests
,
class
WavePCM16Test
(
WaveTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
wave
sndfilename
=
'pluck-pcm16.wav'
sndfilename
=
'pluck-pcm16.wav'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -55,10 +57,7 @@ class WavePCM16Test(audiotests.AudioWriteTests,
...
@@ -55,10 +57,7 @@ class WavePCM16Test(audiotests.AudioWriteTests,
class
WavePCM24Test
(
audiotests
.
AudioWriteTests
,
class
WavePCM24Test
(
WaveTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
wave
sndfilename
=
'pluck-pcm24.wav'
sndfilename
=
'pluck-pcm24.wav'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
@@ -85,10 +84,7 @@ class WavePCM24Test(audiotests.AudioWriteTests,
...
@@ -85,10 +84,7 @@ class WavePCM24Test(audiotests.AudioWriteTests,
frames
=
audiotests
.
byteswap3
(
frames
)
frames
=
audiotests
.
byteswap3
(
frames
)
class
WavePCM32Test
(
audiotests
.
AudioWriteTests
,
class
WavePCM32Test
(
WaveTest
,
unittest
.
TestCase
):
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
module
=
wave
sndfilename
=
'pluck-pcm32.wav'
sndfilename
=
'pluck-pcm32.wav'
sndfilenframes
=
3307
sndfilenframes
=
3307
nchannels
=
2
nchannels
=
2
...
...
Misc/NEWS
Dosyayı görüntüle @
84d28b4e
...
@@ -32,6 +32,8 @@ Core and Builtins
...
@@ -32,6 +32,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #19623: Fixed writing to unseekable files in the aifc module.
- Issue #17919: select.poll.register() again works with poll.POLLNVAL on AIX.
- Issue #17919: select.poll.register() again works with poll.POLLNVAL on AIX.
Fixed integer overflow in the eventmask parameter.
Fixed integer overflow in the eventmask parameter.
...
...
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