Commit graph

2229 commits

Author SHA1 Message Date
Neal Norwitz 57071ce545 Oops, "=" is not a comparison operator 2005-10-21 05:15:07 +00:00
Neal Norwitz 5f5153e871 Fix some mods that got dropped from the AST merge 2005-10-21 04:28:38 +00:00
Jeremy Hylton 3e0055f8c6 Merge ast-branch to head
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
2005-10-20 19:59:25 +00:00
Neal Norwitz 708e51a6b1 Fix SF bug #976608, Unhelpful error message when mtime of a module is -1
Will backport.
2005-10-03 04:48:15 +00:00
Neal Norwitz 11bd119226 SF bug #887946, segfault if redirecting directory
Also provide a warning if a directory is passed on the command line.
Add minimal command line test.

Will backport.
2005-10-03 00:54:56 +00:00
Neal Norwitz 40d3781416 - Fix segfault with invalid coding.
- SF Bug #772896, unknown encoding results in MemoryError, which is not helpful

I will only backport the segfault fix.  I'll let Anthony decide if he wants
the other changes backported.  I will do the backport if asked.
2005-10-02 01:48:49 +00:00
Michael W. Hudson ce7da6c5e9 Forward port bugfix:
[ 1307978 ] Unsatisfied symbols: _PyGILState_NoteThreadState (code)

(note that this only happens in a threads-disabled build).
2005-09-30 08:20:24 +00:00
Raymond Hettinger 6b27cda643 Convert iterator __len__() methods to a private API. 2005-09-24 21:23:05 +00:00
Armin Rigo 1c2d7e5363 clean-up tracing of C functions. In particular, don't call the trace func
with an exception currently set!
2005-09-20 18:34:01 +00:00
Armin Rigo 71d7e704b8 Removed a check "if (args != NULL)" which is always True and makes no sense. 2005-09-20 18:13:03 +00:00
Armin Rigo a6eb56cf46 Don't call memset() before checking that the ptr is not NULL. 2005-09-20 18:07:47 +00:00
Georg Brandl 6953772d90 patch [ 1119423 ] python -c readlink()s and stat()s '-c' 2005-09-15 13:00:34 +00:00
Georg Brandl 77c85e63b4 bug [ 868706 ] Calling builtin function 'eval' from C causes seg fault. 2005-09-15 10:46:13 +00:00
Georg Brandl 6dd14619bb Complete format code support in getargs.c::skipitem(), which is called when
evaluating keyword arguments.
2005-09-14 19:29:53 +00:00
Guido van Rossum 8ee3e5aa93 - Changes donated by Elemental Security to make it work on AIX 5.3
with IBM's 64-bit compiler (SF patch #1284289).  This also closes SF
  bug #105470: test_pwd fails on 64bit system (Opteron).
