Commit Graph

42 Commits

Author SHA1 Message Date
Victor Stinner 08563d904d Issue #12016: my_fgets() now always clears errors before calling fgets(). Fix
the following case: sys.stdin.read() stopped with CTRL+d (end of file),
raw_input() interrupted by CTRL+c.
2011-05-30 23:44:13 +02:00
Victor Stinner 2c585f607e (Merge 3.1) Issue #1195: Fix input() if it is interrupted by CTRL+d and then
CTRL+c, clear the end-of-file indicator after CTRL+d.
2011-05-10 00:22:59 +02:00
Victor Stinner 5de51ac4c0 (Merge 3.1) Issue #11650: PyOS_StdioReadline() retries fgets() if it was
interrupted (EINTR), for example if the program is stopped with CTRL+z on Mac
OS X. Patch written by Charles-Francois Natali.
2011-04-09 16:09:08 +02:00
Antoine Pitrou c83ea137d7 Untabify C files. Will watch buildbots. 2010-05-09 14:46:46 +00:00
Andrew M. Kuchling b64d61369a #2560: remove an unnecessary 'for' loop from my_fgets() in Parser/myreadline.c.
Noted by Joseph Armbruster; patch by Jessica McKellar.

The original code was 'for (;;) {...}', where ... ended
with a 'return -2' statement and did not contain a 'break' or 'continue'
statement.  Therefore, the body of the loop is always executed once.

Once upon a time there was a 'continue' in the loop, but it was removed in
rev36346, committed by mwh on Wed Jul 7 17:44:12 2004.
2010-02-22 22:48:41 +00:00
Neal Norwitz 08062d6665 As discussed on python-dev, really fix the PyMem_*/PyObject_* memory API
mismatches.  At least I hope this fixes them all.

