Commit Graph

1146 Commits

Author SHA1 Message Date
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
Vladimir Marangozov 7bd25be508 Cosmetics on Py_Get/SetRecursionLimit (for the style guide) 2000-09-01 11:07:19 +00:00
Jeremy Hylton b69a27e5b2 code part of patch #100895 by Fredrik Lundh
PyErr_Format computes size of buffer needed rather than relying on
static buffer.
2000-09-01 03:49:47 +00:00
Tim Peters d320c348f8 Revert removal of void from function definition. Guido sez I can take it
out again after we complete switching to C++ <wink>.  Thanks to Greg Stein
for hitting me.
2000-09-01 03:34:26 +00:00
Jeremy Hylton b709df3810 refactor __del__ exception handler into PyErr_WriteUnraisable
add sanity check to gc: if an exception occurs during GC, call
PyErr_WriteUnraisable and then call Py_FatalEror.
2000-09-01 02:47:25 +00:00
Guido van Rossum 349ff6f7e2 Set the recursion limit to 1000 -- 2500 was not enough, let's be
conservative.
2000-09-01 01:52:08 +00:00
Tim Peters 51de6906be Supply missing prototypes for new Py_{Get,Set}RecursionLimit; fixes compiler wngs;
un-analize Get's definition ("void" is needed only in declarations, not defns, &
is generally considered bad style in the latter).
2000-09-01 00:01:58 +00:00
Jeremy Hylton ee5adfbae6 add user-modifiable recursion_limit
ceval.c:
    define recurion_limit (static), default value is 2500
    define Py_GetRecursionLimit and Py_SetRecursionLimit
    raise RuntimeError if limit is exceeded
PC/config.h:
    remove plat-specific definition
sysmodule.c:
    add sys.(get|set)recursionlimit
2000-08-31 19:23:01 +00:00
Fred Drake 592f2d6c85 _PySys_Init(): When setting up sys.version_info, use #if/#elif.../#endif
instead of four #if/#endif blocks.  This shortens the
                code and improves readability.
2000-08-31 15:21:11 +00:00
Fred Drake 399739f79f PyOS_CheckStack(): Better ANSI'fy this while we're at it. 2000-08-31 05:52:44 +00:00
Fred Drake e8de31cbd0 Add a comment explaining the return value of PyOS_CheckStack(). 2000-08-31 05:38:39 +00:00
Paul Prescod e68140dd3c Better error message with UnboundLocalError 2000-08-30 20:25:01 +00:00
Barry Warsaw 093abe005d eval_code2(): Guido provides this patch for his suggested elaboration
of extended print.  If the file object being printed to is None, then
sys.stdout is used.
2000-08-29 04:56:13 +00:00
Thomas Wouters dd13e4f91f Replace the run-time 'future-bytecode-stream-inspection' hack to find out
how 'import' was called with a compiletime mechanism: create either a tuple
of the import arguments, or None (in the case of a normal import), add it to
the code-block constants, and load it onto the stack before calling
IMPORT_NAME.
2000-08-27 20:31:27 +00:00
Tim Peters e868211e10 Hard to believe Guido compiled this! Function lacked a return stmt. 2000-08-27 20:18:17 +00:00
Thomas Wouters e753ef8d1b Re-allow 'import mod.submod as s', and change its meaning to what it should
mean; the same as 'from mod import submod as s'.
2000-08-27 20:16:32 +00:00
Guido van Rossum 0df002c45b Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),
PyRun_FileEx().  These are the same as their non-Ex counterparts but
have an extra argument, a flag telling them to close the file when
done.

Then this is used by Py_Main() and execfile() to close the file after
it is parsed but before it is executed.

Adding APIs seems strange given the feature freeze but it's the only
way I see to close the bug report without incompatible changes.