2005-09-14 18:09:42 +00:00
Guido van Rossum 539c662f10 - Changes donated by Elemental Security to make it work on HP-UX 11 on
Itanium2 with HP's 64-bit compiler (SF patch #1225212).
2005-09-14 17:49:54 +00:00
Georg Brandl 0c55f2946b Patch #1290454: Fix reload() error message when parent module is not in
sys.modules.
2005-09-14 06:56:20 +00:00
Georg Brandl 99d7e4e8eb Whitespace normalization. 2005-08-31 22:21:15 +00:00
Georg Brandl 02c42871cf Disallow keyword arguments for type constructors that don't use them.
(fixes bug #1119418)
2005-08-26 06:42:30 +00:00
Martin v. Löwis d35edda682 Forward UnicodeDecodeError into SyntaxError for source encoding errors.
Will backport to 2.4.
2005-08-24 08:39:24 +00:00
Raymond Hettinger a710b331da SF bug #1242657: list(obj) can swallow KeyboardInterrupt
Fix over-aggressive PyErr_Clear().  The same code fragment appears in
various guises in list.extend(), map(), filter(), zip(), and internally
in PySequence_Tuple().
2005-08-21 11:03:59 +00:00
Raymond Hettinger beb3101b05 Add a C API for sets and frozensets. 2005-08-16 03:47:52 +00:00
Barry Warsaw e2eca0b709 Port from the Python 2.4 branch, patches for SF bug # 900092,
hotshot.stats.load.
2005-08-15 18:14:19 +00:00
Tim Peters ea9dcdc062 com_yield_expr(): Squash new compiler wng about unreferenced local. 2005-08-03 18:33:05 +00:00
Phillip J. Eby 0d6615fd29 PEP 342 implementation. Per Guido's comments, the generator throw()
method still needs to support string exceptions, and allow None for the
third argument.  Documentation updates are needed, too.
2005-08-02 00:46:46 +00:00
Raymond Hettinger d794666048 * Improve code for the empty frozenset singleton:
- Handle both frozenset() and frozenset([]).
  - Do not use singleton for frozenset subclasses.
  - Finalize the singleton.
  - Add test cases.
* Factor-out set_update_internal() from set_update().  Simplifies the
  code for several internal callers.
* Factor constant expressions out of loop in set_merge_internal().
* Minor comment touch-ups.
2005-08-01 21:39:29 +00:00
Georg Brandl e35b657efd Fix cleanup DECREF logic in builtin_filter function. 2005-07-19 22:20:20 +00:00
Georg Brandl 9a3240e8e6 bug 1234979 addition 2005-07-09 15:26:33 +00:00
Georg Brandl af410b510d bug [ 1234979 ] Lock.acquire treats only 1 as True 2005-07-08 22:26:13 +00:00
Brett Cannon c9371d4a1b Fix signedness of various char variables to stop causing a warning under gcc 4. 2005-06-25 08:23:41 +00:00
Brett Cannon 55fa66dd45 Add comments about PyThreadState and the usage of its fields. 2005-06-25 07:07:35 +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 867f2d45cd You can have more than one thread state for a thread if they
correspond to different interpreters (I hope, please revert if this is
wrong :).
2005-06-16 11:35:00 +00:00
Michael W. Hudson f2ca5af439 Fix bug
[ 1180997 ] lax error-checking in new-in-2.4 marshal stuff

which I'd assigned to Martin, but actually turned out to be easy to fix.

Also, a test.
2005-06-13 18:28:46 +00:00
Michael W. Hudson 01fca11080 Remove extraneous format character from PyArg_ParseTuple call in
marshal_loads.

Bugfix candidate.
2005-06-13 17:50:18 +00:00
Michael W. Hudson 6d6917be00 Fix a couple of crashing-on-malformed data marshal bugs. 2005-06-03 15:17:16 +00:00
Michael W. Hudson df88846ebc This is my patch:
[ 1180995 ] binary formats for marshalling floats

Adds 2 new type codes for marshal (binary floats and binary complexes), a
new marshal version (2), updates MAGIC and fiddles the de-serializing of
code objects to be less likely to clobber the real reason for failing if
it fails.
2005-06-03 14:41:55 +00:00
Michael W. Hudson ba283e2b7f This is my patch:
[ 1181301 ] make float packing copy bytes when they can

which hasn't been reviewed, despite numerous threats to check it in
anyway if noone reviews it.  Please read the diff on the checkin list,
at least!

The basic idea is to examine the bytes of some 'probe values' to see if
the current platform is a IEEE 754-ish platform, and if so
_PyFloat_{Pack,Unpack}{4,8} just copy bytes around.

The rest is hair for testing, and tests.
2005-05-27 15:23:20 +00:00
Jason Tishler 7961aa6135 Patch #1197318: Cygwin case-sensitive import patch
A problem regarding importing symlinked modules was recently reported on the
Cygwin mailing list:

    http://cygwin.com/ml/cygwin/2005-04/msg00257.html

The following test case demonstrates the problem:

$ ls -l
total 1
lrwxrwxrwx    1 jt       None            6 Apr 23 13:32 bar.py -> foo.py
-rw-r--r--    1 jt       None           24 Apr 18 20:13 foo.py

$ python -c 'import bar'
Traceback (most recent call last):
File "<string>", line 1, in ?
ImportError: No module named bar

Since Cygwin's case_ok() uses a modified version of the Windows's version, the
symlinked bar module actually resolves to file foo.py instead of bar.py. This
obviously causes the matching code to fail (regardless of case).

The patch fixes this problem by making Cygwin use the Mac OS X case_ok()
instead of a modified Window's version.
2005-05-20 00:56:54 +00:00
Michael W. Hudson 774479c68b Fix:
[ 1176893 ] Readline segfault

by unsilly-ing PyGILState_Release().

Backport candidate.
2005-04-18 08:46:17 +00:00
Hye-Shik Chang b6fa2814f7 Make a handy macro, Py_DEFAULT_RECURSION_LIMIT to allow to define
a default value of recursion limit from build systems.  1000 levels
are still too high for some 64bit systems.
2005-04-04 15:49:02 +00:00
Michael W. Hudson 5253c30791 I suppose a bug report or even a fix would be a better response, but
commit a yelp about a noted flaw the error messages for METH_KEYWORDS
functions under some circumstances.
2005-03-30 16:41:55 +00:00
Anthony Baxter 12b6f6cac7 Move exception finalisation later in the shutdown process - this
fixes the crash seen in bug #1165761
2005-03-29 13:36:16 +00:00
Martin v. Löwis 8b8fb3db5a Add 0 to _POSIX_SEMAPHORES. Will backport to 2.4. 2005-03-28 12:34:20 +00:00
Anthony Baxter 19b2369d42 Patch #1163249 - Correctly handle _POSIX_SEMAPHORES == -1 to mean no
support for posix semaphores.
2005-03-16 04:15:07 +00:00
Raymond Hettinger 96229b1918 Add two new functions, any() and all(). 2005-03-11 06:49:40 +00:00
Brett Cannon 409d8f2ebd Allow classes to be defined with empty parentheses. This means that
``class C(): pass`` is no longer a syntax error.
2005-03-05 06:47:57 +00:00
Martin v. Löwis 96d743ec8b Patch #1115086: support PY_LONGLONG in structmember. 2005-03-03 23:00:26 +00:00
Martin v. Löwis 6ce7ed23d0 Revert previous checkin on getargs 'L' code. Try to convert all
numbers in PyLong_AsLongLong, and update test suite accordingly.
Backported to 2.4.
2005-03-03 12:26:35 +00:00
Martin v. Löwis 4bf108d74f Patch #802188: better parser error message for non-EOL following line cont. 2005-03-03 11:45:45 +00:00
Martin v. Löwis ff232d7230 Clear internal call error in 'L' format. Fixes #723201.
Backported to 2.4.
2005-03-03 09:24:38 +00:00
Brett Cannon 5dc8ced4a8 Silence a gcc warning about putting in parentheses around && expressions mixed
with || expressions.  Also clarifies intend of 'if' conditional.
2005-03-03 07:01:48 +00:00
Raymond Hettinger e63a078635 Preserve sign of -0.0 when result is run through marshal. 2005-02-23 13:37:55 +00:00
Raymond Hettinger 07359a7fed Document how the pattern recognizer keeps all of its references in bounds.
Add a test in case the underlying assumptions ever change (i.e. the
compiler starts generating code blocks that are not punctuated by
RETURN_VALUE).
2005-02-21 20:03:14 +00:00
Raymond Hettinger 80121491e0 Teach the peepholer to fold unary operations on constants.
Afterwards, -0.5 loads in a single step and no longer requires a runtime
UNARY_NEGATIVE operation.
2005-02-20 12:41:32 +00:00
Raymond Hettinger b615bf0681 Remove the set conversion which didn't work with: [] in (0,) 2005-02-10 01:42:32 +00:00
Raymond Hettinger 5e547969f8 Have set conversion replace existing constant if not used elsewhere. 2005-02-09 21:24:51 +00:00
Guido van Rossum 0f1f63cf07 Close the discussion in SF bug 1069160. 2005-02-08 02:07:57 +00:00
Raymond Hettinger 7fcb7869ba Adopt Skip's idea to optimize lists of constants in the context
of a "in" or "not in" test.
2005-02-07 19:32:38 +00:00
Raymond Hettinger a164574937 Transform "x in (1,2,3)" to "x in frozenset([1,2,3])".
Inspired by Skip's idea to recognize the throw-away nature of sequences
in this context and to transform their type to one with better performance.
2005-02-06 22:05:42 +00:00
Jeremy Hylton c9add9a483 Fix bug that allowed future statements virtually anywhere in a module.
If we exit via the break here, we need to set ff_last_lineno or
FUTURE_POSSIBLE() will remain true.  The bug affected statements
containing a variety of expressions, but not all expressions.  It has
been present since Python 2.2.
2005-02-04 18:38:43 +00:00
Martin v. Löwis 13a1fde4da Partially revert #1074011; don't try to fflush stdin.
Backported to 2.3 and 2.4.
2005-01-27 18:56:16 +00:00
Raymond Hettinger 9feb267caf Do not fold a constant if a large sequence will result.
Saves space in the presence of code like: (None,)*10000
2005-01-26 12:50:05 +00:00
Anthony Baxter c560a00966 happy new year! (on the trunk) 2005-01-25 12:40:01 +00:00
Martin v. Löwis 8e3ca8af26 Flush std{in,out,err} before closing it. Fixes #1074011.
Will backport to 2.4 and 2.3.
2005-01-23 09:41:49 +00:00
Michael W. Hudson 75eabd2944 Change the name of the macro used by --with-tsc builds to the less
inscrutable READ_TIMESTAMP.
2005-01-18 15:56:11 +00:00
Michael W. Hudson 969f485cba -X died some time ago; remove a tiny bit of associated cruft. 2005-01-18 15:26:11 +00:00
Andrew MacIntyre 2bea474476 make thread stack size compile-time tunable on OS/2 2005-01-17 12:16:36 +00:00
Fred Drake d7c27bef52 remove unused variable 2005-01-12 16:00:55 +00:00
Raymond Hettinger a422c34b70 SF 1098985: set objects cannot be marshalled 2005-01-11 03:03:27 +00:00
Skip Montanaro c9a4762bd6 comment tweak 2005-01-08 21:58:58 +00:00
Armin Rigo 664b43b3f4 Re-running python with/without the -Qnew flag uses incorrectly optimized
bytecodes from the previously saved .pyc files.  Fixed by disabling the static
optimization of BINARY_DIVIDE between two constants.
2005-01-07 18:10:51 +00:00
Raymond Hettinger c34f8673a1 Teach the peephole optimizer to fold simple constant expressions. 2005-01-02 06:17:33 +00:00
Armin Rigo 2ccea17856 Any call to marshal.dumps() with the new optional argument 'version' just
immediately segfaults, due to a typo!  This was obviously never tested...
Added a test for it, and also fixed the documentation.
2004-12-20 12:25:57 +00:00
Brett Cannon 9e635cf3ae Put parentheses around the assignment in the 'while' loop conditional
expression in min_max() to shut gcc up.
2004-12-07 00:25:35 +00:00
Raymond Hettinger 3b0c7c20a1 SF patch #1077353: add key= argument to min and max
(First draft of patch contributed by Steven Bethard.)
2004-12-03 08:30:39 +00:00
Kurt B. Kaiser 4c79a83e0c Hye-Shik Chang's fix for Bug 875692.
Improve signal handling, especially when using threads, by forcing an early
re-execution of PyEval_EvalFrame() "periodic" code when things_to_do is not
cleared by Py_MakePendingCalls().

M Misc/NEWS
M Python/ceval.c
2004-11-23 18:06:08 +00:00
Tim Peters fb1ffb0ebb SF bug 1061968: threads: segfault or Py_FatalError at exit
PyGILState_Ensure():  The fix in 2.4a3 for bug 1010677 reintroduced thread
shutdown race bug 225673.  Repaired by (once again) ensuring the GIL is
held whenever deleting a thread state.

Alas, there's no useful test case for this shy bug.  Four years ago, only
Guido could provoke it, on his box, and today only Armin can provoke it
on his box.  I've never been able to provoke it (but not for lack of
trying!).

