From 4f755a8bdec9c715d06ce47b46c9a878194d563c Mon Sep 17 00:00:00 2001 From: Michael Floering Date: Wed, 2 Dec 2015 11:50:48 -0600 Subject: [PATCH] Fail gracefully if disable_warnings not available Addresses #418. Rationale explained there. --- httpie/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/httpie/client.py b/httpie/client.py index 190737d2..d55ce62c 100644 --- a/httpie/client.py +++ b/httpie/client.py @@ -11,8 +11,14 @@ from httpie.compat import str from httpie.plugins import plugin_manager -# https://urllib3.readthedocs.org/en/latest/security.html -urllib3.disable_warnings() +try: + # https://urllib3.readthedocs.org/en/latest/security.html + urllib3.disable_warnings() +except AttributeError: + # In some rare cases, the user may have an old version of the requests or urllib3, + # and there is no method called "disable_warnings." In these cases, we don't need to call + # the method. They may get some noisy output but execution shouldn't die. Move on + pass FORM = 'application/x-www-form-urlencoded; charset=utf-8'