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

UnboundLocalError: local variable 'i' referenced before assignment

未关闭
#463 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python, sqlalchemy
领域
databases

调研方向

从 traceback 中显示的 get_indexes 入口点开始,在 pyhive/sqlalchemy_hive.py 中通过 SQLAlchemy 表反射重现该故障。跟踪 get_indexes 返回的行,并确定为什么报告的局部变量未被赋值;当针对报告的情况进行反射时不再引发此 UnboundLocalError,即表示完成。

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

描述

Hi, I have met some errors:

  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4901, in reflect
    Table(name, self, **reflect_opts)
  File "<string>", line 2, in __new__
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 619, in __new__
    metadata._remove_table(name, schema)
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 614, in __new__
    table._init(name, metadata, *args, **kw)
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 689, in _init
    self._autoload(
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 724, in _autoload
    conn_insp.reflect_table(
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py", line 807, in reflect_table
    self._reflect_indexes(
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py", line 1035, in _reflect_indexes
    indexes = self.get_indexes(table_name, schema)
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py", line 605, in get_indexes
    return self.dialect.get_indexes(
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyhive/sqlalchemy_hive.py", line 369, in get_indexes
    for col_name, _col_type, _comment in rows[i + 1:]:
UnboundLocalError: local variable 'i' referenced before assignment
主要语言
Python
星标
1.7k
派生
545
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

dropbox/PyHive 的其他 Issue

查看 dropbox/PyHive 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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