getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

'encoding' cannot be specified in python 3 #1365

Closed yangjiel closed 4 years ago

yangjiel commented 4 years ago

https://github.com/getsentry/raven-python/blob/285b257cf386bfac78f6fe334c9044af65f98561/raven/utils/json.py#L59-L63

1155

I am still experiencing the issue above. In Python 3, the argument encoding is no longer supported. The error message is:

Traceback (most recent call last):
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/handlers/logging.py", line 97, in emit
    return self._emit(record)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/contrib/django/handlers.py", line 33, in _emit
    return super(SentryHandler, self)._emit(record, request=request)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/handlers/logging.py", line 192, in _emit
    **kwargs)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/contrib/django/client.py", line 303, in capture
    result = super(DjangoClient, self).capture(event_type, **kwargs)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/base.py", line 653, in capture
    self.send(**data)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/base.py", line 748, in send
    message = self.encode(data)
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/base.py", line 790, in encode
    return zlib.compress(json.dumps(data).encode(\'utf8\'))
  File "/home/ubuntu/catalina/env/lib/python3.6/site-packages/raven/utils/json.py", line 63, in dumps
    return json.dumps(value, cls=BetterJSONEncoder, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
TypeError: __init__() got an unexpected keyword argument 'encoding'