summaryrefslogtreecommitdiff
path: root/Python/marshal.c
AgeCommit message (Collapse)AuthorLines
2001-08-30fix for part of bug #453523: disable unmarshalling of code objects inMichael W. Hudson-1/+7
restricted execution mode.
2001-08-29marshal.c r_long64: When reading a TYPE_INT64 value on a box with 32-bitTim Peters-12/+24
ints, convert to PyLong (rather than throwing away the high-order 32 bits).
2001-08-17Patch #445762: Support --disable-unicodeMartin v. Löwis-0/+4
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
2001-06-18Merging the gen-branch into the main line, at Guido's direction. Yay!Tim Peters-0/+8
Bugfix candidate in inspect.py: it was referencing "self" outside of a method.
2001-05-08SF bug #422177: Results from .pyc differs from .pyTim Peters-5/+3
Store floats and doubles to full precision in marshal. Test that floats read from .pyc/.pyo closely match those read from .py. Declare PyFloat_AsString() in floatobject header file. Add new PyFloat_AsReprString() API function. Document the functions declared in floatobject.h.
2001-04-10test_pickle works on sizeof(long)==8 boxes again.Tim Peters-1/+1
pickle.py The code implicitly assumed that all ints fit in 4 bytes, causing all sorts of mischief (from nonsense results to corrupted pickles). Repaired that. marshal.c The int marshaling code assumed that right shifts of signed longs sign-extend. Repaired that.
2001-01-28It's unclear whether PyMarshal_XXX() are part of the public or private API.Tim Peters-33/+49
They're named as if public, so I did a Bad Thing by changing PyMarshal_ReadObjectFromFile() to suck up the remainder of the file in one gulp: anyone who counted on that leaving the file pointer merely at the end of the next object would be screwed. So restored PyMarshal_ReadObjectFromFile() to its earlier state, renamed the new greedy code to PyMarshal_ReadLastObjectFromFile(), and changed Python internals to call the latter instead.
2001-01-25PEP 227 implementationJeremy Hylton-3/+12
The majority of the changes are in the compiler. The mainloop changes primarily to implement the new opcodes and to pass a function's closure to eval_code2(). Frames and functions got new slots to hold the closure. Include/compile.h Add co_freevars and co_cellvars slots to code objects. Update PyCode_New() to take freevars and cellvars as arguments Include/funcobject.h Add func_closure slot to function objects. Add GetClosure()/SetClosure() functions (and corresponding macros) for getting at the closure. Include/frameobject.h PyFrame_New() now takes a closure. Include/opcode.h Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF. Remove comment about old requirement for opcodes to fit in 7 bits. compile.c Implement changes to code objects for co_freevars and co_cellvars. Modify symbol table to use st_cur_name (string object for the name of the current scope) and st_cur_children (list of nested blocks). Also define st_nested, which might more properly be called st_cur_nested. Add several DEF_XXX flags to track def-use information for free variables. New or modified functions of note: com_make_closure(struct compiling *, PyCodeObject *) Emit LOAD_CLOSURE opcodes as needed to pass cells for free variables into nested scope. com_addop_varname(struct compiling *, int, char *) Emits opcodes for LOAD_DEREF and STORE_DEREF. get_ref_type(struct compiling *, char *name) Return NAME_CLOSURE if ref type is FREE or CELL symtable_load_symbols(struct compiling *) Decides what variables are cell or free based on def-use info. Can now raise SyntaxError if nested scopes are mixed with exec or from blah import *. make_scope_info(PyObject *, PyObject *, int, int) Helper functions for symtable scope stack. symtable_update_free_vars(struct symtable *) After a code block has been analyzed, it must check each of its children for free variables that are not defined in the block. If a variable is free in a child and not defined in the parent, then it is defined by block the enclosing the current one or it is a global. This does the right logic. symtable_add_use() is now a macro for symtable_add_def() symtable_assign(struct symtable *, node *) Use goto instead of for (;;) Fixed bug in symtable where name of keyword argument in function call was treated as assignment in the scope of the call site. Ex: def f(): g(a=2) # a was considered a local of f ceval.c eval_code2() now take one more argument, a closure. Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE> Also: When name error occurs for global variable, report that the name was global in the error mesage. Objects/frameobject.c Initialize f_closure to be a tuple containing space for cellvars and freevars. f_closure is NULL if neither are present. Objects/funcobject.c Add support for func_closure. Python/import.c Change the magic number. Python/marshal.c Track changes to code objects.
2001-01-18Variant of SF patch 103252: Startup optimize: read *.pyc as string, not with ↵Tim Peters-0/+47
getc().
2000-11-14SF bug 119622: compile errors due to redundant atof decls. I don't understandTim Peters-2/+0
the bug report (for details, look at it), but agree there's no need for Python to declare atof itself: we #include stdlib.h, and ANSI C sez atof is declared there already.
2000-09-19Obscure marshal fixes:Tim Peters-4/+4
When reading a short, sign-extend on platforms where shorts are bigger than 16 bits. When reading a long, repair the unportable sign extension that was being done for 64-bit machines (it assumed that signed right shift sign-extends).
2000-09-01REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum-9/+0
This should match the situation in the 1.6b1 tree.
2000-07-23Included assert.h in Python.h -- it's absurd that this basic tool ofTim Peters-1/+1
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-- changed w_more to take an integer instead of a charFredrik Lundh-2/+2
(this is what the callers expect).
2000-07-22Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters-59/+22
declarations yet, those come later.
2000-07-09Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters-6/+4
2000-06-30Change copyright notice - 2nd try.Guido van Rossum-6/+0
2000-06-30Change copyright notice.Guido van Rossum-21/+6
2000-06-28Urmpf. Quality control on this patch lapsed a bit. :-(Guido van Rossum-2/+6
The depth field was never decremented inside w_object(), and it was never initialized in PyMarshal_WriteObjectToFile(). This caused imports from .pyc files to fil mysteriously when the .pyc file was written by the broken code -- w_object() would bail out early, but PyMarshal_WriteObjectToFile() doesn't check the error or return an error code, and apparently the marshalling code doesn't call PyErr_Check() either. (That's a separate patch if I feel like it.)
2000-06-28Michael Hudson <mwh21@cam.ac.uk>:Fred Drake-3/+22
As I really do not have anything better to do at the moment, I have written a patch to Python/marshal.c that prevents Python dumping core when trying to marshal stack bustingly deep (or recursive) data structure. It just throws an exception; even slightly clever handling of recursive data is what pickle is for... [Fred Drake:] Moved magic constant 5000 to a #define. This closes SourceForge patch #100645.
2000-05-03Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum-4/+4
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-03-31Use modern PyArg_ParseTuple style, with function names.Guido van Rossum-8/+8
2000-03-10Marc-Andre Lemburg: support marshalling Unicode objects (code 'u').Guido van Rossum-5/+42
1998-10-08The previous checkin contained an experiment of Greg Stein's that wasn'tGuido van Rossum-1/+1
meant for checkin, and which broke marshal.loads().
1998-10-07Changes to support other object types besides stringsGuido van Rossum-2/+15
as the code string of code objects, as long as they support the (readonly) buffer interface. By Greg Stein.
1998-06-08When unmarshalling, add test for negative lengths on strings, tuplesGuido van Rossum-2/+14
and lists; if the size is negative, raise an exception. Also raise an exception when an undefined type is found -- all this to increase the chance that garbage input causes an exception instead of a core dump.
1998-05-14Remove unnecessary PyErr_Clear().Guido van Rossum-1/+0
1998-04-10Make new gcc -Wall happyGuido van Rossum-4/+7
1997-07-26Plugged a leak. (The same as the one plugged in compile.c -- forgotGuido van Rossum-0/+1
to free lnotab).
1997-05-22PyFile_WriteString now returns an error indicator instead of callingGuido van Rossum-2/+2
PyErr_Clear(). Add checking of those errors.
1997-04-29Quickly renamed the remaining files -- this directory is done.Guido van Rossum-156/+161
1997-03-14New form of PyFPE_END_PROTECT macro.Guido van Rossum-3/+3
1997-02-14Changes for Lee Busby's SIGFPE patch set.Guido van Rossum-1/+9
New file pyfpe.c and exception FloatingPointError. Surround some f.p. operations with PyFPE macro brackets.
1997-02-14Keep gcc -Wall happy.Guido van Rossum-1/+1
1997-01-24Marshal the line number table of code objects.Guido van Rossum-1/+9
1997-01-17Marshal the new stacksize item in code objects.Guido van Rossum-1/+3
1996-12-10Better way to handle 64-bit ints, keeping gcc -Wall happy.Guido van Rossum-30/+18
Tested with AMK's help.
1996-12-05Tentative changes to make this work better on 64-bit machines.Guido van Rossum-3/+66
A plain int that doesn't fit in 32 bits will be marshalled using a new type. 32 bits machines can't handle this and will issue a warning.
1996-10-25New permission notice, includes CNRI.Guido van Rossum-12/+19
1996-10-11Ellipses -> Ellipsis rename (the dictionary really says that it shouldGuido van Rossum-6/+6
be Ellipsis!). Bumped the API version because a linker-visible symbol is affected. Old C code will still compile -- there's a b/w compat macro. Similarly, old Python code will still run, builtin exports both Ellipses and Ellipsis.
1996-08-19Added *PyMarshal_WriteObjectToString() (moved the relevant code thereGuido van Rossum-18/+25
from marshal_loads()).
1996-07-30Changes for slice and ellipsesGuido van Rossum-0/+7
1996-07-21Py_complex; and WITHOUT_COMPLEX added to getargs.cGuido van Rossum-1/+1
1996-06-26Jeremy's patches for more robust handling of unmarshallable types.Guido van Rossum-5/+22
1996-05-28Plug memory leak (variable names in code objects were being leaked!)Guido van Rossum-0/+1
1996-01-12changes for complex numbersGuido van Rossum-0/+47
1995-10-27Made a bit more robust against out-of-memory situationsJack Jansen-12/+35
1995-08-28rd_object() with exception is fatal errorGuido van Rossum-0/+1
1995-07-18keyword arguments and faster callsGuido van Rossum-3/+13
1995-03-09various tuple related optimizations; remove unused b/w compat code from ceval.cGuido van Rossum-9/+18