mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Fix for issue #693
- Added changes to file read, as per review comments
This commit is contained in:
parent
e1e5d3638f
commit
b6f3cb8e7c
@ -315,11 +315,13 @@ def _get_codeobj(pyfile):
|
|||||||
# WARNING:
|
# WARNING:
|
||||||
# fp.read() can blowup if the module is extremely large file.
|
# fp.read() can blowup if the module is extremely large file.
|
||||||
# Lookout for overflow errors.
|
# Lookout for overflow errors.
|
||||||
if result is PY_COMPILED:
|
try:
|
||||||
# This is a .pyc file. Treat accordingly.
|
|
||||||
data = fileobj.read()
|
data = fileobj.read()
|
||||||
|
finally:
|
||||||
fileobj.close()
|
fileobj.close()
|
||||||
|
|
||||||
|
# This is a .pyc file. Treat accordingly.
|
||||||
|
if result is PY_COMPILED:
|
||||||
# .pyc format is as follows:
|
# .pyc format is as follows:
|
||||||
# 0 - 4 bytes: Magic number, which changes with each create of .pyc file.
|
# 0 - 4 bytes: Magic number, which changes with each create of .pyc file.
|
||||||
# First 2 bytes change with each marshal of .pyc file. Last 2 bytes is "\r\n".
|
# First 2 bytes change with each marshal of .pyc file. Last 2 bytes is "\r\n".
|
||||||
@ -331,8 +333,7 @@ def _get_codeobj(pyfile):
|
|||||||
|
|
||||||
elif result is PY_SOURCE:
|
elif result is PY_SOURCE:
|
||||||
# This is a .py file.
|
# This is a .py file.
|
||||||
code_obj = compile(fileobj.read(), fullpath, 'exec')
|
code_obj = compile(data, fullpath, 'exec')
|
||||||
fileobj.close()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Unsupported extension
|
# Unsupported extension
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user