Skip to content

Fix misleading AttributeError tracebacks on Request objects. #2530

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

Merged
merged 5 commits into from
Feb 9, 2015

Conversation

tomchristie
Copy link
Member

Closes #2108.

@tomchristie tomchristie changed the title Fix misleading AttributeError on Request` objects. Fix misleading AttributeError tracebacks on Request objects. Feb 9, 2015
@tomchristie tomchristie added the Bug label Feb 9, 2015
@tomchristie tomchristie added this to the 3.0.5 Release milestone Feb 9, 2015
@foresmac
Copy link

foresmac commented Feb 9, 2015

Thanks for working on this. I ended up tracing the problem to an issue with my auth backend, but it took some doing to get there because the original stack trace was lost.

@tomchristie
Copy link
Member Author

@foresmac Most welcome - needed to be done.

@tomchristie
Copy link
Member Author

Some unrelated stuff in this commit - mostly due to a silent upgrade of pep8 (we might consider pinning it)

@@ -154,7 +154,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru

If autoescape is True, the link text and URLs will get autoescaped.
"""
trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
def trim_url(x, limit=trim_url_limit):
return limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
Copy link

Choose a reason for hiding this comment

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

FWIW, I'd feel better if these conditional and y or x lines were replaced with explicit Python conditional assignment statements.

return ('%s...' % x[:max(0, limit - 3)]) if limit and len(x) > limit else x

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. We're just cloning from the Django codebase here so I don't particularly mind that it's a bit rubbish in this case.

tomchristie added a commit that referenced this pull request Feb 9, 2015
Fix misleading `AttributeError` tracebacks on `Request` objects.
@tomchristie tomchristie merged commit 873fb69 into master Feb 9, 2015
@tomchristie tomchristie deleted the attribute-proxying-fix branch February 9, 2015 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage of both @property and __getattr__ can lead to obscure and hard to debug errors
2 participants