This is a critical fix for 2.3.5 too, since the fix for 1010677 got
backported there already and so also reintroduced 225673.  I don't intend to
backport this fix.  For whoever (if anyone) does, there are other thread
fixes in 2.4 that need backporting too, and I bet they need to happen first
for this patch to apply cleanly.
2004-11-08 04:30:21 +00:00
Jeremy Hylton 16b047904c SF patch 1025636: Check for NULL returns in compile.c:com_import_stmt
There is no test for this change, because there is no way to provoke memory errors on demand.  Test suite passes, though.
2004-11-07 14:04:00 +00:00
Raymond Hettinger ec6eb369d5 SF patch #1035255: Remove CoreServices / CoreFoundation dependencies in core
(Contributed by Bob Ippolito.)

This patch trims down the Python core on Darwin by making it
independent of CoreFoundation and CoreServices. It does this by:

Changed linker flags in configure/configure.in
Removed the unused PyMac_GetAppletScriptFile
Moved the implementation of PyMac_StrError to the MacOS module
Moved the implementation of PyMac_GetFullPathname to the
Carbon.File module
2004-11-05 07:02:59 +00:00
Raymond Hettinger 5dec096e6a Maintain peepholer's cumlc invariant by updating the running total
everytime a LOAD_CONSTANT is encountered, created, or overwritten.

