Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

sentry_sdk/integrations/pymongo.py:151: BytesWarning: str() on a bytes instance

未关闭 适合新手
#4,782 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
mongodb, python
领域
backend, databases

调研方向

从 sentry_sdk/integrations/pymongo.py:151 的 started 入口点开始,并在可能的情况下启用 BytesWarning 运行 Python,同时检查 lsid 的转换。当 PyMongo 集成在此路径上不再发出 BytesWarning 时,即视为完成;如果 repository 提供了相关的回归测试覆盖,请添加或更新它。

由索引模型根据 Issue 内容生成。

描述

good first issue Improvement Integration: MongoDB Python Waiting for: Product Owner
How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.37.0

Steps to Reproduce

From Discord:

If run Python with the BytesWarning mode (using the -b flag), i see this messages in my logs. This probably highlights a bug. If "b'...........'" string should be there, it should probably be replaced with repr() for better readability. Otherwise, we should use decode here.
https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/pymongo.py#L151

Currently, I cannot provide a small code sample that reproduces this warning, but I can provide a part of stack trace that I generated.

  <.....>
  <.....>
  File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 1005, in collection_names
    for result in self.list_collections(session=session, nameOnly=True, **kws)
  File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 943, in list_collections
    return self.__client._retryable_read(_cmd, read_pref, session)
  File "<***>/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1617, in _retryable_read
    return func(session, server, sock_info, secondary_ok)
  File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 939, in _cmd
    return self._list_collections(
  File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 880, in _list_collections
    cursor = self._command(
  File "<***>/lib/python3.9/site-packages/pymongo/database.py", line 703, in _command
    return sock_info.command(
  File "<***>/lib/python3.9/site-packages/pymongo/pool.py", line 740, in command
    return command(
  File "<***>/lib/python3.9/site-packages/pymongo/network.py", line 155, in command
    listeners.publish_command_start(
  File "<***>/lib/python3.9/site-packages/pymongo/monitoring.py", line 1412, in publish_command_start
    subscriber.started(event)
  File "<***>/lib/python3.9/site-packages/sentry_sdk/integrations/pymongo.py", line 151, in started
    data["operation_ids"]["session"] = str(lsid)

My versions:
Python 3.9.21
pymongo==3.13.0
sentry-sdk==2.37.0

Expected Result

No BytesWarning

Actual Result

BytesWarning

主要语言
Python
星标
2.2k
派生
672
平均合并
22 小时 47 分钟
30 天内合并 PR
224

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-python 的其他 Issue

查看 getsentry/sentry-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。