[ Bug #110616 ] source file stays open after parsing is done (PR#209)
2000-08-27 19:21:52 +00:00
Fredrik Lundh 2f15b25da2 implements PyOS_CheckStack for Windows and MSVC. this fixes a
couple of potential stack overflows, including bug #110615.

closes patch #101238
2000-08-27 19:15:31 +00:00
Thomas Wouters 0ae722e0a2 Oops, one pop too many. 2000-08-27 19:01:33 +00:00
Guido van Rossum fee3a2dd8c Charles Waldman's patch to reinitialize the interpreter lock after a
fork.  This solves the test_fork1 problem.  (ceval.c, signalmodule.c,
intrcheck.c)

SourceForge: [ Patch #101226 ] make threading fork-safe
2000-08-27 17:34:07 +00:00
Marc-André Lemburg dc3d606bd9 Fix to [ Bug #111165 ] doc-string removal masked by PYTHONOPTIMIZE 2000-08-25 21:00:46 +00:00
Thomas Wouters b59290f5b2 Fix allowable node-types for assignment, need to add 'listmaker'.
(This fix is a bit broken, just as the test already was: the test for
testlist and listmaker are done always, whereas the test for exprlist and
the actual abort() are only done if Py_DEBUG is defined. Suggestions
welcome, I guess ;)
2000-08-25 05:41:11 +00:00
Fred Drake 6d63adfbb7 Improve the exceptions raised by PyErr_BadInternalCall(); adding the
filename and line number of the call site to allow esier debugging.

This closes SourceForge patch #101214.
2000-08-24 22:38:39 +00:00
Thomas Wouters 434d0828d8 Support for three-token characters (**=, >>=, <<=) which was written by
Michael Hudson, and support in general for the augmented assignment syntax.
The graminit.c patch is large!
2000-08-24 20:11:32 +00:00
Fred Drake ef8ace3a6f Charles G. Waldman <cgw@fnal.gov>:
Add the EXTENDED_ARG opcode to the virtual machine, allowing 32-bit
arguments to opcodes instead of being forced to stick to the 16-bit
limit.  This is especially useful for machine-generated code, which
can be too long for the SET_LINENO parameter to fit into 16 bits.

This closes the implementation portion of SourceForge patch #100893.
2000-08-24 00:32:09 +00:00
Trent Mick 635f6fb0e9 This patch partly (some stuff went in already) ports Python to Monterey.
- Fix bug in thread_pthread.h::PyThread_get_thread_ident() where
  sizeof(pthread) < sizeof(long).
- Add 'configure' for:
	- SIZEOF_PTHREAD is pthread_t can be included via <pthread.h>
	- setting Monterey system name
	- appropriate CC,LINKCC,LDSHARED,OPT, and CCSHARED for Monterey
- Add section in README for Monterey build
2000-08-23 21:33:05 +00:00
Fred Drake b745a0481b Remove the dependency information for version.o; this is not part of
the sources/build process any more.
2000-08-23 21:16:10 +00:00
Skip Montanaro 46dfa5f4ed require list comprehensions to start with a for clause 2000-08-22 02:43:07 +00:00
Barry Warsaw 24703a02e7 com_print_stmt(): Guido rightly points out that the stream expression
in extended prints should only be evaluated once.  This patch plays
stack games (documented!) to fix this.
2000-08-21 17:07:20 +00:00
Barry Warsaw 45ab2b65f6 Thomas reminds me to bump the MAGIC number for the extended print
opcode additions.
2000-08-21 16:35:06 +00:00
Barry Warsaw 23c9ec87cf PEP 214, Extended print Statement, has been accepted by the BDFL.
eval_code2(): Implement new bytecodes PRINT_ITEM_TO and
PRINT_NEWLINE_TO, as per accepted SF patch #100970.

Also update graminit.c based on related Grammar/Grammar changes.
2000-08-21 15:44:01 +00:00
Barry Warsaw 29c574e30c PEP 214, Extended print Statement, has been accepted by the BDFL.
com_print_stmt(): Implement recognition of, and byte compilation for,
extended print using new byte codes PRINT_ITEM_TO and
PRINT_NEWLINE_TO.
2000-08-21 15:38:56 +00:00
Thomas Wouters 0400515ff0 Fix the bug Sjoerd Mullender discovered, where find_from_args() wasn't
trying hard enough to find out what the arguments to an import were. There
is no test-case for this bug, yet, but this is what it looked like:

from encodings import cp1006, cp1026
ImportError: cannot import name cp1026

'__import__' was called with only the first name in the 'arguments' list.
2000-08-20 14:01:53 +00:00
Thomas Wouters 8bad612881 Disallow "import mod.submod as m", because the result is ambiguous. Does it
load mod.submod as m, or mod as m ? Both can be achieved differently, and
unambiguously. Also attempt to document this restriction (editor
appreciated!)

Note that this is an artificial check during compile, because incorporating
this in the grammar is hard, and then adjusting the compiler to do the right
thing with the right nodes is harder.
2000-08-19 20:55:02 +00:00
Barry Warsaw 73f77b4495 com_error(): Quiet gcc -Wall warning. 2000-08-18 19:59:20 +00:00
Fred Drake 04e654a63c Remove a couple of warnings turned up by "gcc -Wall". 2000-08-18 19:53:25 +00:00
Vladimir Marangozov 0888ff17bd Do not set a MemoryError exception over another MemoryError exception,
thus preserving the first one that has been raised.
2000-08-18 18:01:06 +00:00
Barry Warsaw 87bec35d74 SyntaxError__classinit__(): Slight reorg for simplicity. 2000-08-18 05:05:37 +00:00
Barry Warsaw 5ca1ef9238 comples_from_string(): Move s_buffer[] up to the top-level function
scope.  Previously, s_buffer[] was defined inside the
PyUnicode_Check() scope, but referred to in the outer scope via
assignment to s.  This quiets an Insure portability warning.
2000-08-18 05:02:16 +00:00
Thomas Wouters 5215225ea1 Apply SF patch #101135, adding 'import module as m' and 'from module import
name as n'. By doing some twists and turns, "as" is not a reserved word.

There is a slight change in semantics for 'from module import name' (it will
now honour the 'global' keyword) but only in cases that are explicitly
undocumented.
2000-08-17 22:55:00 +00:00
Barry Warsaw f2581c97f2 _PySys_Init(): Fix another Insure discovered memory leak; the PyString
created from the "big"/"little" constant needs to be decref'd.
2000-08-16 23:03:57 +00:00
Barry Warsaw 77c9f50422 SyntaxError__str__(): Fix two memory problems discovered by Insure.
First, the allocated buffer was never freed after using it to create
the PyString object.  Second, it was possible that have_filename would
be false (meaning that filename was not a PyString object), but that
the code would still try to PyString_GET_SIZE() it.
2000-08-16 19:43:17 +00:00
Tim Peters b59ab42487 Fix new compiler warnings. Unused var in compile.c. Argsize mismatches
in binascii.c (only on platforms with signed chars -- although Py_CHARMASK
is documented as returning an int, it only does so on platforms with
signed chars).
2000-08-15 16:41:26 +00:00
Fred Drake 185a29b08f my_basename(): Removes the leading path components from a path name,
returning a pointer to the start of the file's "base" name;
	similar to os.path.basename().

SyntaxError__str__():  Use my_basename() to keep the length of the
	file name included in the exception message short.
2000-08-15 16:20:36 +00:00
Fred Drake a811a5b13a Remove the osdefs.h #include; it was not needed in the final version of
my last set of changes.
2000-08-15 16:13:37 +00:00
Fred Drake dcf08e0dfe When raising a SyntaxError, make a best-effort attempt to set the
filename and lineno attributes, but do not mask the SyntaxError if we
fail.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).

Wrap a long line to fit in under 80 columns.
2000-08-15 15:49:44 +00:00
Fred Drake 83cb797380 When raising a SyntaxError, make a best-effort attempt to set the
filename and lineno attributes, but do not mask the SyntaxError if we
fail.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).
2000-08-15 15:49:03 +00:00
Fred Drake 1aba577093 SyntaxError__str__(): Do more formatting of the exception here, rather
than depending on the site that raises the exception.  If the
	filename and lineno attributes are set on the exception object,
	use them to augment the message displayed.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).
