Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
672 views
in Technique[技术] by (71.8m points)

macos - Python, Macports, and Buffer Problems

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...