Commit Graph

413 Commits

Author SHA1 Message Date
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
Georg Brandl e5b99f0fb3 Remove redundant includes of headers that are already included by Python.h. 2010-11-30 09:41:01 +00:00
Victor Stinner 3e2b7171bf Issue #10359: Remove ";" after function definition, invalid in ISO C 2010-11-09 09:32:19 +00:00
Victor Stinner ed7916dd00 find_module(): use FS encoding to display the missing __init__ warning 2010-10-17 02:07:09 +00:00
Victor Stinner 49d3f2514b _PyImport_FixupExtension() and _PyImport_FindExtension() uses FS encoding
* Rename _PyImport_FindExtension() to _PyImport_FindExtensionUnicode():
   the filename becomes a Unicode object instead of byte string
 * Rename _PyImport_FixupExtension() to _PyImport_FixupExtensionUnicode():
   the filename becomes a Unicode object instead of byte string
2010-10-17 01:24:53 +00:00
Benjamin Peterson 294a9fcba6 fix refleak 2010-10-16 03:12:39 +00:00
Victor Stinner 88bd891e6c Fix imp_cache_from_source(): Decode make_compiled_pathname() result from the
filesystem encoding instead of utf-8.

imp_cache_from_source() encodes the input path to filesystem encoding and this
path is passed to make_compiled_pathname().
2010-10-15 22:46:07 +00:00
Victor Stinner 1a5630326f imp_load_module() uses PyUnicode_FSConverter() to support surrogates in module
path
2010-10-15 22:43:10 +00:00
Victor Stinner 3ea23ddabf imp.cache_from_source() uses PyUnicode_FSConverter() to support surrogates in
module path
2010-10-15 20:34:32 +00:00
Victor Stinner 8dbf629bbd imp.load_dynamic() uses PyUnicode_FSConverter() to support surrogates
in the library path.
2010-10-15 12:48:01 +00:00
Victor Stinner 4e31443c4d Create fileutils.c/.h
* _Py_fopen() and _Py_stat() come from Python/import.c
 * (_Py)_wrealpath() comes from Python/sysmodule.c
 * _Py_char2wchar(), _Py_wchar2char() and _Py_wfopen() come from Modules/main.c
 * (_Py)_wstat(), (_Py)_wgetcwd(), _Py_wreadlink() come from Modules/getpath.c
2010-10-07 21:45:39 +00:00
Victor Stinner beb4135b8c PyUnicode_AsWideCharString() takes a PyObject*, not a PyUnicodeObject*
All unicode functions uses PyObject* except PyUnicode_AsWideChar(). Fix the
prototype for the new function PyUnicode_AsWideCharString().
2010-10-07 01:02:42 +00:00
Brian Curtin 748cacee46 Remove an unreferenced variable. len is no longer needed. 2010-09-29 19:09:33 +00:00
Victor Stinner 255dfdb5ce Issue #9979: Use PyUnicode_AsWideCharString() in import.c
Don't truncate path if it is too long anymore, and allocate fewer memory (but
allocate it on the heap, not on the stack).
2010-09-29 10:28:51 +00:00
Brett Cannon bc2eff3112 PyImport_Import was using the old import hack of sticking a dummy value into
fromlist to get __import__ to return the module desired. Now it uses the proper
approach of fetching the module from sys.modules.

Closes issue #9252. Thanks to Alexander Belopolsky for the bug report.
2010-09-19 21:39:02 +00:00
Nick Coghlan cd419abe42 Fix incorrect comment regarding MAGIC and TAG in import.c 2010-09-11 00:39:25 +00:00
Benjamin Peterson 6246d6dcb0 bump magic number for DELETE_DEREF 2010-09-10 21:51:44 +00:00
Daniel Stutzbach c7937791a1 Fix Issue #9752: MSVC compiler warning due to undefined function
(Patch by Jon Anglin)
2010-09-09 21:18:04 +00:00
Antoine Pitrou 74a69fa662 Issue #9225: Remove the ROT_FOUR and DUP_TOPX opcode, the latter replaced
by the new (and simpler) DUP_TOP_TWO.  Performance isn't changed, but
our bytecode is a bit simplified.  Patch by Demur Rumed.
2010-09-04 18:43:52 +00:00
Victor Stinner 6b06da5395 Remove unused functions _PyImport_FindModule and _PyImport_IsScript 2010-08-17 22:54:21 +00:00
Victor Stinner f52b705be4 Create _Py_fopen() for PyUnicodeObject path
Call _wfopen() on Windows, or fopen() otherwise. Return the new file object on
success, or NULL if the file cannot be open or (if PyErr_Occurred()) on unicode
error.
2010-08-14 17:06:04 +00:00
Victor Stinner 8a79dccc48 _Py_stat(): ensure that path ends with a nul character 2010-08-14 16:59:08 +00:00
Victor Stinner 4f4402c4bb Issue #9425: Create private _Py_stat() function
Use stat() or _wstat() depending on the OS.
2010-08-14 14:50:26 +00:00
Victor Stinner 1a4d12d746 Issue #9425: NullImporter constructor is fully unicode compliant
* On non-Windows OSes: the constructor accepts bytes filenames
   and use surrogateescape for unicode filenames
 * On Windows: use GetFileAttributesW() instead of GetFileAttributesA()
2010-08-13 13:07:29 +00:00
Victor Stinner 44c6c155d6 Issue #9425: Create load_builtin() subfunction
Just move the code and some variables.
2010-08-09 00:59:10 +00:00
Benjamin Peterson 556d8001df Merged revisions 81380 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81380 | brett.cannon | 2010-05-20 13:37:55 -0500 (Thu, 20 May 2010) | 8 lines

  Turned out that if you used explicit relative import syntax
  (e.g. from .os import sep) and it failed, import would still try the implicit
  relative import semantics of an absolute import (from os import sep). That's
  not right, so when level is negative, only do explicit relative import
  semantics.

  Fixes issue #7902. Thanks to Meador Inge for the patch.
........
2010-06-27 22:37:28 +00:00
Barry Warsaw 7c9627b4de Typo repair. 2010-06-17 18:38:20 +00:00
Victor Stinner ae6265f8d0 Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
object to Py_FileSystemDefaultEncoding with the "surrogateescape" error
handler, return a bytes object. If Py_FileSystemDefaultEncoding is not set,
fall back to UTF-8.
2010-05-15 16:27:27 +00:00
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:52:27 +00:00
Barry Warsaw 28a691b7fd PEP 3147 2010-04-17 00:19:56 +00:00