Session.from_id
unexpectedly suppresses deprecation warnings.
#1886
Labels
bug
Something isn't working
Session.from_id
unexpectedly suppresses deprecation warnings.
#1886
Desribe the bug
When
Session.from_id
is called, internally it callscls(service, backend)
to create aSession
instance, withbackend
set to a string. Unless it's intentional to suppress warnings fromSession.__init__
when called fromSession.from_id
, this should raise two deprecation warnings (one for passing a service and one for backend as a string), but raises none.Steps to reproduce
First, create a session instance and grab the ID:
Next, regenerate the session from its ID:
Expected behavior
Deprecation warnings raised for service and backend as a string, as for example when I use
Session.__init__
directly:Suggested solutions
Not sure how to solve the problem in its entirety, but part of the issue seems to be how
issue_deprecation_msg
is used inSession.__init__
. As used there, thestacklevel
passed towarnings.warn
is 3 (default value of 2, plus one), which works when a session is created via__init__
directly. In that case, the stack is:issue_deprecation_msg
->Session.__init__
-> caller. But whenSession.from_id
is used, the stack is too deep:issue_deprecation_msg
->Session.__init__
->Session.from_id
-> caller.Additional Information
The text was updated successfully, but these errors were encountered: