Commit Graph

67 Commits

Author SHA1 Message Date
Georg Brandl f3c4ad1410 typo 2006-03-08 12:24:33 +00:00
Guido van Rossum 1a5e21e033 Updates to the with-statement:
- New semantics for __exit__() -- it must re-raise the exception
  if type is not None; the with-statement itself doesn't do this.
  (See the updated PEP for motivation.)

- Added context managers to:
  - file
  - thread.LockType
  - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore}
  - decimal.Context

- Added contextlib.py, which defines @contextmanager, nested(), closing().

- Unit tests all around; bot no docs yet.
2006-02-28 21:57:43 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Michael W. Hudson 188d4366be Fix bug:
[ 1163563 ] Sub threads execute in restricted mode

basically by fixing bug 1010677 in a non-broken way.

Backport candidate.
2005-06-20 16:52:57 +00:00
Michael W. Hudson 2368b3c41b Consistently use hard tabs for indentation.
Slightly de-Fultonize two bits of C layout.

No semantic changes.
2005-06-15 12:48:40 +00:00
Michael W. Hudson 64e0814798 Add a missing incref.
Backport candidate.
2005-06-15 12:25:20 +00:00
Andrew M. Kuchling a43ece9654 Delete some vestigial code; execution will never reach the 'if' statement if args is NULL 2005-06-02 17:07:11 +00:00
Guido van Rossum 54c273c703 The error message "can't start new thread" should not end in a
newline.
2005-02-20 03:02:16 +00:00
Mark Hammond eb619bb80b Fix for [ 1010677 ] thread Module Breaks PyGILState_Ensure(),
and a test case.
When booting a new thread, use the PyGILState API to manage the GIL.
2004-08-24 22:24:08 +00:00
Jim Fulton d15dc06df0 Implemented thread-local data as proposed on python-dev:
http://mail.python.org/pipermail/python-dev/2004-June/045785.html
2004-07-14 19:11:50 +00:00
Nicholas Bastin e5662aedef Changed random calls to PyThreadState_Get() to use the macro 2004-03-24 22:22:12 +00:00
Kurt B. Kaiser a1ad5f658c Correct function name. 2003-06-16 18:51:28 +00:00
Kurt B. Kaiser a11e846135 Add interrupt_main() to thread module. 2003-06-13 21:59:45 +00:00
Guido van Rossum 24ccca1565 When an unhandled exception happens, report the repr() of the function
that was used to start the thread.  This is useful to track down the
source of the problem when there is no traceback, as can happen when a
daemon thread gets to run after Python is finialized (a new kind of
event, somehow this is now possible due to changes in Py_Finalize()).
2003-04-29 19:44:05 +00:00
Neal Norwitz 884baa1e6b --with(out)-thread is deprecated according to configure --help 2002-09-05 21:31:04 +00:00
Mark Hammond fe51c6d66e Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
for Py_Main().

Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-08-02 02:27:13 +00:00
Jeremy Hylton 938ace69a0 staticforward bites the dust.
The staticforward define was needed to support certain broken C
compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the
static keyword when it was used with a forward declaration of a static
initialized structure.  Standard C allows the forward declaration with
static, and we've decided to stop catering to broken C compilers.  (In
fact, we expect that the compilers are all fixed eight years later.)

I'm leaving staticforward and statichere defined in object.h as
static.  This is only for backwards compatibility with C extensions
that might still use it.

XXX I haven't updated the documentation.
2002-07-17 16:30:39 +00:00
Martin v. Löwis 14f8b4cfcb Patch #568124: Add doc string macros. 2002-06-13 20:33:02 +00:00
Guido van Rossum 8fdc75ba5e Lock methods acquire() and locked() now return bools. 2002-04-07 06:32:21 +00:00
Neal Norwitz ba3a16c6c3 Remove METH_OLDARGS:
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
  Convert METH_OLDARGS -> METH_NOARGS: remove args parameter
Please review.  All tests pass, but some modules don't have tests.
I spot checked various functions to try to make sure nothing broke.
2002-03-31 15:27:00 +00:00
Neal Norwitz 4632117e37 Missed change METH_OLDARGS to METH_NOARGS for two aliased functions 2002-03-26 14:52:00 +00:00
Neal Norwitz 2358425146 Missed change METH_OLDARGS to METH_NOARGS for two aliased functions 2002-03-25 21:05:50 +00:00
Neal Norwitz 3a6f97850b Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS. 2002-03-25 20:46:46 +00:00
Guido van Rossum 146483964e Patch supplied by Burton Radons for his own SF bug #487390: Modifying
type.__module__ behavior.

