summaryrefslogtreecommitdiffstats
path: root/Python/import.c
Commit message (Collapse)AuthorAgeFilesLines
* Since the MAGIC number scheme is going to break on January 1st, documentTim Peters2001-11-181-4/+16
| | | | what it is more carefully and point out some of the subtleties.
* On the macintosh don't take a quick exit in find_module() for frozen ↵Jack Jansen2001-10-301-0/+8
| | | | submodule imports: the frozen import goes through a different mechanism.
* Use PyDict_Copy() and PyDict_Update() instead of using PyObject_CallMethod()Fred Drake2001-10-251-5/+3
| | | | | | to call the corresponding methods. This is not a performance improvement since the times are still swamped by disk I/O, but cleans up the code just a little.
* SF patch #474590 -- RISC OS supportGuido van Rossum2001-10-241-7/+31
|
* First part of SF patch #416704: More robust freeze, by Toby Dickenson.Guido van Rossum2001-10-181-5/+23
| | | | | | | This fixes the behavior reported by SF bug #404545, where a file x.y.py could be imported by the statement "import x.y" when there's a frozen package x (I believe even if x.y also exists as a frozen module).
* Remove a couple of unused local variables (bug #445960, compiler warningsGreg Ward2001-10-041-4/+2
| | | | on IRIX 6.5).
* Add a new function imp.lock_held(), and use it to skip test_threaded_importTim Peters2001-08-301-0/+19
| | | | when that test is doomed to deadlock.
* Fixed typo in comment leading up to _PyImport_FixupExtension().Barry Warsaw2001-08-131-1/+1
|
* Put conditional S_IFMT definition into pyport.h.Martin v. Löwis2001-08-081-5/+0
|
* Put conditional S_ISDIR definition(s) into pyport.h.Martin v. Löwis2001-08-081-4/+0
|
* Derived from SF patch #446899 Permit import of .pyw under Windows, fromTim Peters2001-08-041-5/+14
| | | | David Bolen.
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-2/+5
|
* Add -E command line switch (ignore environment variables like PYTHONHOMENeil Schemenauer2001-07-231-4/+4
| | | | and PYTHONPATH).
* SF Patch #441791, with changes: when "import foo.bar" fails with anGuido van Rossum2001-07-231-4/+16
| | | | | | | exception in the execution of bar, ensure that foo.bar exists. (Previously, while sys.modules['foo.bar'] would exist, foo.bar would only be created upon successful execution of bar. This is inconvenient; some would say wrong. :-)
* SF bug #438295: [Windows] __init__.py cause strange behaviorTim Peters2001-07-051-11/+28
| | | | | | | | | | Probable fix (the bug report doesn't have enough info to say for sure). find_init_module(): Insist on a case-sensitive match for __init__ files. Given __INIT__.PY instead, find_init_module() thought that was fine, but the later attempt to do find_module("__INIT__.PY") didn't and its caller silently suppressed the resulting ImportError. Now find_init_module() refuses to accept __INIT__.PY to begin with. Bugfix candidate; specific to platforms with case-insensitive filesystems.
* SF bug #417093: Case sensitive import: dir and .py file w/ same nameTim Peters2001-04-291-8/+5
| | | | | | | | | | | | | | | | Directory containing Spam.py spam/__init__.py Then "import Spam" caused a SystemError, because code checking for the existence of "Spam/__init__.py" finds it on a case-insensitive filesystem, but then bails because the directory it finds it in doesn't match case, and then old code assumed that was still an error even though it isn't anymore. Changed the code to just continue looking in this case (instead of calling it an error). So import Spam and import spam both work now.
* Iterators phase 1. This comprises:Guido van Rossum2001-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | new slot tp_iter in type object, plus new flag Py_TPFLAGS_HAVE_ITER new C API PyObject_GetIter(), calls tp_iter new builtin iter(), with two forms: iter(obj), and iter(function, sentinel) new internal object types iterobject and calliterobject new exception StopIteration new opcodes for "for" loops, GET_ITER and FOR_ITER (also supported by dis.py) new magic number for .pyc files new special method for instances: __iter__() returns an iterator iteration over dictionaries: "for x in dict" iterates over the keys iteration over files: "for x in file" iterates over lines TODO: documentation test suite decide whether to use a different way to spell iter(function, sentinal) decide whether "for key in dict" is a good idea use iterators in map/filter/reduce, min/max, and elsewhere (in/not in?) speed tuning (make next() a slot tp_next???)
* split long lineJeremy Hylton2001-04-131-1/+2
|
* Case-checking was broken on the Macintosh. Fixed.Jack Jansen2001-03-201-3/+2
|
* Add some spaces around the "=" in assignments.Fred Drake2001-03-061-2/+2
|
* RISCOS changes by dschwertberger.Guido van Rossum2001-03-021-0/+58
|
* Thanks to Steven Majewski, finally putting MacOS X imports to bed for 2.1b1.Tim Peters2001-03-021-9/+3
|
* More MacOSX fiddling. As noted in a comment, I believe all variationsTim Peters2001-03-011-18/+37
| | | | | of these "search the directory" schemes (including this one) are still prone to making mistakes.
* More fiddling w/ the new-fangled Mac import code.Tim Peters2001-03-011-5/+9
|
* Suppress a compiler warning under OpenVMS; time_t is unsigned on (at least)Fred Drake2001-03-011-2/+2
| | | | | | | | | | | | the more recent versions of that platform, so we use the value (time_t)(-1) as the error value. This is the type used in the OpenVMS documentation: http://www.openvms.compaq.com/commercial/c/5763p048.htm#inde This closes SF tracker bug #404240. Also clean up an exception message when detecting overflow of time_t values beyond 4 bytes.
* Remove extra close curly in code #ifdef'ed out on my box.Tim Peters2001-03-011-1/+0
|
* In Steven's apparent absence, check in *something* with a non-zero chanceTim Peters2001-03-011-35/+40
| | | | | of making new-fangled Mac imports work again. May not work, and may not even compile on his boxes, but should be at worst very close on both.
* Ack -- my eyes are getting bleary. Typos in the comment typo repairs.Tim Peters2001-02-281-1/+1
|
* Comment typos.Tim Peters2001-02-281-2/+2
|
* Implement PEP 235: Import on Case-Insensitive Platforms.Tim Peters2001-02-281-138/+87
| | | | | | | | | | | | | | | | | | | | | | | | | http://python.sourceforge.net/peps/pep-0235.html Renamed check_case to case_ok. Substantial code rearrangement to get this stuff in one place in the file. Innermost loop of find_module() now much simpler and #ifdef-free, and I want to keep it that way (it's bad enough that the innermost loop is itself still in an #ifdef!). Windows semantics tested and are fine. Jason, Cygwin *should* be fine if and only if what you did before "worked" for case_ok. Jack, the semantics on your flavor of Mac have definitely changed (see the PEP), and need to be tested. The intent is that your flavor of Mac now work the same as everything else in the "lower left" box, including respecting PYTHONCASEOK. Steven, sorry, you did the most work here so far but you got screwed the worst. Happy to work with you on repairing it, but I don't understand anything about all your Mac variants. We need to add another branch (or two, three, ...?) inside case_ok. But we should not need to change anything else.
* The code in PyImport_Import() tried to save itself a bit of work andGuido van Rossum2001-02-201-13/+7
| | | | | | | | | | | | | | save the __builtin__ module in a static variable. But this doesn't work across Py_Finalise()/Py_Initialize()! It also doesn't work when using multiple interpreter states created with PyInterpreterState_New(). So I'm ripping out this small optimization. This was probably broken since PyImport_Import() was introduced in 1997! We really need a better test suite for multiple interpreter states and repeatedly initializing. This fixes the problems Barry reported in Demo/embed/loop.c.
* This modified version of a patch by Thomas Heller allows __import__Marc-André Lemburg2001-02-091-8/+9
| | | | | | | | | | hooks to take over the Python import machinery at a very early stage in the Python startup phase. If there are still places in the Python interpreter which need to bypass the __import__ hook, these places must now use PyImport_ImportModuleEx() instead. So far no other places than in the import mechanism itself have been identified.
* bump the magic number; the compiler has changed since 2.1a1Jeremy Hylton2001-02-021-1/+1
|
* Steve Majewski's patch #103495, MatchFilename() and find_module()Barry Warsaw2001-02-021-0/+53
| | | | | patch for case-preserving HFS+ suport. Untested except to verify that it builds and doesn't break anything on Linux RH6.1.
* It's unclear whether PyMarshal_XXX() are part of the public or private API.Tim Peters2001-01-281-1/+1
| | | | | | | | | | 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.
* PEP 227 implementationJeremy Hylton2001-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Move distributed and duplicated config for stat() and fstat() into pyport.h.Tim Peters2001-01-181-19/+0
|
* SF Patch #103154 by jlt63: Cygwin Check Import Case Patch.Guido van Rossum2001-01-101-1/+13
| | | | | Note: I've reordered acconfig.h and config.h.in to obtain alphabetical order (modulo case and leading _).
* Rip out DOS-8x3 support.Guido van Rossum2000-11-131-17/+2
|
* _PyImport_Fini(): Closed small memory leak when an embedded app callsBarry Warsaw2000-10-031-0/+2
| | | | | Py_Initialize()/Py_Finalize() in a loop. _PyImport_Filetab needed to be deallocated. Partial closure of SF #110681, Jitterbug PR#398.
* The 2.0b2 change to write .pyc files in exclusive mode (if possible)Tim Peters2000-09-291-1/+6
| | | | | | | | 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.
* On Unix, use O_EXCL when creating the .pyc/.pyo files, to avoid a race conditionGuido van Rossum2000-09-201-1/+31
|
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Replace the run-time 'future-bytecode-stream-inspection' hack to find outThomas Wouters2000-08-271-2/+2
| | | | | | | 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.
* Support for three-token characters (**=, >>=, <<=) which was written byThomas Wouters2000-08-241-1/+1
| | | | | Michael Hudson, and support in general for the augmented assignment syntax. The graminit.c patch is large!
* Thomas reminds me to bump the MAGIC number for the extended printBarry Warsaw2000-08-211-1/+1
| | | | opcode additions.
* Apply SF patch #101135, adding 'import module as m' and 'from module importThomas Wouters2000-08-171-1/+1
| | | | | | | | 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.
* Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since theyThomas Wouters2000-08-111-1/+1
| | | | | | | 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 ?
* Oops. One of last nights ANSIfication patches accidentily upped the bytecodeThomas Wouters2000-07-231-1/+1
| | | | | | 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.)
* ANSIfy as many declarations as possible.Thomas Wouters2000-07-221-1/+2
|