Skip to content

fix(compat): catch AttributeError since EntryPoints object has no get() #9167

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

Closed
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 3.9.0
rev: 5.0.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion rest_framework/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def apply_markdown(text):
)
md_filter_add_syntax_highlight(md)
return md.convert(text)
except ImportError:
except (ImportError, AttributeError):
Copy link

@graingert-coef graingert-coef Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the traceback you get that raises AttributeError? markdown has support for 3.12 and doesn't call entry_points(...).get(...)

https://github.com/Python-Markdown/markdown/blob/cef5afeb959d11e1ad5566fefa1f9a71136c1050/markdown/util.py#L110

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to update the pin in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check related issue for traceback, markdown is already set to 3.3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being handled here #9181

apply_markdown = None
markdown = None

Expand Down
2 changes: 1 addition & 1 deletion rest_framework/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def decorator(func):
# WrappedAPIView.__doc__ = func.doc <--- Not possible to do this

# api_view applied without (method_names)
assert not(isinstance(http_method_names, types.FunctionType)), \
assert not (isinstance(http_method_names, types.FunctionType)), \
'@api_view missing list of allowed HTTP methods'

# api_view applied with eg. string instead of list of strings
Expand Down
2 changes: 1 addition & 1 deletion tests/test_throttling.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def ensure_response_header_contains_proper_throttle_field(self, view, expected_h
if expect is not None:
assert response['Retry-After'] == expect
else:
assert not'Retry-After' in response
assert 'Retry-After' not in response

def test_seconds_fields(self):
"""
Expand Down