Closed foxx closed 9 years ago
This problem was introduced in 4a2f191c9d697a9198158e38675e4b01c4aa430d, which moved the class. I agree that this is a breaking change, because the documented API and implementations prior to 3.6.7 offered that class in twilio.TwilioRestException
. It needs to be reimported into the appropriate namespace.
The exceptions should still be importable like so:
from twilio import TwilioRestException
and also like so:
from twilio.rest.exceptions import TwilioRestException
This should prevent any backwards compatibility issues. I have no problems with version 3.6.7, which version are you on?
Sure, you can change your code to be compatible with the change and still work with old binaries, and I've done so, but that doesn't change the fact that this change and minor release broke code which relied on the documented API, and will presumably continue to break developers as they update. What's the problem with importing the exception into the spot in the namespace that it's documented to live?
Edit: sorry, I wasn't thinking (still drinking coffee), and misremembered the problem as being with twilio.rest.TwilioRestException
. @foxx is right; the problem is that twilio.TwilioRestException
doesn't work.
@phalt That's the point, the exception is currently not importable using;
from twilio import TwilioRestException
You are right that it should be working, but it isn't (as per latest release from 16 days ago).
@tdierks I think the issue here is I changed how we separated the exceptions and I missed this in the documentation. I'm looking into fixing the backwards compatible namespace issue now.
@foxx - can you run pip freeze
and see what version you have? I'm on 3.6.7 and I have no issues.
Sorry this took me so long, I was stuck in my own personal logic loop (in my head) seeing code that I thought was running, when I was actually running an installed version and not my local, new, code.
Here you go;
$ pip freeze | grep twilio
twilio==3.6.7
>>> from twilio import TwilioRestException
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name TwilioRestException
>>> twilio.__version_info__
('3', '6', '7')
Thanks @foxx - I think I found the issue.
@phalt Could you ref the commit which fixes this?
Sure. Fixed with 7df5a01e51335cf6c7aaf3023b1832e8ffccb425
In case anyone (like me) came here trying to figure out where to import from, it's now from twilio.base.exceptions import TwilioRestException
(as of 64fc4e01e8197acd521792e770baeeb99eebfa3b).
can we update the docs located here? https://twilio-python.readthedocs.io/en/latest/api/rest/ I would do it but I can't seem to find the file associated with it.
Hey @Altrum - thanks for letting us know. The docs on Read the Docs were definitely out of date, I just pulled them down.
The best place for docs and sample code on using this library live on www.twilio.com/docs. We have lots of automation and testing in place on those docs to make sure they're always up to date.
Let me know if you can't find what you're looking for there and I can try to help.
TwilioRestException: Unable to create record: Permission to send an SMS has not been enabled for the region indicated by the 'To' number:__
i am using twilio first time for sms and its showing this error .can anyone help me to solve this problem.
@mahimakaushik-oss Please open a new issue.
The docs say that
TwilioRestException
can be accessed fromtwilio.TwilioRestException
, but this is not the case.You instead need to use
twilio.rest.exceptions.TwilioRestException
.Is this a documentation bug, or should
twilio.TwilioRestException
actually work?