Commit Graph

212 Commits

Author SHA1 Message Date
Tim Peters d9b9ac855c It's unclear whether PyMarshal_XXX() are part of the public or private API.
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-28 00:27:39 +00:00
Jeremy Hylton 64949cb753 PEP 227 implementation
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-25 20:06:59 +00:00
Tim Peters 60f42b50d8 Move distributed and duplicated config for stat() and fstat() into pyport.h. 2001-01-18 03:03:16 +00:00
Guido van Rossum 4c3f57cf05 SF Patch #103154 by jlt63: Cygwin Check Import Case Patch.
Note: I've reordered acconfig.h and config.h.in to obtain alphabetical
order (modulo case and leading _).
2001-01-10 20:40:46 +00:00
Guido van Rossum 215c340aa3 Rip out DOS-8x3 support. 2000-11-13 17:26:32 +00:00
Barry Warsaw 84294487df _PyImport_Fini(): Closed small memory leak when an embedded app calls
Py_Initialize()/Py_Finalize() in a loop.  _PyImport_Filetab needed to
be deallocated.  Partial closure of SF #110681, Jitterbug PR#398.
2000-10-03 16:02:05 +00:00
Tim Peters 42c83afd14 The 2.0b2 change to write .pyc files in exclusive mode (if possible)
unintentionally caused them to get written in text mode under Windows.
As a result, when .pyc files were later read-- in binary mode --the
magic number was always wrong (note that .pyc magic numbers deliberately
include \r and \n characters, so this was "good" breakage, 100% across
all .pyc files, not random corruption in a subset).  Fixed that.
2000-09-29 04:03:10 +00:00
Guido van Rossum 55a8338d7f On Unix, use O_EXCL when creating the .pyc/.pyo files, to avoid a race condition 2000-09-20 20:31:38 +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 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
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
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
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
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
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
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
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +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
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Fred Drake 4c82b2366f Trent Mick <trentm@activestate.com>:
This patch fixes possible overflow in the use of
PyOS_GetLastModificationTime in getmtime.c and Python/import.c.

Currently PyOS_GetLastModificationTime returns a C long. This can
overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it
should logically return a time_t anyway (this patch changes this).

As well, import.c uses PyOS_GetLastModificationTime for .pyc
timestamping.  There has been recent discussion about the .pyc header
format on python-dev.  This patch adds oveflow checking to import.c so
that an exception will be raised if the modification time
overflows. There are a few other minor 64-bit readiness changes made
to the module as well:

- size_t instead of int or long for function-local buffer and string
length variables

- one buffer overflow check was added (raises an exception on possible
overflow, this overflow chance exists on 32-bit platforms as well), no
other possible buffer overflows existed (from my analysis anyway)

Closes SourceForge patch #100509.
2000-06-30 16:18:57 +00:00
Jeremy Hylton 9262b8ab1f another typo caught by Rob Hooft 2000-06-30 04:59:17 +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 96774c1347 Marc-Andre Lemburg:
Changed all references to the MAGIC constant to use a global
pyc_magic instead. This global is initially set to MAGIC, but can be
changed by the _PyImport_Init() function to provide for
special features implemented in the compiler which are settable
using command line switches and affect the way PYC files are
generated.

Currently this change is only done for the -U flag.
2000-05-01 20:19:08 +00:00
Guido van Rossum 22b65a8edc Robin Becker: The following patch seems to fix a module case bug in
1.6a2 caused by wrong return values in routine allcaps83.  [GvR: I
also changed the case for end-s>8 to return 0.]
2000-05-01 17:36:58 +00:00
Guido van Rossum 1cb6cd0ec5 As Marc-Andre Lemburg points out, the magic number needs to change
because we've added Unicode marshalling to the repertoire.
2000-04-28 19:03:54 +00:00
Guido van Rossum b33aa1a51e Jack Jansen: The new version of the GUSI i/o library on the Macintosh
has a few slightly different calls from the old one.
2000-04-24 15:08:18 +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 96a8fb7e99 Cleanup patches from Greg Stein:
* in import.c, #ifdef out references to dynamic loading based on
  HAVE_DYNAMIC_LOADING

* clean out the platform-specific crud from importdl.c.
  [ maybe fold this function into import.c and drop the importdl.c file? Greg.]

* change GetDynLoadFunc's "funcname" parameter to "shortname". change
  "name" to "fqname" for clarification.

