File tree Expand file tree Collapse file tree 6 files changed +21
-11
lines changed Expand file tree Collapse file tree 6 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 5151 ConnectionTimeout ,
5252 AuthenticationException ,
5353 AuthorizationException ,
54+ ElasticsearchWarning ,
5455 ElasticsearchDeprecationWarning ,
5556)
5657
8081 "ConnectionTimeout" ,
8182 "AuthenticationException" ,
8283 "AuthorizationException" ,
84+ "ElasticsearchWarning" ,
8385 "ElasticsearchDeprecationWarning" ,
8486]
8587
Original file line number Diff line number Diff line change 3131from ..exceptions import (
3232 TransportError ,
3333 ImproperlyConfigured ,
34- ElasticsearchDeprecationWarning ,
34+ ElasticsearchWarning ,
3535 HTTP_EXCEPTIONS ,
3636)
3737from .. import __versionstr__
@@ -197,7 +197,7 @@ def _raise_warnings(self, warning_headers):
197197 warning_messages .append (header )
198198
199199 for message in warning_messages :
200- warnings .warn (message , category = ElasticsearchDeprecationWarning )
200+ warnings .warn (message , category = ElasticsearchWarning )
201201
202202 def _pretty_json (self , data ):
203203 # pretty JSON in tracer curl logs
Original file line number Diff line number Diff line change @@ -153,12 +153,18 @@ class AuthorizationException(TransportError):
153153 """ Exception representing a 403 status code. """
154154
155155
156- class ElasticsearchDeprecationWarning (Warning ):
156+ class ElasticsearchWarning (Warning ):
157157 """Warning that is raised when a deprecated option
158- is flagged via the 'Warning' HTTP header.
158+ or incorrect usage is flagged via the 'Warning' HTTP header.
159159 """
160160
161161
162+ # Alias of 'ElasticsearchWarning' for backwards compatibility.
163+ # Additional functionality was added to the 'Warning' HTTP header
164+ # not related to deprecations.
165+ ElasticsearchDeprecationWarning = ElasticsearchWarning
166+
167+
162168# more generic mappings from status_code to python exceptions
163169HTTP_EXCEPTIONS = {
164170 400 : RequestError ,
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ class ConflictError(TransportError): ...
4343class RequestError (TransportError ): ...
4444class AuthenticationException (TransportError ): ...
4545class AuthorizationException (TransportError ): ...
46- class ElasticsearchDeprecationWarning (Warning ): ...
46+ class ElasticsearchWarning (Warning ): ...
47+
48+ ElasticsearchDeprecationWarning = ElasticsearchWarning
4749
4850HTTP_EXCEPTIONS : Dict [int , ElasticsearchException ]
Original file line number Diff line number Diff line change 2424import warnings
2525import inspect
2626
27- from elasticsearch import RequestError , ElasticsearchDeprecationWarning
27+ from elasticsearch import RequestError , ElasticsearchWarning
2828from elasticsearch .helpers .test import _get_version
2929from ...test_server .test_rest_api_spec import (
3030 YamlRunner ,
@@ -111,7 +111,7 @@ async def run_do(self, action):
111111 for k in args :
112112 args [k ] = self ._resolve (args [k ])
113113
114- warnings .simplefilter ("always" , category = ElasticsearchDeprecationWarning )
114+ warnings .simplefilter ("always" , category = ElasticsearchWarning )
115115 with warnings .catch_warnings (record = True ) as caught_warnings :
116116 try :
117117 self .last_response = await api (** args )
@@ -129,7 +129,7 @@ async def run_do(self, action):
129129 caught_warnings = [
130130 str (w .message )
131131 for w in caught_warnings
132- if w .category == ElasticsearchDeprecationWarning
132+ if w .category == ElasticsearchWarning
133133 and str (w .message ) not in allowed_warnings
134134 ]
135135
Original file line number Diff line number Diff line change 2929import warnings
3030import pytest
3131
32- from elasticsearch import TransportError , RequestError , ElasticsearchDeprecationWarning
32+ from elasticsearch import TransportError , RequestError , ElasticsearchWarning
3333from elasticsearch .compat import string_types
3434from elasticsearch .helpers .test import _get_version
3535
@@ -146,7 +146,7 @@ def run_do(self, action):
146146 for k in args :
147147 args [k ] = self ._resolve (args [k ])
148148
149- warnings .simplefilter ("always" , category = ElasticsearchDeprecationWarning )
149+ warnings .simplefilter ("always" , category = ElasticsearchWarning )
150150 with warnings .catch_warnings (record = True ) as caught_warnings :
151151 try :
152152 self .last_response = api (** args )
@@ -164,7 +164,7 @@ def run_do(self, action):
164164 caught_warnings = [
165165 str (w .message )
166166 for w in caught_warnings
167- if w .category == ElasticsearchDeprecationWarning
167+ if w .category == ElasticsearchWarning
168168 and str (w .message ) not in allowed_warnings
169169 ]
170170
You can’t perform that action at this time.
0 commit comments