2000-08-15 15:46:16 +00:00
Fred Drake a2b6ad6e27 Guido pointed out that all names in the sys module have no underscore, 2000-08-15 04:24:43 +00:00
Mark Hammond 557a044f74 Fix the parent of WindowsError - both the comments in this source file, and the previous exceptions.py have WindowsError as a sub-class of OSError. 2000-08-15 00:37:32 +00:00
Fred Drake ccede59889 The attempt to protect against MS_WIN16 compilers that do not support long
string literals has not been tested on an MS_WIN16 platform; the trailing
";" was inside the #ifndef MS_WIN16, which should cause an error (missing
semi-colon) when compiled with that symbol #defined.
2000-08-14 20:59:57 +00:00
Fred Drake 099325e01b Add a byte_order value to the sys module. The value is "big" for
big-endian machines and "little" for little-endian machines.
2000-08-14 15:47:03 +00:00
Thomas Wouters 87df80d542 The list comp patch checked for the second child node of the 'listmaker'
node, without checking if the node actually had more than one child. It can
have only one node, though: '[' test ']'. This fixes it.
2000-08-13 17:05:17 +00:00
Thomas Wouters 361852f80e The list comprehensions patch partly reversed the removal of UNPACK_LIST,
re-introducing com_assign_list, now unused. Removed it.
2000-08-12 22:03:16 +00:00
Trent Mick 29b83810bd Clean up a couple of warnings on Win64. The downcast of the strlen size_t
return value to int is safe here because in each case it previouls checked that
there will be no overflow.
2000-08-12 21:35:36 +00:00
Skip Montanaro 803d6e5451 list comprehensions. see
http://sourceforge.net/patch/?func=detailpatch&patch_id=100654&group_id=5470