This reverts part of my change from yesterday that converted everything
in Parser/*.c to use PyObject_* API.  The encoding doesn't really need
to use PyMem_*, however, it uses new_string() which must return PyMem_*
for handling the result of PyOS_Readline() which returns PyMem_* memory.

If there were 2 versions of new_string() one that returned PyMem_*
for tokens and one that return PyObject_* for encodings that could
also fix this problem.  I'm not sure which version would be clearer.
This seems to fix both Guido's and Phillip's problems, so it's good enough
for now.  After this change, it would be good to review Parser/*.c
for consistent use of the 2 memory APIs.
2006-04-11 08:19:15 +00:00
Anthony Baxter 114900298e Fix the code in Parser/ to also compile with C++. This was mostly casts for
malloc/realloc type functions, as well as renaming one variable called 'new'
in tokensizer.c. Still lots more to be done, going to be checking in one
chunk at a time or the patch will be massively huge. Still compiles ok with
gcc.
2006-04-11 05:39:14 +00:00
Neal Norwitz 2c4e4f9839 SF patch #1467512, fix double free with triple quoted string in standard build.
This was the result of inconsistent use of PyMem_* and PyObject_* allocators.
By changing to use PyObject_* allocator almost everywhere, this removes
the inconsistency.
2006-04-10 06:42:25 +00:00
Michael W. Hudson e3afc598bc In a threads-disabled build, typing Ctrl-C into a raw_input() crashed,
because (essentially) I didn't realise that PY_BEGIN/END_ALLOW_THREADS
actually expanded to nothing under a no-threads build, so if you somehow
NULLed out the threadstate (e.g. by calling PyThread_SaveThread) it would
stay NULLed when you return to Python.  Argh!

Backport candidate.
2005-04-07 10:11:19 +00:00
Michael W. Hudson 2384990603 PyThreadState_Swap(NULL) didn't do what I thought it did. Fixes
[ 987287 ] Python 2.4a1, interpreter hanging on Keyboard Interrupt
2004-07-08 15:28:26 +00:00
Tim Peters b7e898a0e2 "#if WITH_THREAD" is incorrect; must be #ifdef instead; WITH_THREAD
isn't always set to an integer value when it's defined.
2004-07-07 20:42:07 +00:00
Michael W. Hudson 30ea2f223f This closes patch:
[ 960406 ] unblock signals in threads

although the changes do not correspond exactly to any patch attached to
that report.

Non-main threads no longer have all signals masked.

A different interface to readline is used.

The handling of signals inside calls to PyOS_Readline is now rather
different.

These changes are all a bit scary!  Review and cross-platform testing
much appreciated.
2004-07-07 17:44:12 +00:00
Jack Jansen fb2765666f Getting rid of support for the ancient Apple MPW compiler. 2003-11-19 15:24:47 +00:00
Martin v. Löwis c16f3bd8a3 Patch #708495: Port more stuff to OpenVMS. 2003-05-03 09:14:54 +00:00
Martin v. Löwis 566f6afe9a Patch #512981: Update readline input stream on sys.stdin/out change. 2002-10-26 14:39:10 +00:00
Mark Hammond 2f10cb8fa5 Fix bug 439992 - [win32] KeyboardInterrupt Not Caught.
This gets us closer to consistent Ctrl+C behaviour on NT and Win9x.  NT now reliably generates KeyboardInterrupt exceptions for NT when a file IO operation was aborted.  Bugfix candidate
2002-07-14 23:12:29 +00:00
Guido van Rossum 48a680c097 RISCOS changes by dschwertberger. 2001-03-02 06:34:14 +00:00
Fred Drake d5fadf75e4 Rationalize use of limits.h, moving the inclusion to Python.h.
Add definitions of INT_MAX and LONG_MAX to pyport.h.
Remove includes of limits.h and conditional definitions of INT_MAX
and LONG_MAX elsewhere.

This closes SourceForge patch #101659 and bug #115323.
2000-09-26 05:46:01 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Thomas Wouters 23c9e0024a Mass ANSIfication.
Work around intrcheck.c's desire to pass 'PyErr_CheckSignals' to
'Py_AddPendingCall' by providing a (static) wrapper function that has the
right number of arguments.
2000-07-22 19:20:54 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Jack Jansen 41aa8e523d Include limits.h if we have it. 2000-07-03 21:39:47 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Guido van Rossum 6da3434e03 Trent Mick: familiar simple Win64 patches 2000-06-28 22:00:02 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum 80c7bcf667 The previous fix was still broken; the Py_END_ALLOW_THREADS macro was
never executed because of a return statement.  Sigh.
1998-08-29 16:03:27 +00:00
Guido van Rossum 8efa47b63e We now assume that PyOS_Readline() is called with the interpreter lock
held.  It releases the lock around the call to the function pointed to by
PyOS_ReadlineFunctionPointer (default PyOS_StdioReadline()).
1998-08-27 19:43:43 +00:00
Guido van Rossum 44620646fd Renamed Py_input_hook to PyOS_InputHook.
Also cleaned out some CR's left by the VC++ editor.
1997-08-11 18:57:29 +00:00
Guido van Rossum 717c6f95be Move GNU readline interface to ../Modules/readline.c.
Add Py_input_hook (used by _tkinter and perhaps Gist).
1997-08-05 21:28:12 +00:00
Guido van Rossum fa658ce03d Remove two unised variables. 1997-04-09 18:19:39 +00:00
Guido van Rossum fbd64c8790 Restructured quite a bit, hopefully Lee Busby will find this useful.
Also grandly renamed.

Here's the new interface:

When WITH_READLINE is defined, two functions are defined:

  - PyOS_GnuReadline (what used to be my_readline() with WITH_READLINE)
  - PyOS_ReadlineInit (for Dave Ascher)

Always, these functions are defined:

  - PyOS_StdioReadline (what used to be my_readline() without WITH_READLINE)
  - PyOS_Readline (the interface used by tokenizer.c and [raw_]input().

There's a global function pointer PyOS_ReadlineFunctionPointer,
initialized to NULL.  When PyOS_Readline finds this to be NULL, it
sets it to either PyOS_GnuReadline or PyOS_StdioReadline depending on
which one makes more sense (i.e. it uses GNU only if it is defined
*and* stdin is indeed a tty device).

An embedding program that has its own wishes can set the function
pointer to a function of its own design.  It should take a char*
prompt argument (which may be NULL) and return a string *ending in a
\n character* -- or "" for EOF or NULL for a user interrupt.

--Guido van Rossum (home page: http://www.python.org/~guido/)
1997-02-18 21:53:32 +00:00
Guido van Rossum fd8a393086 Make gcc -Wall happy 1996-12-02 18:27:33 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum 0bc253dba7 Explicitly call rl_initialize().
Set rl_readline_name to python.
Move extern decls to more logical point.
1996-09-13 04:09:26 +00:00
Guido van Rossum 7cf1fcf347 Always include config.h 1996-08-19 22:12:39 +00:00
Guido van Rossum 9ea917ebaa Only define PyOS_ReadlineInit if WITH_READLINE defined. 1996-05-24 20:44:12 +00:00
Guido van Rossum adf876938a Separate readline initialization into new function PyOS_ReadlineInit().
For Dave Ascher's readline extensions.
1996-04-09 02:45:31 +00:00
Guido van Rossum c7fea2feed add sigrelse() call for SunOS 4.1; add some fflush() calls 1996-01-12 01:30:55 +00:00
Guido van Rossum b9f8d6e54d Added 1995 to copyright message. 1995-01-04 19:08:09 +00:00
Guido van Rossum b6775db241 Merge alpha100 branch back to main trunk 1994-08-01 11:34:53 +00:00
Guido van Rossum 6fa6343f0e None 1993-12-24 10:36:57 +00:00