python / python/cpython

print _pyrepl.readline._wrapper.reader will raise error'UnixConsole' object has no attribute 'posxy'

未關閉
#139,349 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

pending stdlib topic-repl type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:
print('Before importing _pyrepl.readline:')
import sys
import os
print('PYTHON_HISTORY:', os.environ.get('PYTHON_HISTORY'))

print('\\nImporting _pyrepl.readline...')
import _pyrepl.readline

print('After importing:')
print('History length:', _pyrepl.readline.get_current_history_length())
print('Wrapper object:', _pyrepl.readline._wrapper)
print('Wrapper reader:', _pyrepl.readline._wrapper.reader)

./python.exe test.py

Before importing _pyrepl.readline:
PYTHON_HISTORY: None
\nImporting _pyrepl.readline...
After importing:
History length: 0
Wrapper object: _ReadlineWrapper(f_in=3, f_out=4, saved_history_length=-1, startup_hook=None)
Wrapper reader: Traceback (most recent call last):
  File "/Users/yihong/test.py", line 12, in <module>
    print('Wrapper reader:', _pyrepl.readline._wrapper.reader)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/reprlib.py", line 21, in wrapper
    result = user_function(self)
  File "<string>", line 41, in __repr__
  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/reprlib.py", line 21, in wrapper
    result = user_function(self)
  File "<string>", line 9, in __repr__
AttributeError: 'UnixConsole' object has no attribute 'posxy'

this exists from 3.13 to 3.15

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-139351

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用提供的腳本重現 macOS 失敗,從 _pyrepl.readline 進入點及其 _wrapper.reader 表示開始。檢查 UnixConsole 的表示路徑,並驗證列印 reader 時不再因缺少 posxy 而引發 AttributeError。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。