Added two tests to cover cases affected by the patch.
2004-11-02 04:20:10 +00:00
Raymond Hettinger 099ecfbec9 Simplify and future proof NOP counting in the peepholer.
No longer assumes that the input is NOP free.
2004-11-01 15:19:11 +00:00
Armin Rigo d7bcf4deb1 Fixed a comment and added another one. 2004-10-30 21:08:59 +00:00
Raymond Hettinger effb3931ea Adopt some peepholer suggestions from Armin Rigo:
* Use simpler, faster two pass algorithm for markblocks().
* Free the blocks variable if not NULL and exiting without change.
* Verify that the rest of the compiler has not set an exception.
* Make the test for tuple of constants less restrictive.
* Embellish the comment for chained conditional jumps.
2004-10-30 08:55:08 +00:00
Raymond Hettinger 23109ef11e SF bug #1053819: Segfault in tuple_of_constants
Peepholer could be fooled into misidentifying a tuple_of_constants.
Added code to count consecutive occurrences of LOAD_CONST.
Use the count to weed out the misidentified cases.
Added a unittest.
2004-10-26 08:59:14 +00:00
Raymond Hettinger 9047c8f73d SF bug #1048870: call arg of lambda not updating 2004-10-24 00:10:06 +00:00
Anthony Baxter 9ceaa72ebe Patch #975056 - fixes for restartable signals on *BSD. In addition,
a few remaining calls to signal() were converted to PyOS_setsig().
2004-10-13 14:48:50 +00:00
Tim Peters 7f468f29f4 SF patch 1044089: New C API function PyEval_ThreadsInitialized(), by Nick
Coghlan, for determining whether PyEval_InitThreads() has been called.
Also purged the undocumented+unused _PyThread_Started int.
2004-10-11 02:40:51 +00:00
Tim Peters 89c0ec9beb Revert rev 2.35. It was based on erroneous reasoning -- the current
thread's id can't get duplicated, because (of course!) the current thread
is still running.  The code should work either way, but reverting the
gratuitous change should make backporting easier, and gets the bad
reasoning out of 2.35's new comments.
2004-10-10 05:30:40 +00:00
Tim Peters 8470558a04 PyInterpreterState_New(), PyThreadState_New(): use malloc/free directly.
This appears to finish repairs for SF bug 1041645.