* each GetDynLoadFunc now creates its own funcname value.

  WARNING: as I mentioned previously, we may run into an issue with a
  missing "_" on some platforms. Testing will show this pretty quickly,
  however.

* move pathname munging into dynload_shlib.c
1999-12-22 14:09:35 +00:00
Guido van Rossum ed1170e49f In _PyImport_Init(), dynamically construct the table of legal suffixes
from two static tables (one standard, one provided by the platform's
dynload_*.c variant).

This is part of a set of patches by Greg Stein.
1999-12-20 21:23:41 +00:00
Guido van Rossum 2571cc8bf5 Changes by Mark Hammond for Windows CE. Mostly of the form
#ifdef DONT_HAVE_header_H ... #endif around #include <header.h>.
1999-04-07 16:07:23 +00:00
Barry Warsaw 3879333b9e PyImport_ReloadModule(): Nailed a small memory leak. In the
else-clause of the subname test, the parentname object was never
DECREF'd.
1999-01-27 17:54:20 +00:00
Guido van Rossum 6058eb49ee Improve comment for PyImport_Import() as suggested by Bill Tutt. 1998-12-21 19:51:00 +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 66468568df Jim Fulton writes:
"""
I had originally not realized that PyEval_GetGlobals did not
INCREF it's return value.  The fix is to add the INCREF,
as shown below.
"""
1998-10-22 15:46:50 +00:00
Guido van Rossum 2f3667a7b9 Replace fprintf(stderr, ...) with PySys_WriteStderr(...). 1998-10-12 18:23:55 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum 566373e974 While scalling sys.modules, skip entries that don't have string keys,
to protect us from jokers who put items with non-string keys in
sys.modules.  Reported by Greg Stein.
1998-10-01 15:24:50 +00:00
Guido van Rossum a0f0a33d05 Mac-specific mod to enable aliases on import paths.
(Jack Jansen and/or Just van Rossum)
1998-09-14 13:40:53 +00:00
Guido van Rossum afd3daedde __file__ used to be always set to the .pyc (or .pyo) file, even if
that file in fact did not exist or at least was not used.  Change this
so that __file__ is *only* set to the .pyc/.pyo file when it actually
read the code object from it; otherwise __file__ is set to the .py
file.
1998-08-25 18:44:34 +00:00
Guido van Rossum 0506a431d5 Patch by Just van Rossum that changes how we search for submodules of
frozen packages.  (I *think* this means that we can now have a
built-in module bar that's a submodule of a frozen package foo, by
registering the built-in module with a name "foo.bar" in the table of
builtin modules.)
1998-08-11 15:07:39 +00:00
Guido van Rossum 0f84a349bb Added handling for Mac code resource modules (Jack Jansen). 1998-08-06 13:36:01 +00:00
Guido van Rossum 1a8791e0b8 Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:46:29 +00:00
Guido van Rossum b68cd421e1 Fix two smal memory leaks discovered by Vadim Chugunov. 1998-07-01 17:36:26 +00:00
Guido van Rossum 323bf5e1f7 Ignore Windows case check for ALL CAPS 8.3 files 1998-06-24 03:54:06 +00:00
Guido van Rossum 9c0afe5dc7 Fix a curious bug: statements like "import sys.time" would succeed,
because the path through the code would notice that sys.__path__ did
not exist and it would fall back to the default path (builtins +
sys.path) instead of failing).  No longer.
1998-05-19 15:09:05 +00:00
Guido van Rossum 09cae1f8cd New APIs for embedding applications that want to add their own entries
to the table of built-in modules.  This should normally be called
*before* Py_Initialize().  When the malloc() or realloc() call fails,
-1 is returned and the existing table is unchanged.

After a similar function by Just van Rossum.

int PyImport_ExtendInittab(struct _inittab *newtab);
int PyImport_AppendInittab(char *name, void (*initfunc)());
1998-05-14 02:32:54 +00:00
Guido van Rossum 111c20b992 Reject empty module names -- otherwise __import__("") does something
weird!
1998-04-11 17:38:22 +00:00
Guido van Rossum 8766a7797e Comment out a label on an #endif. 1998-04-10 23:44:32 +00:00
Guido van Rossum 39b0f8976c Address warnings issued by the MSVC++ compiler 1998-04-10 21:52:06 +00:00
Guido van Rossum a5568d349b Support for frozen packages, matching the revamped Tools/freeze.
Frozen packages are indicated by a negative size (the code string
is the __import__.py file).  A frozen package module has its __path__
set to a string, the package name.
1998-03-05 03:45:08 +00:00
Guido van Rossum d65911b3f3 Oops -- overuse of dabbrev-expand introduced a strange bug, where
instead of 'locals' I was passing 'lock_import' to import_module_ex().
1998-03-03 22:33:27 +00:00
Guido van Rossum 75acc9ca1c Add a single Python-wide (!) lock on import. Only one thread at a
time can be in PyImport_ImportModuleEx().  Recursive calls from the
same thread are okay.

