Commit Graph

442 Commits

Author SHA1 Message Date
Victor Stinner d417d01ec8 call_find_module() handles dup() failure: raise an OSError exception 2011-06-20 15:16:55 +02:00
Victor Stinner 925ef39949 find_module_path_list() fails if _Py_fopen() failed and raised an exception
(UnicodeEncodeError).
2011-06-20 15:01:10 +02:00
Benjamin Peterson e7c15fa184 bump magic for super closure change 2011-06-19 19:54:45 -05:00
Benjamin Peterson 48deae12d5 some horrible preprocessing tricks to automatically update the tag 2011-06-03 17:50:16 -05:00
Victor Stinner 25095b2be6 Remove useless assignments
Warnings found by the the Clang Static Analyzer.
2011-05-26 13:47:08 +02:00
Benjamin Peterson 04778a8150 make PyImport_ImportModuleLevel's first arg const like similiar functions (closes #12173) 2011-05-25 09:29:00 -05:00
Victor Stinner 783c82c701 Close #11619: write_compiled_module() doesn't encode the filename
Reimplement open_exclusive() using _wopen() to avoid encoding the filename to
the filesystem encoding: use the Unicode version of the Windows API.
2011-04-20 03:27:51 +02:00
Victor Stinner fe7c5b5bdf Issue #9319: Include the filename in "Non-UTF8 code ..." syntax error. 2011-04-05 01:48:03 +02:00
Brett Cannon 442c9b92d8 Make importlib compatible with __import__ by "fixing" code.co_filename
paths.

__import__ does a little trick when importing from bytecode by
back-patching the co_filename paths to point to the file location
where the code object was loaded from, *not* where the code object was
originally created. This allows co_filename to point to a valid path.
Problem is that co_filename is immutable from Python, so a private
function -- imp._fix_co_filename() -- had to be introduced in order to
get things working properly. Originally the plan was to add a file
argument to marshal.loads(), but that failed as the algorithm used by
__import__ is not fully recursive as one might expect, so to be fully
backwards-compatible the code used by __import__ needed to be exposed.

This closes issue #6811 by taking a different approach than outlined
in the issue.
2011-03-23 16:14:42 -07:00
Victor Stinner e9ddbf65a8 Issue #11630, issue #3080: Fix refleak introduced by ef2b6305d395 2011-03-22 10:46:35 +01:00
Victor Stinner 9c61e24be4 Issue #3080: On DJGPP, case_bytes() returns -1 to signal an error if the file
cannot be found.
2011-03-22 01:22:27 +01:00
Victor Stinner 6ae1e7f04e Issue #3080: imp.load_module() accepts None for the module path
imp.find_module() returns None as module path for builtin and frozen builtins.
2011-03-20 22:37:17 +01:00
Victor Stinner cc9564ecd8 Issue #3080: Fix call to case_ok() in find_init_module() 2011-03-20 04:58:29 +01:00
Victor Stinner 1304f2d8a3 Issue #3080: Fix case_ok() using case_bytes()
Invert name and namelen arguments.
2011-03-20 04:28:55 +01:00
Victor Stinner fe93faf98c Issue #3080: Add PyImport_ImportModuleLevelObject() function
Use it for the builtin __import__ function.
2011-03-14 15:54:52 -04:00
Victor Stinner 98dbba5d20 Issue #3080: Use repr() to format the module name on error 2011-03-14 15:15:47 -04:00
Victor Stinner ccbf475dfd Fix imp.cache_from_source() if the directory name contains a dot
If the directory name contains a dot but not the filename, don't strip at the
dot.
2011-03-14 15:05:12 -04:00
Victor Stinner fe19d21815 Issue #3080: imp.new_module() uses Unicode 2011-03-14 14:53:28 -04:00
Victor Stinner 2fd76e478f Issue #3080: find_module() returns the path as Unicode 2011-03-14 15:19:39 -04:00
Victor Stinner c9a271cf2b Issue #3080: case_ok() expects Unicode strings 2011-03-14 14:34:13 -04:00
Victor Stinner 547a2a6d52 Issue #3080: find_init_module() expects Unicode 2011-03-20 03:07:28 +01:00
Victor Stinner d029621c70 Issue #3080: Refactor find_module_path(), use return instead of break
Prepare also the API change of case_ok()
2011-03-14 14:04:10 -04:00
Victor Stinner df75a023a0 Issue #3080: find_module() sets an empty path for builtin and frozen modules 2011-03-14 13:40:04 -04:00
Victor Stinner 533d78399f Issue #3080: Rename some path variables to path_list 2011-03-14 13:22:54 -04:00
Victor Stinner ad3c03b23e Issue #3080: find_module() expects module fullname and subname as Unicode
And PyImport_ReloadModule() uses Unicode for the module name.
2011-03-14 09:21:33 -04:00
Victor Stinner 58d37112ae Issue #3080: Drop OS/2 support for the import machinery
Sorry Andrew I MacIntyre!
2011-03-13 23:11:02 -04:00
Victor Stinner 9599de5110 Issue #3080: Reindent and simplify import_submodule() 2011-03-13 22:38:38 -04:00
Victor Stinner c24c8108b6 Issue #3080: Use %R to format module name in error messages
%R format instead of %U
2011-03-13 22:38:06 -04:00
Victor Stinner 974389d92c Issue #3080: Use Unicode for the "The Magnum Opus of dotted-name import"
Use Unicode for module name and paths in the following functions:

 * PyImport_ImportModuleLevel()
 * add_submodule()
 * ensure_from_list()
 * get_parent()
 * import_module_level()
 * import_submodule()
 * load_next()
 * mark_miss()
