Using deprecated classes cause a crash
See original GitHub issueDescribe the bug
When using a deprecated old name for a class which has been renamed, locust crashes.
Expected behavior
A deprecation warning should be displayed instead, and the original behavior still executed. The user should still have the option to either crash on, notify about or silently ignore usages of deprecated functionality.
For instance, this should by default still work and log a deprecation warning:
class MyLocust(HttpLocust):
...
This should be implemented using warnings.warn('<message>', DeprecationWarning)
as shown in Python documentation.
Actual behavior
Locust raises a DeprecationWarning
exception.
Steps to reproduce
$ python
>>> from locust import HttpLocust
>>> class X(HttpLocust): ...
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "locust/util/deprecation.py", line 23, in __new__
raise DeprecationWarning(deprecation_message)
DeprecationWarning: The HttpLocust class has been renamed to HttpUser in version 1.0. For more info see: https://docs.locust.io/en/latest/changelog.html#changelog-1-0
Environment
- OS: Fedora 30
- Python version: 3.7
- Locust version: 1.0.1
See also:
- Software deprecation on Wikipedia
- warnings – Warning control in Python documentation
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Deprecation while running an app in Android Studio
I am working in an Application to change and show the date but got a problem and the app crashes when the button...
Read more >How a deprecated function can crash WordPress site while ...
It is said that deprecated functions used in plugins & themes can crash a wordress website while upgrading to newer version, ...
Read more >How and When to Deprecate APIs
Starting with J2SE 5.0, you deprecate a class, method, or field by using the @Deprecated annotation. Additionally, you can use the @deprecated Javadoc...
Read more >Deprecated
An element may be deprecated for any of several reasons, for example, its usage is likely to lead to errors; it may be...
Read more >Understand SDK Dependencies in Google Maps Platform
When a version of the SDK is deprecated, it will soon be decommissioned. Building with a dependency on a decommissioned SDK version may...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your replies @cyberw and @heyman,
If the old class names are obsoleted, the exception should be different. Maybe an
ImportError
with an extended message explaining the rename?As said,
DeprecationWarning
isn’t meant to be raised as an exception which terminates execution, but to be used together withwarnings.warn()
.As you can see e.g. from the Software deprecation article on Wikipedia, “deprecation” really means that a feature is going to be removed while it still works in the version you’re using.
Anyway, we can easily change the class name in our code. I just wanted to point out this confusion for the benefit of other users who hit the issue.
@akaihola Ah, you’re right. My mental definition of “deprecation” was a bit off apparently. Even though the Wikipedia article do give some support for my (previous) understanding of it (that it could also mean something that was obsolete) in a single sentence without citation 😄:
Anyway, I’ve now changed (c4bdbd30a52273498a400c19c2ef3672f9fd46ed) so that we’re raising an ImportError instead.
Thanks for reporting it!