Potential problems:

- The lock should really be part of the interpreter state rather than
global, but that would require modifying more files, and I first want
to figure out whether this works at all.

- One could argue that the lock should be per module -- however that
would be complicated to implement.  We would have to have a linked
list of locks per module name, *or* invent a new object type to
represent a lock, so we can store the locks in the module or in a
separate dictionary.  Both seem unwarranted.  The one situation where
this can cause problems is when loading a module takes a long time,
e.g. when the module's initialization code interacts with the user --
during that time, no other threads can run.  I say, "too bad."
1998-03-03 22:26:50 +00:00
Guido van Rossum 05f9dce34f Moved clear_carefully() to _PyModule_Clear() in moduleobject.c
(modified) and use that.

Some differences in the cleanup algorithm:

- Clear __main__ before the other modules.

- Delete more sys variables: including ps1, ps2, exitfunc, argv, and
even path -- this will prevent new imports!

- Restore stdin, stdout, stderr from __stdin__, __stdout__,
__stderr__, effectively deleting hooks that the user might have
installed -- so their (the hooks') destructors will run.
1998-02-19 20:58:44 +00:00
Guido van Rossum aeca79b0f6 Small patches to the DJGPP version of check_case(). 1998-02-18 16:21:00 +00:00
Guido van Rossum 4d1b3b921d Added DJGPP version of check_case(), by Pit Scrorpion (Hans Nowak).
(BTW, the Mac version was by Jack Jansen.)
1998-02-13 23:27:59 +00:00
Guido van Rossum 0980bd9233 Add case checking feature on import.
This is an option for OS-es with case-insensitive but case-preserving
filesystems.  It is currently supported for Win32 and MacOS.  To
enable it, #define CHECK_IMPORT_CASE in your platform specific
config.h.  It is enabled by default on those systems where it is
supported.  On Win32, it can be disabled at runtime by setting the
environment variable PYTHONCASEOK (to any value).

When enabled, the feature checks that the case of the requested module
name matches that of the filename found in the filesystem, and raises
a NameError exception when they don't match.
1998-02-13 17:18:36 +00:00
Guido van Rossum e32bf6ead2 Added PyImport_ExecCodeModuleEx(), which adds an extra parameter to
pass it the true file.  This is used to set __file__ properly, instead
of believing what the code object carries with it.  (If the pointer
is NULL, the code object's co_filename is still used.)
1998-02-11 05:53:02 +00:00
Guido van Rossum a0fec2b5df Two more refinements of the cleanup process.
(1) Explicitly clear __builtin__._ and sys.{last,exc}_* before
clearing anything else.  These are common places where user values
hide and people complain when their destructors fail.  Since the
modules containing them are deleted *last* of all, they would come too
late in the normal destruction order.  Sigh.

(2) Add some debugging aid to cleanup (after a suggestion by Marc
Lemburg) -- print the names of the modules being cleaned, and (when
-vv is used) print the names of the variables being cleared.
1998-02-06 17:16:02 +00:00
Guido van Rossum 758eec0172 Rewritten PyImport_Cleanup() and its helper, clear_carefully(). They
now implement the following finalization strategy.

1. Whenever this code deletes a module, its directory is cleared
   carefully, as follows:
   - set all names to None that begin with exactly one underscore
   - set all names to None that don't begin with two underscores
   - clear the directory

2. Modules are deleted in the following order:
   - modules with a reference count of 1, except __builtin__ or __sys__
   - repeat until no more are found with a reference count of 1
   - __main__ if it's still there
   - all remaining modules except __builtin__ or sys
   - sys
   _ __builtin__
1998-01-19 21:58:26 +00:00
Guido van Rossum e8c27bb3ea Oops! Should've renamed dos_8x3 to dos-8x3 here, too. 1997-12-17 18:57:16 +00:00
Guido van Rossum 595d7ba069 Jeff Rush: add definition for S_IFMT for VisualAge C/C++ under OS2. 1997-12-05 21:45:29 +00:00
Guido van Rossum 197346fafe New policy for package imports: only a directory containing
__init__.py (or __init__.pyc/.pyo, whichever applies) is considered a
package.  All other subdirectories are left alone.  Should make Konrad
Hinsen happy!
1997-10-31 18:38:52 +00:00
Guido van Rossum 771c6c8f7a Instead of using _PyImport_Inittab[] directly, use the new "official"
pointer *PyImport_Inittab which is initialized to _PyImport_Inittab.
1997-10-31 18:37:24 +00:00
Guido van Rossum 9a61dc90e2 Moved mac-specific speedup to a different place (Jack) 1997-10-08 15:25:08 +00:00
Guido van Rossum a7f2e813c9 Remove unreachable "return 1" at end of ensure_fromlist(). 1997-10-03 15:33:32 +00:00
Guido van Rossum 0207e6de38 Added docstrings. Not for the obsolete functions though. 1997-09-09 22:04:42 +00:00
Guido van Rossum c172f26861 Deleted find_module_in_package and find_module_in_directory -- they
aren't needed and it was a mistake to add them.
1997-09-09 20:54:35 +00:00
Guido van Rossum a86f77d4dd Crrected a flow control error that caused the wrong error message when
load-module() didn't find a built-in or frozen module.  Also got rid
of is_frozen(), which duplicated the functionality of
find_frozen()!=NULL.
1997-09-09 18:53:47 +00:00
Guido van Rossum 9905ef9669 Added support for __all__, which should be a list of modules to be
imported when the user says "from package import *".
1997-09-08 16:07:11 +00:00
Guido van Rossum 0c81945808 Bugfix: import A.B from inside package was busted by mark_miss optimization. 1997-09-07 06:16:57 +00:00
Guido van Rossum f5f5fdbdd0 Significant speedup -- when a submodule imports a global module, add a
dummy entry to sys.modules, marking the absence of a submodule by the
same name.

Thus, if module foo.bar executes the statement "import time",
sys.modules['foo.time'] will be set to None, once the absence of a
module foo.time is confirmed (by looking for it in foo's path).

The next time when foo.bar (or any other submodule of foo) executes
"import time", no I/O is necessary to determine that there is no
module foo.time.

(Justification: It may seem strange to pollute sys.modules.  However,
since we're doing the lookup anyway it's definitely the fastest
solution.  This is the same convention that 'ni' uses and I haven't
heard any complaints.)
1997-09-06 20:29:52 +00:00
Guido van Rossum 222ef56bbf Fix reload() for package submodules. 1997-09-06 19:41:09 +00:00
Guido van Rossum 17fc85f2f5 Phase two of package import. "import a.b.c" and all variants now do the
right thing.

Still to do:

- Make reload() of a submodule work.

- Performance tweaks -- currently, a submodule that tries to import a
global module *always* searches the package directory first, even if
the global module was already imported.  Not sure how to solve this
one; probably need to record misses per package.

- Documentation!
1997-09-06 18:52:03 +00:00
Guido van Rossum aee0bad0a5 First part of package support.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but
it does recognize directories.  When importing a directory, it
initializes __path__ to a list containing the directory name, and
loads the __init__ module if found.

The (internal) find_module() and load_module() functions are
restructured so that they both also handle built-in and frozen modules
and Mac resources (and directories of course).  The imp module's
find_module() and (new) load_module() also have this functionality.
Moreover, imp unconditionally defines constants for all module types,
and has two more new functions: find_module_in_package() and
find_module_in_directory().

There's also a new API function, PyImport_ImportModuleEx(), which
takes all four __import__ arguments (name, globals, locals, fromlist).
The last three may be NULL.  This is currently the same as
PyImport_ImportModule() but in the future it will be able to do
relative dotted-path imports.

Other changes:

- bltinmodule.c: in __import__, call PyImport_ImportModuleEx().

- ceval.c: always pass the fromlist to __import__, even if it is a C
function, so PyImport_ImportModuleEx() is useful.

- getmtime.c: the function has a second argument, the FILE*, on which
it applies fstat().  According to Sjoerd this is much faster.  The
first (pathname) argument is ignored, but remains for backward
compatibility (so the Mac version still works without changes).

By cleverly combining the new imp functionality, the full support for
dotted names in Python (mini.py, not checked in) is now about 7K,
lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly
commented).

Good night!
1997-09-05 07:33:22 +00:00
Guido van Rossum 7c14103d77 Keep gcc -Wall happy 1997-08-15 02:52:08 +00:00
Guido van Rossum d47a0a86b4 Added Jim Fulton's PyImport_Import(), which calls whatever
__import__() hook is currently installed.
1997-08-14 20:11:26 +00:00
Guido van Rossum 741689d5f3 Use string interning and caching to get speedups on the mac (Jack). 1997-08-12 14:53:39 +00:00
Guido van Rossum 085d269f1d New rules for deleting modules. Rather than having an elaborate
scheme based on object's types, have a simple two-phase scheme based
on object's *names*:

	/* To make the execution order of destructors for global
	   objects a bit more predictable, we first zap all objects
	   whose name starts with a single underscore, before we clear
	   the entire dictionary.  We zap them by replacing them with
	   None, rather than deleting them from the dictionary, to
	   avoid rehashing the dictionary (to some extent). */
1997-08-05 02:20:51 +00:00
Guido van Rossum 25ce566661 The last of the mass checkins for separate (sub)interpreters.
Everything should now work again.

See the comments for the .h files mass checkin (e.g. pystate.h) for
more detail.
1997-08-02 03:10:38 +00:00
Guido van Rossum ef3d02ebb9 Removed some variables that are used to exchange data between import.c and
importdl.c: the MAXSUFFIXSIZE macro is now defined in importdl.h, and
the modules dictionary is now passed using PyImport_GetModuleDict().

Also undefine USE_SHLIB for AIX -- in AIX 4.2 and up, dlfcn.h exists
but we don't want to use it.
1997-07-21 14:54:36 +00:00
Guido van Rossum b65e85cb73 Fix problem discovered by Greg McFarlane: when an imported module
replaces its own entry in sys.module, reference count errors ensue;
even if there is no reference count problem, it would be preferable
for the import to yield the new thing in sys.modules anyway (if only
because that's what later imports will yield).  This opens the road to
an official hack to implement a __getattr__ like feature for modules:
stick an instance in sys.modules[__name__].
1997-07-10 18:00:45 +00:00
Guido van Rossum af5dfb4ceb One last rename glitch: import_modules -> _PyImport_Modules. 1997-05-14 17:36:12 +00:00
Guido van Rossum b05a5c7698 Instead of importing graminit.h whenever one of the three grammar 'root'
symbols is needed, define these in Python.h with a Py_ prefix.
1997-05-07 17:46:13 +00:00
Guido van Rossum 0bac33b420 Oops, forgot one: inittab. 1997-04-29 20:24:10 +00:00
Guido van Rossum 79f25d9a7b Quickly renamed the remaining files -- this directory is done. 1997-04-29 20:08:16 +00:00
Guido van Rossum 6bf62dad9e Keep gcc -Wall and Microsoft VC happy. 1997-04-11 20:37:35 +00:00
Guido van Rossum 0824f63cfc When -O is given, use ".pyo" instead of ".pyc". 1997-03-11 18:37:35 +00:00
Guido van Rossum 99d182550b New magin number (because of linenumber table). 1997-01-24 03:44:53 +00:00
Guido van Rossum dd5db43905 New MAGIC number (code objects have one more item when marshalled). 1997-01-17 21:06:11 +00:00
Guido van Rossum 80bb9655f0 Keep gcc -Wall happy. 1996-12-05 23:27:02 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum ac279109d4 PYTHONWIN -> MS_COREDLL 1996-08-22 23:10:58 +00:00
Guido van Rossum 1741d60725 Added casts from unsigned char to char when calling rds_object() on
frozen code.
1996-08-08 18:52:59 +00:00
Guido van Rossum 8861b74445 Changes for slice and ellipses 1996-07-30 16:49:37 +00:00
Guido van Rossum 42cd305b25 new .pyc magic number (** operator) 1996-07-21 02:28:18 +00:00
Guido van Rossum 6f489d989d Slightly different Windows ifdefs 1996-06-28 20:15:15 +00:00
Guido van Rossum 0e41c8c848 Cosmetic change to the dox_8x3 hack. 1996-06-20 14:18:34 +00:00