Python, Macports, and Buffer Problems

怎甘沉沦 提交于 2019-11-27 06:52:06

问题


Apologies if this is the wrong place to post this - I'm unclear what the problem is.

When using versions of Python built by Macports 2.3.3 running Mac OX 10.10, I'm seeing some really funny behavior. I've fully re-installed Macports, and replicated this on an iMac as well as a Macbook Air, and created a new user to make sure it wasn't something about my environment. This wasn't happening last week, and sometime in the interim something changed pretty drastically.

Everything works fine until I invoke 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>>> 

The >>> is being printed before the result of the input, but also after I tell Python to exit with Control-D.

At this point, all input ceases to be printed in the terminal (the same happens in iTerm2). If I type echo 'this is ouput; input is hidden' the only thing I see is:

$ this is ouput; input is hidden

Things get even weirder if I re-invoke the interpreter.

$ 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 is being printed (not the norm), and control-D is simply being ignored - I have to type exit to get out of the prompt.

Resetting the terminal with reset makes all of the problems go away, but interacting with the Python interpreter is still a nightmare.

I can replicate this behavior in Python 2.7, 3.3, 3.4, and 3.5, which leads me to believe I'm looking for the problem in the wrong place.

The packaged installs of Python (from the Python website) work fine, and do not exhibit this behavior.

$ 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

I'm stumped. I'm not at all sure where to ask for help for this issue. How do I go about figuring out what the problem is?

I opened a bug report on the Macport Trac before realizing the question might fare better here.


回答1:


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

Seems to be a libedit / curses interaction. Editing the portfile to use readline resolves. Hopefully fixed soon.



来源:https://stackoverflow.com/questions/32578009/python-macports-and-buffer-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!