for details.
2000-08-12 18:09:51 +00:00
Thomas Wouters 0be5aab04d Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since they
did the same anyway.

I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of
distutils, is it ? Should it try to be compatible with old bytecode version ?
2000-08-11 22:15:52 +00:00
Fredrik Lundh 6947d0b65e -- from Trent Mick: [Patch #101010] replace use of INT_PTR
with uintptr_t (fix MSVC 5.0 build)
2000-08-07 20:16:28 +00:00
Guido van Rossum 6c2f0c73a1 When returning an error from jcompile() (which is passed through by
PyNode_Compile()), make sure that an exception is actually set --
otherwise someone stomped on our error.  [2.0 checkin of this fix.]
2000-08-07 19:22:43 +00:00
Guido van Rossum ed473a46fc Avoid dumping core when PyErr_NormalizeException() is called without
an exception set.  This shouldn't happen, but we see it at times...
2000-08-07 19:18:27 +00:00
Moshe Zadka aa39a7edf7 Initialized opcode and oparg to silence a gcc -Wall warning. 2000-08-07 06:34:45 +00:00
Thomas Wouters e8643c465d Fix some strange indentation and grammar that have been bugging me for
weeks.
2000-08-05 21:37:50 +00:00
Jack Jansen cc22fbe3db Changed H specifier to mean "bitfield", i.e. any value from
-32768..65535 is acceptable. Added B specifier (with values from
-128..255). No L added (which would have completed the set) because l
already accepts any value (and the letter L is taken for quadwords).
2000-08-05 21:29:58 +00:00
Moshe Zadka 9fb6af9640 Removing warnings by gcc -Wall -- cast ugly || to void. 2000-08-04 21:27:47 +00:00
Guido van Rossum 413407f103 Add a test that Py_IsInitialized() in Py_InitModule4(). See
python-dev discussion.

This should catch future version incompatibilities on Windows.  Alas,
this doesn't help for 1.5 vs. 1.6; but it will help for 1.6 vs. 2.0.
2000-08-04 14:00:14 +00:00
Marc-André Lemburg bff879cabb This patch finalizes the move from UTF-8 to a default encoding in
the Python Unicode implementation.

The internal buffer used for implementing the buffer protocol
is renamed to defenc to make this change visible. It now holds the
default encoded version of the Unicode object and is calculated
on demand (NULL otherwise).

Since the default encoding defaults to ASCII, this will mean that
Unicode objects which hold non-ASCII characters will no longer
work on C APIs using the "s" or "t" parser markers. C APIs must now
explicitly provide Unicode support via the "u", "U" or "es"/"es#"
parser markers in order to work with non-ASCII Unicode strings.

(Note: this patch will also have to be applied to the 1.6 branch
 of the CVS tree.)
2000-08-03 18:46:08 +00:00
Guido van Rossum 16b1ad9c7d Changing the CNRI copyright notice according to CNRI's instructions.
This is a notice without a date, which apparently is not a claim to
copyright but only advice to the reader.  IANAL. :-)
2000-08-03 16:24:25 +00:00
Barry Warsaw bd599b5928 Both PEP 201 Lockstep Iteration and SF patch #101030 have been
accepted by the BDFL.

builtin_zip(): New function to implement the zip() function described
in the above proposal.

zip_doc[]: Docstring for zip().

builtin_methods[]: added entry for zip()
2000-08-03 15:45:29 +00:00
Fred Drake 19c6afb42b Include the dependence of sysmodule on the patchlevel.h include, so
that sys.version_info will be built properly.
2000-08-01 17:46:22 +00:00
Peter Schneider-Kamp 7e01890986 merge Include/my*.h into Include/pyport.h
marked my*.h as obsolete
2000-07-31 15:28:04 +00:00
Thomas Wouters 334fb8985b Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Leave the actual #define in for API compatibility.
2000-07-25 12:56:38 +00:00
Thomas Wouters 1e0c2f4bee Create a new section of pyport.h to hold all external function declarations
for systems that are missing those declarations from system include files.
Start by moving a pointy-haired ones from their previous locations to the
new section.

(The gethostname() one, for instance, breaks on several systems, because
some define it as (char *, size_t) and some as (char *, int).)

