Skip to content

updating for compatibility with yaml 6.0.1 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable/0.3.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions rest_framework_swagger/introspectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
import django_filters
except ImportError:
django_filters = None

try:
# try and use C if available, since it's faster
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader

def get_view_description(view_cls, html=False, docstring=None):
if docstring is not None:
Expand Down Expand Up @@ -944,7 +948,7 @@ def load_obj_from_docstring(self, docstring):
yaml_string = "\n".join(split_lines[cut_from:])
yaml_string = formatting.dedent(yaml_string)
try:
return yaml.load(yaml_string)
return yaml.load(yaml_string, Loader=SafeLoader)
except yaml.YAMLError as e:
self.yaml_error = e
return None
Expand Down