numberoverzero / bottom

asyncio-based rfc2812-compliant IRC Client
http://bottom-docs.readthedocs.io
MIT License
74 stars 23 forks source link

partial_bind fails for bound methods #9

Closed numberoverzero closed 9 years ago

numberoverzero commented 9 years ago

partial_bind is failing to preserve self when handed a bound method, probably because the signature is inspected after wrapping non-coroutines. Inspecting first should take care of the problem.

minimal repro:

class Object:
    def handle(self, host, port):
        print("Connected: {} {}".format(host, port))
obj = Object()
bound_method = obj.handle

import asnycio
import bottom
client = bottom.Client("localhost", "8080")
client.on("client_connect")(bound_method)
# Throws when connecting because Object.handle gets params "host" and "port" but not "self"
asyncio.get_event_loop().run_until_complete(client.run())