Python、Macports 和缓冲区问题

Python, Macports, and Buffer Problems

抱歉,如果这是 post 的错误位置 - 我不清楚问题出在哪里。

当使用由 Macports 2.3.3 运行 Mac OX 10.10 构建的 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>>> 

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

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

$ 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 解决。希望尽快修复。