This is a critical bugfix.
2004-10-10 02:47:33 +00:00
Tim Peters 263091e388 find_key(): This routine wasn't thread-correct, and accounts for the
release-build failures noted in bug 1041645.

This is a critical bugfix.  I'm not going to backport it, though (no time).
2004-10-10 01:58:44 +00:00
Tim Peters 5c14e6498a PyGILState_Release(): If we need to delete the TLS entry for this thread,
that must be done under protection of the GIL, for reasons explained in
new comments.
2004-10-09 23:55:36 +00:00
Tim Peters f9becec8cd _PyGILState_Init(), PyGILState_Ensure(): Since PyThread_set_key_value()
can fail, check its return value, and die if it does fail.

_PyGILState_Init():  Assert that the thread doesn't already have an
association for autoTLSkey.  If it does, PyThread_set_key_value() will
ignore the attempt to (re)set the association, which the code clearly
doesn't want.
2004-10-09 22:47:13 +00:00
Tim Peters fda787fcec Document the results of painful reverse-engineering of the "portable TLS"
code.

PyThread_set_key_value():  It's clear that this code assumes the passed-in
value isn't NULL, so document that it must not be, and assert that it
isn't.  It remains unclear whether existing callers want the odd semantics
actually implemented by this function.
2004-10-09 22:33:09 +00:00
Tim Peters 19717fa33a Style guide & consistency changes. No semantic changes. 2004-10-09 17:38:29 +00:00
Tim Peters 4c1f5ecfe3 Trim trailing whitespace. 2004-10-09 17:25:05 +00:00
Raymond Hettinger db29e0fe8c SF patch #1035498: -m option to run a module as a script
(Contributed by Nick Coghlan.)
2004-10-07 06:46:25 +00:00
Raymond Hettinger fb09f0e85c Finalize the freelist of list objects. 2004-10-07 03:58:07 +00:00
Martin v. Löwis 507a485984 Print verbose messages to stderr. Fixes #1036752. 2004-10-03 08:51:35 +00:00
Raymond Hettinger fec0c466ad Improve error message for augmented assignments to genexps or listcomps.
Rather than introduce new logic, took the approach of making the message
itself more general.
2004-09-29 23:54:08 +00:00
Raymond Hettinger 8ffc1410e2 Fix two erroneous error messages. 2004-09-29 21:47:10 +00:00
Raymond Hettinger 06cc973d06 Replaced a test with an assertion.
(Suggested by Michael Hudson.)
2004-09-28 17:22:12 +00:00
Phillip J. Eby 7ec642a4d2 Fix for SF bug #1029475 : reload() doesn't work with PEP 302 loaders. 2004-09-23 04:37:36 +00:00
Raymond Hettinger 2c31a058eb SF patch #1031667: Fold tuples of constants into a single constant
Example:
>>> import dis
>>> dis.dis(compile('1,2,3', '', 'eval'))
  0           0 LOAD_CONST               3 ((1, 2, 3))
              3 RETURN_VALUE
