Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb517f1

Browse files
committed
Add mini-FAT error definition
Also fix test comparison on python 3.2 (bytes vs unicode)
1 parentac61057 commiteb517f1

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

‎compoundfiles/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
CompoundFileInvalidBomError,
8282
CompoundFileLargeNormalFatError,
8383
CompoundFileLargeMiniFatError,
84+
CompoundFileNoMiniFatError,
8485
CompoundFileMasterLoopError,
8586
CompoundFileNormalLoopError,
8687
CompoundFileDirLoopError,

‎compoundfiles/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class CompoundFileLargeMiniFatError(CompoundFileMiniFatError):
8686
Error raised when the document has an excessively large mini FAT.
8787
"""
8888

89+
classCompoundFileNoMiniFatError(CompoundFileMiniFatError):
90+
"""
91+
Error raised when the document has no mini-FAT, but an attempt is made
92+
to open a file that should belong to the mini-FAT.
93+
"""
94+
8995
classCompoundFileMasterLoopError(CompoundFileMasterFatError):
9096
"""
9197
Error raised when a loop is detected in the master FAT.

‎compoundfiles/streams.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
fromabcimportabstractmethod
3939

4040
fromcompoundfiles.errorsimport (
41+
CompoundFileNoMiniFatError,
4142
CompoundFileNormalLoopError,
4243
CompoundFileDirSizeWarning,
4344
CompoundFileTruncatedWarning,
@@ -222,6 +223,9 @@ def read1(self, n=-1):
222223
classCompoundFileMiniStream(CompoundFileStream):
223224
def__init__(self,parent,start,length=None):
224225
super(CompoundFileMiniStream,self).__init__()
226+
ifnotparent._mini_fat:
227+
raiseCompoundFileNoMiniFatError(
228+
'no mini FAT in compound document')
225229
self._load_sectors(start,parent._mini_fat)
226230
self._sector_size=parent._mini_sector_size
227231
self._header_size=0

‎tests/test_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def verify_example(doc, contents=None, test_contents=True):
7171
iftest_contents:
7272
forentryincontents:
7373
ifentry.isfile:
74-
assertdoc.open(entry.name).read()== ('Data'* ((entry.size+3)//4))[:entry.size]
74+
assertdoc.open(entry.name).read()== (b'Data'* ((entry.size+3)//4))[:entry.size]
7575

7676
@pytest.fixture(params=(
7777
('tests/sample1.doc', (

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp