-
Notifications
You must be signed in to change notification settings - Fork 887
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
an empty request.finished_callbacks
returns None
in master/1.6; returns empty tuple ()
in earlier versions
#1600
Comments
Please provide some kind of example which shows the behavior you are seeing. |
It used to be an empty tuple on initialization. It is now This is a departure from earlier Pyramid releases, where it initialized as a tuple (iterable!). in 1.5.4 and prior, in 1.6/master, it initializes to Here's a drop-in replacement view for the starter template https://gist.github.com/jvanasco/d0b8ba106291f40139e4 |
I just wanted to add - I have no opinion on which behavior is better. This should just be documented as a potentially-breaking change if this new behavior is intended. |
I'm pretty sure |
@mmerickel the switch to None is in response to your comment on #1373. |
@tseaver oh I'm aware, I didn't realize anyone was depending on the internal API. |
Interesting. I didn't realize it was an internal API. I use it in two situations -- read only: • Test Suites (90% of my usage). Check to see if the • One library I wrote has an "ensure_cleanup" function. It checks to see if the cleanup function has already been added, as It only needs to be run once. I was naively relying on that. I think it's fine to leave as-is. A note in the changelog would be great though, because I expect others who have written packages have relied on this being an empty list. Searching in github, it looks like "response_callbacks" is more popular (also an internal api, it seems), but is used a lot in testing. Quickly searching github's source, the two most popular packages I saw that expected an iterable for that were pyramid_redis_sessions and pyramid_zodbconn |
If we change this I'd advocate for something closer to the following: class Request(object):
_finished_callbacks = None
@property
def finished_callbacks(self):
callbacks = getattr(self, '_finished_callbacks', None)
if callbacks is None:
callbacks = collections.deque()
self._finished_callbacks = callbacks
return callbacks I see no problem with documenting it as a read-only iterable but the fact that it is a |
I've updated this to return an empty |
This raised an exception for me when testing against #1534
I confirmed this behavior in a fresh virtualenv against 1.5.4 and and master/1.6.
I couldn't figure out where the change comes from. It's not documented, and will break anything that inspects
request.finished_callbacks
without checking for None (which was previously not needed)The text was updated successfully, but these errors were encountered: