Revert "Handle syntax error in load config file."
This commit is contained in:
parent
6778f4d9e0
commit
ebb28fdcae
|
@ -1,8 +1,6 @@
|
|||
import os
|
||||
import types
|
||||
|
||||
from sanic.exceptions import PyFileError
|
||||
|
||||
|
||||
SANIC_PREFIX = 'SANIC_'
|
||||
|
||||
|
@ -85,9 +83,6 @@ class Config(dict):
|
|||
except IOError as e:
|
||||
e.strerror = 'Unable to load configuration file (%s)' % e.strerror
|
||||
raise
|
||||
except Exception as e:
|
||||
raise PyFileError(filename) from e
|
||||
|
||||
self.from_object(module)
|
||||
return True
|
||||
|
||||
|
|
|
@ -223,11 +223,6 @@ class InvalidRangeType(ContentRangeError):
|
|||
pass
|
||||
|
||||
|
||||
class PyFileError(Exception):
|
||||
def __init__(self, file):
|
||||
super().__init__('could not execute config file %s', file)
|
||||
|
||||
|
||||
@add_status_code(401)
|
||||
class Unauthorized(SanicException):
|
||||
"""
|
||||
|
|
|
@ -6,7 +6,6 @@ from textwrap import dedent
|
|||
import pytest
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.exceptions import PyFileError
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -88,16 +87,6 @@ def test_load_from_missing_envvar(app):
|
|||
"could not be loaded.")
|
||||
|
||||
|
||||
def test_load_config_from_file_invalid_syntax(app):
|
||||
config = b"VALUE = some value"
|
||||
with NamedTemporaryFile() as config_file:
|
||||
config_file.write(config)
|
||||
config_file.seek(0)
|
||||
|
||||
with pytest.raises(PyFileError):
|
||||
app.config.from_pyfile(config_file.name)
|
||||
|
||||
|
||||
def test_overwrite_exisiting_config(app):
|
||||
app.config.DEFAULT = 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user