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
bab07a65
Kaydet (Commit)
bab07a65
authored
Mar 17, 2011
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Tidy up merge with remote
üst
c9dacc27
b52c0be4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
18 deletions
+40
-18
binhex.py
Lib/binhex.py
+24
-18
test_binhex.py
Lib/test/test_binhex.py
+11
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/binhex.py
Dosyayı görüntüle @
bab07a65
...
@@ -52,14 +52,13 @@ class FInfo:
...
@@ -52,14 +52,13 @@ class FInfo:
def
getfileinfo
(
name
):
def
getfileinfo
(
name
):
finfo
=
FInfo
()
finfo
=
FInfo
()
fp
=
io
.
open
(
name
,
'rb'
)
with
io
.
open
(
name
,
'rb'
)
as
fp
:
# Quick check for textfile
# Quick check for textfile
data
=
fp
.
read
(
512
)
data
=
fp
.
read
(
512
)
if
0
not
in
data
:
if
0
not
in
data
:
finfo
.
Type
=
'TEXT'
finfo
.
Type
=
'TEXT'
fp
.
seek
(
0
,
2
)
fp
.
seek
(
0
,
2
)
dsize
=
fp
.
tell
()
dsize
=
fp
.
tell
()
fp
.
close
()
dir
,
file
=
os
.
path
.
split
(
name
)
dir
,
file
=
os
.
path
.
split
(
name
)
file
=
file
.
replace
(
':'
,
'-'
,
1
)
file
=
file
.
replace
(
':'
,
'-'
,
1
)
return
file
,
finfo
,
dsize
,
0
return
file
,
finfo
,
dsize
,
0
...
@@ -140,19 +139,26 @@ class _Rlecoderengine:
...
@@ -140,19 +139,26 @@ class _Rlecoderengine:
class
BinHex
:
class
BinHex
:
def
__init__
(
self
,
name_finfo_dlen_rlen
,
ofp
):
def
__init__
(
self
,
name_finfo_dlen_rlen
,
ofp
):
name
,
finfo
,
dlen
,
rlen
=
name_finfo_dlen_rlen
name
,
finfo
,
dlen
,
rlen
=
name_finfo_dlen_rlen
close_on_error
=
False
if
isinstance
(
ofp
,
str
):
if
isinstance
(
ofp
,
str
):
ofname
=
ofp
ofname
=
ofp
ofp
=
io
.
open
(
ofname
,
'wb'
)
ofp
=
io
.
open
(
ofname
,
'wb'
)
ofp
.
write
(
b
'(This file must be converted with BinHex 4.0)
\r\r
:'
)
close_on_error
=
True
hqxer
=
_Hqxcoderengine
(
ofp
)
try
:
self
.
ofp
=
_Rlecoderengine
(
hqxer
)
ofp
.
write
(
b
'(This file must be converted with BinHex 4.0)
\r\r
:'
)
self
.
crc
=
0
hqxer
=
_Hqxcoderengine
(
ofp
)
if
finfo
is
None
:
self
.
ofp
=
_Rlecoderengine
(
hqxer
)
finfo
=
FInfo
()
self
.
crc
=
0
self
.
dlen
=
dlen
if
finfo
is
None
:
self
.
rlen
=
rlen
finfo
=
FInfo
()
self
.
_writeinfo
(
name
,
finfo
)
self
.
dlen
=
dlen
self
.
state
=
_DID_HEADER
self
.
rlen
=
rlen
self
.
_writeinfo
(
name
,
finfo
)
self
.
state
=
_DID_HEADER
except
:
if
close_on_error
:
ofp
.
close
()
raise
def
_writeinfo
(
self
,
name
,
finfo
):
def
_writeinfo
(
self
,
name
,
finfo
):
nl
=
len
(
name
)
nl
=
len
(
name
)
...
...
Lib/test/test_binhex.py
Dosyayı görüntüle @
bab07a65
...
@@ -15,10 +15,12 @@ class BinHexTestCase(unittest.TestCase):
...
@@ -15,10 +15,12 @@ class BinHexTestCase(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
fname1
=
support
.
TESTFN
+
"1"
self
.
fname1
=
support
.
TESTFN
+
"1"
self
.
fname2
=
support
.
TESTFN
+
"2"
self
.
fname2
=
support
.
TESTFN
+
"2"
self
.
fname3
=
support
.
TESTFN
+
"very_long_filename__very_long_filename__very_long_filename__very_long_filename__"
def
tearDown
(
self
):
def
tearDown
(
self
):
support
.
unlink
(
self
.
fname1
)
support
.
unlink
(
self
.
fname1
)
support
.
unlink
(
self
.
fname2
)
support
.
unlink
(
self
.
fname2
)
support
.
unlink
(
self
.
fname3
)
DATA
=
b
'Jack is my hero'
DATA
=
b
'Jack is my hero'
...
@@ -37,6 +39,15 @@ class BinHexTestCase(unittest.TestCase):
...
@@ -37,6 +39,15 @@ class BinHexTestCase(unittest.TestCase):
self
.
assertEqual
(
self
.
DATA
,
finish
)
self
.
assertEqual
(
self
.
DATA
,
finish
)
def
test_binhex_error_on_long_filename
(
self
):
"""
The testcase fails if no exception is raised when a filename parameter provided to binhex.binhex()
is too long, or if the exception raised in binhex.binhex() is not an instance of binhex.Error.
"""
f3
=
open
(
self
.
fname3
,
'wb'
)
f3
.
close
()
self
.
assertRaises
(
binhex
.
Error
,
binhex
.
binhex
,
self
.
fname3
,
self
.
fname2
)
def
test_main
():
def
test_main
():
support
.
run_unittest
(
BinHexTestCase
)
support
.
run_unittest
(
BinHexTestCase
)
...
...
Misc/ACKS
Dosyayı görüntüle @
bab07a65
...
@@ -451,6 +451,7 @@ Tamito Kajiyama
...
@@ -451,6 +451,7 @@ Tamito Kajiyama
Peter van Kampen
Peter van Kampen
Rafe Kaplan
Rafe Kaplan
Jacob Kaplan-Moss
Jacob Kaplan-Moss
Arkady Koplyarov
Lou Kates
Lou Kates
Hiroaki Kawai
Hiroaki Kawai
Sebastien Keim
Sebastien Keim
...
...
Misc/NEWS
Dosyayı görüntüle @
bab07a65
...
@@ -72,6 +72,8 @@ Core and Builtins
...
@@ -72,6 +72,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
11577
:
fix
ResourceWarning
triggered
by
improved
binhex
test
coverage
-
Issue
#
11243
:
fix
the
parameter
querying
methods
of
Message
to
work
if
-
Issue
#
11243
:
fix
the
parameter
querying
methods
of
Message
to
work
if
the
headers
contain
un
-
encoded
non
-
ASCII
data
.
the
headers
contain
un
-
encoded
non
-
ASCII
data
.
...
@@ -242,6 +244,8 @@ Tools/Demos
...
@@ -242,6 +244,8 @@ Tools/Demos
Tests
Tests
-----
-----
- Issue #11577: improve test coverage of binhex.py. Patch by Arkady Koplyarov.
- New test_crashers added to exercise the scripts in the Lib/test/crashers
- New test_crashers added to exercise the scripts in the Lib/test/crashers
directory and confirm they fail as expected
directory and confirm they fail as expected
...
...
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