2004-09-22 18:44:21 +00:00
Raymond Hettinger cfc3192677 SF bug #1014215: Unspecific errors with metaclass
High level error message was stomping useful detailed messages from lower
level routines.

The new approach is to augment string error messages returned by the low
level routines.  The provides both high and low level information.  If
the exception value is not a string, no changes are made.

To see the improved messages in action, type:
   import random
   class R(random): pass
   class B(bool): pass
2004-09-16 16:41:57 +00:00
Anthony Baxter 1a4ddaecc7 SF patch #1007189, multi-line imports, for instance:
"from blah import (foo, bar
baz, bongo)"
2004-08-31 10:07:13 +00:00
Martin v. Löwis 87fa785f0f Centralize WITH_TSC processing. 2004-08-29 15:51:52 +00:00
Raymond Hettinger 1792bfbf90 Bypass peepholing of code with lineno tables having intervals >= 255.
Allows the lineno fixup code to remain simple and not have to deal with
multibyte codings.

* Add an assertion to that effect.
* Remove the XXX comment on the subject.
2004-08-25 17:19:38 +00:00
Raymond Hettinger 65d3c0537a Fix typo in comment and add clarification. 2004-08-25 15:15:56 +00:00
Martin v. Löwis 8d494f3241 Patch #1015021: Stop claiming that coerce can return None.
Will backport to 2.3.
2004-08-25 10:42:41 +00:00
Raymond Hettinger ef0a82b682 Simplify chains of conditional jumps.
(Suggested by Neal Norwitz.)
2004-08-25 03:18:29 +00:00
Tim Peters c885443479 Stop producing or using OverflowWarning. PEP 237 thought this would
happen in 2.3, but nobody noticed it still was getting generated (the
warning was disabled by default).  OverflowWarning and
PyExc_OverflowWarning should be removed for 2.5, and left notes all over
saying so.
2004-08-25 02:14:08 +00:00
Raymond Hettinger a12fa148d7 Incorporate review comments courtesy of Neal Norwitz:
* Perform the code length check earlier.
* Eliminate the extra PyMem_Free() upon hitting an EXTENDED_ARG.
* Assert that the NOP count used in jump retargeting matches the NOPs
  eliminated in the final step.
* Add an XXX note to indicate that more work is being to done to
  handle linenotab with intervals > 255.
2004-08-24 04:34:16 +00:00
Raymond Hettinger fd2d1f7870 SF Patch #1013667: Cleanup Peepholer Output
* Make a pass to eliminate NOPs.  Produce code that is more readable,
  more compact, and a tiny bit faster.  Makes the peepholer more flexible
  in the scope of allowable transformations.

* With Guido's okay, bumped up the magic number so that this patch gets
  widely exercised before the alpha goes out.
2004-08-23 23:37:48 +00:00
Martin v. Löwis 336e85f56a Patch #900727: Add Py_InitializeEx to allow embedding without signals. 2004-08-19 11:31:58 +00:00
Raymond Hettinger 1a7892924f Move the bytecode optimizer upstream so that its results are saved in pyc
files and not re-optimized upon import.  Saves a bit of startup time while
still remaining decoupled from the rest of the compiler.

As a side benefit, handcoded bytecode is not run through the optimizer
when new code objects are created.  Hopefully, a handcoder has already
created exactly what they want to have run.

