Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
31949b91
Commit
31949b91
authored
Dec 15, 2008
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3954: Fix error handling code in _hotshot.logreader
Will port to 2.6. hotshot was deleted from python 3.
parent
68060013
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
Lib/test/test_hotshot.py
Lib/test/test_hotshot.py
+6
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_hotshot.c
Modules/_hotshot.c
+8
-10
No files found.
Lib/test/test_hotshot.py
View file @
31949b91
...
...
@@ -3,6 +3,8 @@ import hotshot.log
import
os
import
pprint
import
unittest
import
_hotshot
import
gc
from
test
import
test_support
...
...
@@ -124,6 +126,10 @@ class HotShotTestCase(unittest.TestCase):
if
os
.
path
.
exists
(
test_support
.
TESTFN
):
os
.
remove
(
test_support
.
TESTFN
)
def
test_logreader_eof_error
(
self
):
self
.
assertRaises
((
IOError
,
EOFError
),
_hotshot
.
logreader
,
"."
)
gc
.
collect
()
def
test_main
():
test_support
.
run_unittest
(
HotShotTestCase
)
...
...
Misc/NEWS
View file @
31949b91
...
...
@@ -74,6 +74,9 @@ Core and Builtins
Library
-------
- Issue #3954: Fix a potential SystemError in _hotshot.logreader error
handling.
- Issue #4574: fix a crash in io.IncrementalNewlineDecoder when a carriage
return encodes to more than one byte in the source encoding (e.g. UTF-16)
and gets split on a chunk boundary.
...
...
Modules/_hotshot.c
View file @
31949b91
...
...
@@ -1357,20 +1357,16 @@ hotshot_logreader(PyObject *unused, PyObject *args)
self
->
logfp
=
fopen
(
filename
,
"rb"
);
if
(
self
->
logfp
==
NULL
)
{
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
filename
);
Py_DECREF
(
self
);
self
=
NULL
;
goto
finally
;
goto
error
;
}
self
->
info
=
PyDict_New
();
if
(
self
->
info
==
NULL
)
{
Py_DECREF
(
self
);
goto
finally
;
}
if
(
self
->
info
==
NULL
)
goto
error
;
/* read initial info */
for
(;;)
{
if
((
c
=
fgetc
(
self
->
logfp
))
==
EOF
)
{
eof_error
(
self
);
break
;
goto
error
;
}
if
(
c
!=
WHAT_ADD_INFO
)
{
ungetc
(
c
,
self
->
logfp
);
...
...
@@ -1383,13 +1379,15 @@ hotshot_logreader(PyObject *unused, PyObject *args)
else
PyErr_SetString
(
PyExc_RuntimeError
,
"unexpected error"
);
break
;
goto
error
;
}
}
}
}
finally:
return
(
PyObject
*
)
self
;
error:
Py_DECREF
(
self
);
return
NULL
;
}
...
...
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