I purposely decided not to include the summary of used #defines like Tim did
in the first section of pyport.h. In my opinion, the number of #defines
likedly to be used by this section would make such an overview unwieldy. I
would suggest documenting the non-obvious ones, though.
2000-07-24 16:06:23 +00:00
Thomas Wouters 8ec68fded2 Prototype yet another forward declaration. 2000-07-24 14:39:50 +00:00
Thomas Wouters e28c296f0f Another missed ansification. 2000-07-23 22:21:32 +00:00
Tim Peters 8315ea5790 Included assert.h in Python.h -- it's absurd that this basic tool of
good C practice hasn't been available to everything all along.
Added Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) macro to pyport.h; this
just casts VALUE from type WIDE to type NARROW, but assert-fails if
Py_DEBUG is defined and info is lost due to casting.
Replaced a line in Fredrik's fix to marshal.c to use the new macro.
2000-07-23 19:28:35 +00:00
Fredrik Lundh 115343849c -- changed w_more to take an integer instead of a char
(this is what the callers expect).
2000-07-23 18:24:06 +00:00
Thomas Wouters 2f2370bfc9 Oops. One of last nights ANSIfication patches accidentily upped the bytecode
MAGIC number. When updating it next time, be sure it's higher than 50715 *
constants. (Shouldn't be a problem if everyone keeps to the proper
algorithm.)
2000-07-23 09:20:08 +00:00
Thomas Wouters b4bd21cf79 ANSIfy as many declarations as possible. 2000-07-22 23:38:01 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Thomas Wouters 0452d1f316 Fix two instances of empty argument lists, and fix style
('PyObject** x' -> 'PyObject **x')
2000-07-22 18:45:06 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Peter Schneider-Kamp 9a5086c598 just fixing the indentation 2000-07-13 06:24:29 +00:00
Peter Schneider-Kamp 11384c60f6 raise error on duplicate function arguments
example:

>>> def f(a,a):print a
...
SyntaxError: duplicate argument in function definition
2000-07-13 06:15:04 +00:00
Skip Montanaro 6980dff3db delete obsolete SYMANTEC__CFM68K__ #ifdefs 2000-07-12 17:21:42 +00:00
Jeremy Hylton 03657cfdb0 replace PyXXX_Length calls with PyXXX_Size calls 2000-07-12 13:05:33 +00:00
Tim Peters bf26e07049 Worm around MSVC6 error on single string literal > 2Kb. 2000-07-12 04:02:10 +00:00
Jack Jansen cbf630f0a9 Include macglue.h for some function prototypes, and renamed a few
mac-specific functions to have a PyMac_ name.
2000-07-11 21:59:16 +00:00
Fred Drake 85f363990c Create two new exceptions: IndentationError and TabError. These are
used for indentation related errors.  This patch includes Ping's
improvements for indentation-related error messages.

Closes SourceForge patches #100734 and #100856.
2000-07-11 17:53:00 +00:00
Barry Warsaw b78165566e Exception__str__(): In case 1, be sure to decref the tmp local
variable.  This crushes another memory leak.  Slight rewrite
included.
2000-07-09 22:27:10 +00:00
Barry Warsaw 7dfeb42939 EnvironmentError__init__(): The two case clauses were missing
`break's.  This first missing break caused a memory leak when case 3
fell through case 2 in the following example:

import os
os.chmod('/missing', 0600)
2000-07-09 04:56:25 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Tim Peters 4be47c0f76 Get rid of unused vars in builtin_unicode (they were causing
legit warnings).
2000-07-09 02:11:18 +00:00
Marc-André Lemburg 1b1bcc9935 Fixed unicode() to use the new API PyUnicode_FromEncodedObject().
This adds support for instance to the constructor (instances
have to define __str__ and can return Unicode objects via that
hook; string return values are decoded into Unicode using the
current default encoding).
2000-07-07 13:48:25 +00:00
Jack Jansen d50338fbd9 Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Py_BuildValue.
2000-07-06 12:22:00 +00:00
Jack Jansen 41aa8e523d Include limits.h if we have it. 2000-07-03 21:39:47 +00:00
Barry Warsaw 8fcaa92c5f init_exceptions(): Decref `doc' so it doesn't leak. 2000-07-01 04:45:52 +00:00
Guido van Rossum db67739d4f Jack Jansen, Mac patch:
Include limits.h if we have it.
2000-07-01 01:09:43 +00:00
Guido van Rossum f12d7a02a0 Jack Jansen, Mac patch:
If we have stat.h include it if we don't have sys/stat.h
2000-07-01 01:08:11 +00:00
Guido van Rossum 63e97ad4ea Jack Jansen, Mac patch:
Include stat.h if needed; different Mac filename compare
2000-07-01 01:06:56 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00