_ssl_compat.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. _ssl_compat.py
  3. websocket - WebSocket client library for Python
  4. Copyright 2024 engn33r
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. """
  15. __all__ = [
  16. "HAVE_SSL",
  17. "ssl",
  18. "SSLError",
  19. "SSLEOFError",
  20. "SSLWantReadError",
  21. "SSLWantWriteError",
  22. ]
  23. try:
  24. import ssl
  25. from ssl import SSLError, SSLEOFError, SSLWantReadError, SSLWantWriteError
  26. HAVE_SSL = True
  27. except ImportError:
  28. # dummy class of SSLError for environment without ssl support
  29. class SSLError(Exception):
  30. pass
  31. class SSLEOFError(Exception):
  32. pass
  33. class SSLWantReadError(Exception):
  34. pass
  35. class SSLWantWriteError(Exception):
  36. pass
  37. ssl = None
  38. HAVE_SSL = False