(Idea suggested by Armin Rigo and Michael Hudson.  Initially avoided
 because of worries about compiler coupling; however, only the nexus
 point needed to be moved so there won't be a conflict when the AST
 branch is loaded.)
2004-08-18 05:22:06 +00:00
Michael W. Hudson 0ccff074cd This is Mark Russell's patch:
[ 1009560 ] Fix @decorator evaluation order

From the description:

Changes in this patch:

- Change Grammar/Grammar to require
newlines between adjacent decorators.

- Fix order of evaluation of decorators
in the C (compile.c) and python
(Lib/compiler/pycodegen.py) compilers

- Add better order of evaluation check
to test_decorators.py (test_eval_order)

- Update the decorator documentation in
the reference manual (improve description
of evaluation order and update syntax
description)

and the comment:

Used Brett's evaluation order (see
http://mail.python.org/pipermail/python-dev/2004-August/047835.html)

(I'm checking this in for Anthony who was having problems getting SF to
talk to him)
2004-08-17 17:29:16 +00:00
Matthias Klose a2542bee59 The attached patch fixes FTBFS on GNU/k*BSD. The problem happens on GNU/k*BSD
because GNU/k*BSD uses gnu pth to provide pthreads, but will also happen on any
system that does the same.

python fails to build because it doesn't detect gnu pth in pthread
emulation. See C comments in patch for details.

patch taken from http://bugs.debian.org/264315
2004-08-16 11:35:51 +00:00
Brett Cannon add33601c2 Correct the order of application for decorators. Meant to be bottom-up and not
top-down.  Now matches the PEP.
2004-08-15 07:21:25 +00:00
Brett Cannon 31f8350f43 Fix incorrect comment for (struct compiling)->c_cellvars 2004-08-15 01:15:01 +00:00
Michael W. Hudson 800ba2375a This is my patch:
[ 1005891 ] support --with-tsc on PPC

plus a trivial change to settscdump's docstring and a Misc/NEWS entry.
2004-08-12 18:19:17 +00:00
Tim Peters d459f536c5 code_new(): Wouldn't compile on Windows, because of gcc'ism. 2004-08-12 18:16:43 +00:00
Michael W. Hudson 6093462739 Fix bug
[ 1005248 ] new.code() not cleanly checking its arguments

using the result of new.code() can still destroy the sun, but merely
calling the function shouldn't any more.

I also rewrote the existing tests of new.code() to use vastly less
un-bogus arguments, and added tests for the previous insane behaviours.
2004-08-12 17:56:29 +00:00
Martin v. Löwis fd39ad4937 Patch #1005468: Disambiguate "min() or max()" exception string. 2004-08-12 14:42:37 +00:00
Armin Rigo 618fbf5469 This was quite a dark bug in my recent in-place string concatenation
hack: it would resize *interned* strings in-place!  This occurred because
their reference counts do not have their expected value -- stringobject.c
hacks them.  Mea culpa.
2004-08-07 20:58:32 +00:00
Jeremy Hylton 4c989ddc9c Subclasses of string can no longer be interned. The semantics of
interning were not clear here -- a subclass could be mutable, for
example -- and had bugs.  Explicitly interning a subclass of string
via intern() will raise a TypeError.  Internal operations that attempt
to intern a string subclass will have no effect.

Added a few tests to test_builtin that includes the old buggy code and
verifies that calls like PyObject_SetAttr() don't fail.  Perhaps these
tests should have gone in test_string.
2004-08-07 19:20:05 +00:00
Michael W. Hudson 34553388ef Fix
[ 991812 ] PyArg_ParseTuple can miss errors with warnings as exceptions

as suggested in the report.

This is definitely a 2.3 candidate (as are most of the checkins I've
made in the last month...)
2004-08-07 17:57:16 +00:00
Raymond Hettinger 98bd1814e2 SF bug #1004088: big code objects (>64K) may be optimized incorrectly
Will backport.
2004-08-06 19:46:34 +00:00
Raymond Hettinger 52a21b8e65 SF patch #980695: efficient string concatenation
(Original patch by Armin Rigo).
2004-08-06 18:43:09 +00:00
Michael W. Hudson e51c4f9a10 Revert 2.312; turns out interning the file name did do some good (reducing
.pyc size) after all.
2004-08-04 10:26:08 +00:00
Michael W. Hudson 782d8ffb42 Don't intern the filename of a file being compiled.
Hard to believe it ever helped anything, and it hurts finding reference
leaks.
2004-08-03 10:24:03 +00:00
Michael W. Hudson a3711f73c1 Fix for the unfortunate fact that PyDict_GetItem and PyObject_GetItem
have differing refcount semantics.  If anyone sees a prettier way to
acheive the same ends, then please go for it.