This adds the module name and a dot in front of the type name in every
type object initializer, except for built-in types (and those that
already had this).  Note that it touches lots of Mac modules -- I have
no way to test these but the changes look right.  Apologies if they're
not.  This also touches the weakref docs, which contains a sample type
object initializer.  It also touches the mmap test output, because the
mmap type's repr is included in that output.  It touches object.h to
put the correct description in a comment.
2001-12-08 18:02:58 +00:00
Guido van Rossum 3c28863e08 Partial patch from SF #452266, by Jason Petrone.
This changes Pythread_start_thread() to return the thread ID, or -1
for an error.  (It's technically an incompatible API change, but I
doubt anyone calls it.)
2001-10-16 21:13:49 +00:00
Andrew M. Kuchling 38300c631a Fix typo in docstring 2001-10-05 12:24:15 +00:00
Guido van Rossum 2528b19a86 Use PyThreadState_DeleteCurrent() instead of PyThreadState_Delete()
and PyEval_ReleaseThread().

This fixes SF bug #125673 PyThreadState_Delete: invalid tstate (Unix
only?).
2001-01-23 01:47:18 +00:00
Fred Drake 9c801abef3 t_bootstram(): Use PySys_WriteStderr() instead of fprintf(stderr,...).
This closes bug #117324.
2000-10-20 20:02:37 +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
Guido van Rossum 38d45b7da9 The second argument to start_new_thread() is not a tuple, as pointed
out by Curtis Jensen on c.l.py and forwarded by Fredrik Lundh.
2000-09-01 20:47:58 +00:00
Andrew M. Kuchling a1abb728bc Use METH_OLDARGS instead of numeric constant 0 in method def. tables 2000-08-03 02:34:44 +00:00
Andrew M. Kuchling e365fb8d1f Use METH_VARARGS instead of numeric constant 1 in method def. tables 2000-08-03 02:06:16 +00:00
Thomas Wouters f3f33dcf03 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
and a couple of functions that were missed in the previous batches. Not
terribly tested, but very carefully scrutinized, three times.

All these were found by the little findkrc.py that I posted to python-dev,
which means there might be more lurking. Cases such as this:

long
func(a, b)
	long a;
	long b; /* flagword */
{

and other cases where the last ; in the argument list isn't followed by a
newline and an opening curly bracket. Regexps to catch all are welcome, of
course ;)
2000-07-21 06:00:07 +00:00
Peter Schneider-Kamp 3707efef9b ANSI-fication 2000-07-10 10:03:58 +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 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 43713e5a28 Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
2000-02-29 13:59:29 +00:00
Guido van Rossum 65d5b5763c Thanks to Chris Herborth, the thread primitives now have proper Py*
names in the source code (they already had those for the linker,
through some smart macros; but the source still had the old, un-Py names).
1998-12-21 19:32:43 +00:00
Guido van Rossum 3886bb6997 Add DL_EXPORT() to all modules that could possibly be used
on BeOS or Windows.
1998-12-04 18:50:17 +00:00
Guido van Rossum 89bae99c5d Make gcc -Wall happy:
Remove unused decls of getloclock() and is_lockobject().
1998-10-07 16:35:54 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum bcc207484a Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:53:56 +00:00
Guido van Rossum d2264bb5c3 # Remove an extra blank line from a doc string. 1998-06-27 19:45:17 +00:00
Guido van Rossum 75e9fc31d3 Added doc strings. Also export LockType from the modoule, and give it
a doc string.
1998-06-27 18:21:06 +00:00
Fred Drake bebc97fcd7 t_bootstrap(): Use PyErr_ExceptionMatches(...) instead of PyErr_Occurred(...). 1998-05-28 04:35:12 +00:00
Guido van Rossum 40769dd073 Don't store the exception info from an unhandled exception in a thread
in sys.last_*; it prevents proper calling of destructors of local
variables.
1998-02-06 22:32:08 +00:00
Guido van Rossum 0cb96de269 Apply two changes, systematically:
(1) Use PyErr_NewException("module.class", NULL, NULL) to create the
    exception object.

(2) Remove all calls to Py_FatalError(); instead, return or
    ignore the errors -- the import code now checks PyErr_Occurred()
    after calling a module's init function, so it's no longer a
    fatal error for the initialization to fail.

Also did some small cleanups, e.g. removed unnecessary test for
"already initialized" from initfpectl(), and unified
initposix()/initnt().

I haven't checked this very thoroughly, so while the changes are
pretty trivial -- beware of untested code!
1997-10-01 04:29:29 +00:00
Guido van Rossum b02158efa3 Oops, one more checkin. Use the new tstate/interp interface. 1997-08-02 03:13:11 +00:00
Guido van Rossum 75aa0d6abe Use the new functions PyEval_AcquireThread() and
PyEval_ReleaseThread() (in ceval.c) to set/reset the current thread,
and at the same time acquire/release the interpreter lock.

Much saner.
1997-07-18 23:57:50 +00:00