2011-03-15 09:33:57 +01:00
Victor Stinner 2e5f11aaa4 Issue #3080: PyImport_ImportModuleNoBlock() uses Unicode 2011-03-13 21:57:27 -04:00
Victor Stinner 41c5fecce0 Issue #3080: load_module() expects name and path as Unicode 2011-03-13 21:46:30 -04:00
Victor Stinner 2f42ae53aa Issue #3080: Use Unicode to import source and compiled modules
* Use Unicode for module name and path in the following functions:

   * get_file()
   * load_source_module(), parse_source_module()
   * make_compiled_pathname(), check_compiled_module(),
     read_compiled_module(), load_compiled_module(), write_compiled_module(),
     update_compiled_module()

 * On Windows, use CreateDirectoryW() instead of mkdir()
 * update_compiled_module() cannot fail anymore
2011-03-20 00:41:24 +01:00
Victor Stinner c9abda0c04 Issue #3080: get_sourcefile(), make_source_pathname(), load_package()
Use Unicode for module name and path in get_sourcefile(),
make_source_pathname() and load_package() functions.
2011-03-14 13:33:46 -04:00
Victor Stinner d68c2cf237 Issue #3080: Create find_module_path() subfunction 2011-03-12 16:02:28 -05:00
Victor Stinner 3758028299 Issue #3080: Create find_module_path_list() subfunction 2011-03-20 01:34:43 +01:00
Victor Stinner c696316466 Issue #3080: Remove useless name buffer from find_module()
Rename subname argument to name, and mark it as constant.
2011-03-12 09:26:54 -05:00
Victor Stinner 7d8b77c2aa Issue #3080: find_module() initialize buf and *p_fp
Document also the find_module() function
2011-03-12 08:45:02 -05:00
Victor Stinner fefd70c40d Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and path
Document also that dynamic module names are ASCII only
2011-03-14 15:54:07 -04:00
Victor Stinner 4d6c1c476a Issue #3080: _PyWin_FindRegisteredModule() returns the path as Unicode
* Document the function
 * Use RegQueryValueW() instead of RegQueryValueA()
 * Use _Py_fopen() instead of fopen()
 * Allocate registry key on the heap, not on the stack, and handle memory
   allocation failure
 * Handle Python exception in find_module()
2011-03-08 23:49:04 +01:00
Victor Stinner 21fcd0c9af Issue #3080: Use PyUnicode_InternFromString() for builtins
_PyImport_FixupBuiltin() and _PyImport_FindBuiltin() use
PyUnicode_InternFromString() instead of PyUnicode_FromString().
2011-03-07 18:28:15 +01:00
Victor Stinner 9587286f98 Issue #3080: Import builtins using Unicode strings
- is_builtin(), init_builtin(), load_builtin() and other builtin related
   functions use Unicode strings, instead of byte strings
 - Rename _PyImport_FixupExtensionUnicode() to _PyImport_FixupExtensionObject()
 - Rename _PyImport_FindExtensionUnicode() to _PyImport_FindExtensionObject()
2011-03-07 18:20:56 +01:00
Victor Stinner 53dc735168 Issue #3080: Add PyImport_ImportFrozenModuleObject()
find_frozen(), get_frozen_object(), is_frozen_package() and other functions
related to frozen modules use Unicode strings instead of byte strings.
2011-03-20 01:50:21 +01:00
Victor Stinner 9464d61cba Issue #3080: PyImport_Cleanup() uses Unicode
Replace strcmp() by PyUnicode_CompareWithASCIIString()
2011-03-07 17:08:21 +01:00
Victor Stinner 942003ccf9 import.c: replace tab by spaces 2011-03-07 16:57:48 +01:00
Victor Stinner 27ee089c35 Issue #3080: Add PyImport_AddModuleObject() and PyImport_ExecCodeModuleObject() 2011-03-04 12:57:09 +00:00
Victor Stinner 501c09a754 Issue #3080: Mark _PyImport_FindBuiltin() argument as constant
And as a consequence, mark also name argument of
_PyImport_FindExtensionUnicode() constant too. But I plan to change this
argument type to PyObject* later.
2011-02-23 00:02:00 +00:00
Victor Stinner 9b99b448f7 Issue #3080: Mark PyWin_FindRegisteredModule() as private
This function was not declared in Python public API (in any .h file) and not
documented. Mark it as private to prepare a change of its API.
2011-02-22 23:12:28 +00:00
Martin v. Löwis 4d0d471a80 Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
Victor Stinner ebc0052e3a import: use PyUnicode_FSConverter to support bytes path and PEP 383
(instead of PyArg_Parse*() with "es" format and Py_FileSystemDefaultEncoding)
2010-12-03 17:06:43 +00:00
Nick Coghlan b2ddf7979d Issue #9573: os.fork now works when triggered as a side effect of import (the wisdom of actually relying on this remains questionable!) 2010-12-02 04:11:46 +00:00