gpt4 book ai didi

Python、Macports 和缓冲区问题

转载 作者:太空狗 更新时间:2023-10-29 21:45:56 24 4
gpt4 key购买 nike

如果发帖位置不对,我深表歉意 - 我不清楚问题出在哪里。

当使用由运行 Mac OX 10.10 的 Macports 2.3.3 构建的 Python 版本时,我看到了一些非常有趣的行为。我已经完全重新安装了 Macports,并将其复制到 iMac 和 Macbook Air 上,并创建了一个新用户以确保它与我的环境无关。上周并没有发生这种情况,在此期间的某个时候,情况发生了相当大的变化。

一切正常,直到我调用 Python。

$ python
Python 3.4.3 (default, Aug 26 2015, 18:29:14)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
>>> 2
^D>>>

>>> 在输入结果之前打印,也在我告诉 Python 使用 Control-D 退出之后打印。

此时,终端不再打印所有输入(在 iTerm2 中也是如此)。如果我输入 echo 'this is ouput;输入是隐藏的” 我唯一看到的是:

$ this is ouput; input is hidden

如果我重新调用解释器,事情会变得更奇怪。

$ Python 3.4.3 (default, Aug 26 2015, 18:29:14) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
>>> 2
^C
KeyboardInterrupt
>>> ^D
>>> exit()
>>> $

正在打印 Control-C(不是标准),而 Control-D 只是被忽略了 - 我必须键入 exit 才能退出提示。

使用 reset 重置终端可以解决所有问题,但与 Python 解释器交互仍然是一场噩梦。

我可以在 Python 2.7、3.3、3.4 和 3.5 中复制这种行为,这让我相信我在错误的地方寻找问题。

Python 的打包安装(来自 Python 网站)工作正常,不会出现这种行为。

$ python3
Python 3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 11:00:19)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
2
>>>
KeyboardInterrupt
>>> ^D

我被难住了。我完全不确定在哪里可以就此问题寻求帮助。我该如何着手找出问题所在?

我打开了一个 bug report on the Macport Trac,然后才意识到这个问题在这里可能会更好。

最佳答案

https://trac.macports.org/ticket/48807

似乎是一个 libedit/curses 交互。编辑端口文件以使用 readline 解决。希望尽快修复。

关于Python、Macports 和缓冲区问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32578009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com