rollbar / pyrollbar

Error tracking and logging from Python to Rollbar
https://docs.rollbar.com/docs/python/
MIT License
213 stars 133 forks source link

Removed support for Python 2 for upcoming v1.0.0 #435

Closed danielmorell closed 10 months ago

danielmorell commented 10 months ago

Description of the change

This PR removes support for Python 2. Python 2 support is being removed in v1.0.0, and so this commit also bumps the version to v1.0.0beta0.

Doing this allowed a bunch of code to be simplified. This reduced function calls, memory allocations, generally increased performance. Some early benchmarks showed that the call stack data collection sanitization and serialization is 18.7% faster than previously.

Type of change

Related issues

None

Checklists

Development

Code review

danielmorell commented 10 months ago

The reason for https://github.com/rollbar/pyrollbar/pull/435/commits/e054667e74cd33344059eb4bbb3573367c0d04b3 is the immutables library switched from Py_TRASHCAN_SAFE_BEGIN/END to Py_TRASHCAN_BEGIN/END in v0.20. However these were not added to the CPython C API until Python v3.8 https://github.com/python/cpython/commit/351c67416ba4451eb3928fa0b2e933c2f25df1a3.

The reason for https://github.com/rollbar/pyrollbar/pull/435/commits/bfaab771c68b9a24d2e2a71cce008bde03091c15 is a KeyError was being thrown by importlib during a test run build (3.10, FASTAPI_VERSION=0.50.0 httpx==0.18.1 python-multipart==0.0.5).

======================================================================
ERROR: test_should_use_async_report_exc_info_if_any_async_handler (rollbar.test.fastapi_tests.test_middleware.ReporterMiddlewareTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/pyrollbar/pyrollbar/rollbar/test/fastapi_tests/test_middleware.py", line 30, in setUp
    importlib.reload(rollbar)
  File "/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/importlib/__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/runner/work/pyrollbar/pyrollbar/rollbar/__init__.py", line 83, in <module>
    from google.appengine.api.urlfetch import fetch as AppEngineFetch
  File "<frozen importlib._bootstrap>", line 1024, in _find_and_load
  File "<frozen importlib._bootstrap>", line 171, in __enter__
  File "<frozen importlib._bootstrap>", line 123, in acquire
KeyError: 1[406](https://github.com/rollbar/pyrollbar/actions/runs/5907121447/job/16024697120#step:13:407)63925147456

----------------------------------------------------------------------
Ran 282 tests in 0.970s

FAILED (errors=1, skipped=7)
Test failed: <unittest.runner.TextTestResult run=282 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=282 errors=1 failures=0>
Error: Process completed with exit code 1.