summaryrefslogtreecommitdiff
path: root/Python/import.c
AgeCommit message (Collapse)AuthorLines
2006-09-11Properly handle a NULL returned from PyArena_New().Neal Norwitz-2/+4
Klocwork #364. Will port to head.
2006-09-06Bug #1550983: emit better error messages for erroneous relativeGeorg Brandl-2/+3
imports (if not in package and if beyond toplevel package). (backport from rev. 51765)
2006-09-05Bug #1520864 (again): unpacking singleton tuples in list comprehensions andNeal Norwitz-1/+2
generator expressions (x for x, in ... ) works again. Sigh, I only fixed for loops the first time, not list comps and genexprs too. I couldn't find any more unpacking cases where there is a similar bug lurking.
2006-08-13cpathname could be NULL if it was longer than MAXPATHLEN. Don't tryNeal Norwitz-1/+6
to write the .pyc to NULL. Check results of PyList_GetItem() and PyModule_GetDict() are not NULL. Klocwork 282, 283, 285
2006-08-04There were really two issuesNeal Norwitz-1/+2
2006-08-04Bug #1191458: tracing over for loops now produces a line eventNeal Norwitz-1/+2
on each iteration. I'm not positive this is the best way to handle this. I'm also not sure that there aren't other cases where the lnotab is generated incorrectly. It would be great if people that use pdb or tracing could test heavily. Also: * Remove dead/duplicated code that wasn't used/necessary because we already handled the docstring prior to entering the loop. * add some debugging code into the compiler (#if 0'd out).
2006-07-30Patch #1531113: Fix augmented assignment with yield expressions.Neal Norwitz-2/+3
Also fix a SystemError when trying to assign to yield expressions.
2006-07-28Bug #1529871: The speed enhancement patch #921466 broke Python's compliancePhillip J. Eby-34/+132
with PEP 302. This was fixed by adding an ``imp.NullImporter`` type that is used in ``sys.path_importer_cache`` to cache non-directory paths and avoid excessive filesystem operations during imports.
2006-07-21Speel initialise write. Tanks Anthony.Neal Norwitz-1/+1
2006-07-21Handle allocation failures gracefully. Found with failmalloc.Neal Norwitz-2/+7
Many (all?) of these could be backported.
2006-07-16Fix memory leak under some conditions.Neal Norwitz-7/+9
Reported by Klocwork, #98.
2006-07-12Actually change the MAGIC #. Create a new section for 2.5c1 and mention the ↵Neal Norwitz-1/+1
impact of changing the MAGIC #.
2006-07-12Bug #1520864: unpacking singleton tuples in for loop (for x, in) work again.Neal Norwitz-0/+1
2006-07-06Fix refleaks reported by Shane Hathaway in SF patch #1515361. This changeNeal Norwitz-2/+4
contains only the changes related to leaking the copy variable.
2006-05-28Correct None refcount issue in Mac modules. (Are theyGeorg Brandl-1/+1
still used?)
2006-05-28The empty string is a valid import path.Georg Brandl-2/+4
(fixes #1496539)
2006-05-26Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache ↵Georg Brandl-2/+30
valid and invalid file paths for the built-in import machinery which leads to fewer open calls on startup. Also fix issue with PEP 302 style import hooks which lead to more open() calls than necessary.
2006-05-25Replace PyObject_CallFunction calls with only object argsGeorg Brandl-3/+3
with PyObject_CallFunctionObjArgs, which is 30% faster.
2006-04-27 - Add new Warning class, ImportWarningThomas Wouters-7/+30
- Warn-raise ImportWarning when importing would have picked up a directory as package, if only it'd had an __init__.py. This swaps two tests (for case-ness and __init__-ness), but case-test is not really more expensive, and it's not in a speed-critical section. - Test for the new warning by importing a common non-package directory on sys.path: site-packages - In regrtest.py, silence warnings generated by the build-environment because Modules/ (which is added to sys.path for Setup-created modules) has 'zlib' and '_ctypes' directories without __init__.py's.
2006-04-13spread the extern "C" { } magic pixie dust around. Python itself builds nowAnthony Baxter-0/+7
using a C++ compiler. Still lots and lots of errors in the modules built by setup.py, and a bunch of warnings from g++ in the core.
2006-04-05Fix refleak in __import__("") (probably the cause of the 2 refleaks inThomas Wouters-0/+2
test_builtin.)
2006-04-04Fix __import__("") to raise ValueError rather than return None.Thomas Wouters-1/+10
2006-03-25Found this in an old email message from Hartmut Goebel.Skip Montanaro-0/+1
2006-03-20Use macro versions instead of function versions when we already know the type.Neal Norwitz-2/+2
This will hopefully get rid of some Coverity warnings, be a hint to developers, and be marginally faster. Some asserts were added when the type is currently known, but depends on values from another function.
2006-03-10Um, I thought I'd already checked this in.Guido van Rossum-0/+1
Anyway, this is the changes to the with-statement so that __exit__ must return a true value in order for a pending exception to be ignored. The PEP (343) is already updated.
2006-03-07Change int to Py_ssize_t in several places.Martin v. Löwis-4/+4
Add (int) casts to silence compiler warnings. Raise Python exceptions for overflows.
2006-02-28SF patch #1438387, PEP 328: relative and absolute imports.Thomas Wouters-13/+56
- IMPORT_NAME takes an extra argument from the stack: the relativeness of the import. Only passed to __import__ when it's not -1. - __import__() takes an optional 5th argument for the same thing; it __defaults to -1 (old semantics: try relative, then absolute) - 'from . import name' imports name (be it module or regular attribute) from the current module's *package*. Likewise, 'from .module import name' will import name from a sibling to the current module. - Importing from outside a package is not allowed; 'from . import sys' in a toplevel module will not work, nor will 'from .. import sys' in a (single-level) package. - 'from __future__ import absolute_import' will turn on the new semantics for import and from-import: imports will be absolute, except for from-import with dots. Includes tests for regular imports and importhooks, parser changes and a NEWS item, but no compiler-package changes or documentation changes.
2006-02-27PEP 343 -- the with-statement.Guido van Rossum-1/+2
This was started by Mike Bland and completed by Guido (with help from Neal). This still needs a __future__ statement added; Thomas is working on Michael's patch for that aspect. There's a small amount of code cleanup and refactoring in ast.c, compile.c and ceval.c (I fixed the lltrace behavior when EXT_POP is used -- however I had to make lltrace a static global).
2006-02-15Merge ssize_t branch.Martin v. Löwis-16/+18
2006-01-19Check return result from Py_InitModule*(). This API can fail.Neal Norwitz-0/+2
Probably should be backported.
2005-12-17Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,Neal Norwitz-3/+5
simplifies a lot of error handling code, and fixes many memory leaks.
2005-12-10Add const to several API functions that take char *.Jeremy Hylton-2/+2
In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
2005-10-21the ast-branch changed the stack discipline of MAKE_CLOSURE, so we need toMichael W. Hudson-1/+3
bump MAGIC.
2005-10-20Merge ast-branch to headJeremy Hylton-11/+12
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-03Fix SF bug #976608, Unhelpful error message when mtime of a module is -1Neal Norwitz-1/+5
Will backport.
2005-09-14- Changes donated by Elemental Security to make it work on AIX 5.3Guido van Rossum-0/+12
with IBM's 64-bit compiler (SF patch #1284289). This also closes SF bug #105470: test_pwd fails on 64bit system (Opteron).
2005-09-14Patch #1290454: Fix reload() error message when parent module is not inGeorg Brandl-2/+3
sys.modules.
2005-06-03This is my patch:Michael W. Hudson-1/+2
[ 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-05-20Patch #1197318: Cygwin case-sensitive import patchJason Tishler-17/+6
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.
2004-10-07SF patch #1035498: -m option to run a module as a scriptRaymond Hettinger-0/+16
(Contributed by Nick Coghlan.)
2004-09-23Fix for SF bug #1029475 : reload() doesn't work with PEP 302 loaders.Phillip J. Eby-4/+10
2004-09-22SF patch #1031667: Fold tuples of constants into a single constantRaymond Hettinger-1/+2
Example: >>> import dis >>> dis.dis(compile('1,2,3', '', 'eval')) 0 0 LOAD_CONST 3 ((1, 2, 3)) 3 RETURN_VALUE
2004-08-23SF Patch #1013667: Cleanup Peepholer OutputRaymond Hettinger-1/+2
* 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-02PyImport_ExecCodeModuleEx(): remove module from sys.modules in error cases.Tim Peters-16/+46
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-01lock_held() docs: Use True/False instead of 1/0. The LaTeX docs wereTim Peters-3/+3
already correct, so not changed here.
2004-08-01Trimmed trailing whitespace.Tim Peters-2/+2
2004-06-27Patch #923098: Share interned strings in marshal.Martin v. Löwis-9/+9
2004-06-07Fix a refcount bug in an obscure code corner.Thomas Heller-0/+1
Already backported.
2004-05-28starting to add comments to explain what's hereFred Drake-0/+11
2004-04-01Bump the magic number to avoid sharing bytecode between 2.3 and 2.4.Jeremy Hylton-30/+12
Revise the long comment that explained details of the magic number in gory detail.