I think this is the first time I've ever used Py_XINCREF.
2004-08-02 14:50:43 +00:00
Michael W. Hudson 52db519faa for some reason, the lack of adherence to Python's C whitespace rules
must have annoyed me at some point.
2004-08-02 13:21:09 +00:00
Anthony Baxter 4e7785aa4f fix for @decorators under a debug build. 2004-08-02 11:08:15 +00:00
Raymond Hettinger 66bd233225 Completed the patch for Bug #215126.
* Fixes an incorrect variable in a PyDict_CheckExact.
* Allow general mapping locals arguments for the execfile() function
  and exec statement.
* Add tests.
2004-08-02 08:30:07 +00:00
Anthony Baxter c2a5a63654 PEP-0318, @decorator-style. In Guido's words:
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.
2004-08-02 06:10:11 +00:00
Tim Peters 1cd701732f PyImport_ExecCodeModuleEx(): remove module from sys.modules in error cases.
PyImport_ReloadModule():  restore the module to sys.modules in error cases.
load_package():  semantic-neutral refactoring from an earlier stab at
                 this patch; giving it a common error exit made the code
                 easier to follow, so retaining that part.
_RemoveModule():  new little utility to delete a key from sys.modules.
2004-08-02 03:52:12 +00:00
Tim Peters a7c650934d lock_held() docs: Use True/False instead of 1/0. The LaTeX docs were
already correct, so not changed here.
2004-08-01 23:26:05 +00:00
Tim Peters 86c7d2f220 Trimmed trailing whitespace. 2004-08-01 23:24:21 +00:00
Martin v. Löwis c2632a5c34 Patch #984714: Properly diagnose E_DECODE errors.
Backported to 2.3.
2004-07-21 05:35:02 +00:00
Neil Schemenauer 3a313e3655 Check the type of values returned by __int__, __float__, __long__,
__oct__, and __hex__.  Raise TypeError if an invalid type is
returned.  Note that PyNumber_Int and PyNumber_Long can still
return ints or longs.  Fixes SF bug #966618.
2004-07-19 16:29:17 +00:00
Raymond Hettinger 11a70c79b9 Upgrade None assignment SyntaxWarning to a SyntaxError. 2004-07-17 21:46:25 +00:00
Tim Peters db5860b7c7 optimize_code(): Repaired gross error in new special-casing for None.
The preceding case statement was missing a terminating "break" stmt,
so fell into the new code by mistake.  This caused uncaught out-of-bounds
accesses to the "names" tuple, leading to a variety of insane behaviors.
2004-07-17 05:00:52 +00:00
Raymond Hettinger 76d962d700 Treat None as a constant. 2004-07-16 12:16:48 +00:00
Jack Jansen e497978201 Fix for 838140: don't call NSUnlinkModule when we fail to find our
expected entrypoint. The unlinking will crash the application if the
module contained ObjC code. The price of this is small: a little wasted
memory, and only in a case than isn't expected to occur often.
2004-07-15 22:28:48 +00:00
Jack Jansen 59f072ad7c Moved PyMac_GetScript() to _localemodule, which is the only place where
it is used, and made it private. Should fix #978662.
2004-07-15 13:31:39 +00:00
Michael W. Hudson c849e63eb0 This is Pete Shinners' patch from his bug report
[ 984722 ] Py_BuildValue loses reference counts on error

I'm ever-so-slightly uneasy at the amount of work this can do with an
exception pending, but I don't think that this can result in anything
more serious than a strange error message.
2004-07-14 11:28:06 +00:00
Brett Cannon 711e7d97e4 Add PyArg_VaParseTupleAndKeywords(). Document this function and
PyArg_VaParse().

Closes patch #550732.  Thanks Greg Chapman.
2004-07-10 22:20:32 +00:00
Neal Norwitz 739a8f86d6 Fix a couple of signed/unsigned comparison warnings 2004-07-08 01:55:58 +00:00
Neal Norwitz 93468eac72 Remove unused macros in .c files 2004-07-08 01:49:00 +00:00