Breaking changes

This page keeps track of the main changes that could cause your current application to stop working when you update Peony.

Changes in Peony 2.0

Twitter exceptions inherit from HTTP exceptions

The name of the exceptions related to the HTTP status of the response are now prefixed with HTTP. Here is a list of those new exceptions:

The exceptions related to twitter error codes now inherit from those exceptions, this means that the order of execution of your except blocks now matter. The “HTTP” exceptions should be handled after the exceptions related to twitter error codes.

This works as expected:

except ReadOnlyApplication:
    ...
except HTTPForbidden:
    ...

Here, ReadOnlyApplication will be caught by the first except block instead of the more specific except ReadOnlyApplication.

except HTTPForbidden:
    ...
except ReadOnlyApplication:
    ...

PeonyClient doesn’t have a twitter_configuration attribute anymore

Twitter removed the endpoint used to set this attribute’s value, because they never really changed. So you can use constants instead of using the values from this attribute.

Here is an exemple of what this endpoint used to return in case you need it.

Changes in Peony 1.1

Error Handlers must inherit from ErrorHandler

Error handler should now inherit from ErrorHandler. This ensures that the exception will correctly be propagated when you make a request. See Handle errors for every request for more details on how to create an error handler.

PeonyClient’s properties are now awaitables

It wasn’t very documented until now, but PeonyClient has two properties user and twitter_configuration. They used to be created during the first request made by the client which led to some weird scenarios where these properties could return None.

Now these properties are awaitables, which can make the syntax a bit more complicated to use, but now you will never be left with a None.

client = PeonyClient(**api_keys)
user = await client.user  # assuming we are in a coroutine
print(user.screen_name)   # "POTUS"

Init tasks don’t exist anymore

I think nobody used them anyway but just in case anyone did. They were used to create the user and twitter_configuration properties in PeonyClient.