Commit Graph

1647 Commits

Author SHA1 Message Date
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
Victor Stinner 168e117e0a Add an optional size argument to _Py_char2wchar()
_Py_char2wchar() callers usually need the result size in characters. Since it's
trivial to compute it in _Py_char2wchar() (O(1) whereas wcslen() is O(n)), add
an option to get it.
2010-10-16 23:16:16 +00:00
Victor Stinner f3170ccef8 Use locale encoding if Py_FileSystemDefaultEncoding is not set
* PyUnicode_EncodeFSDefault(), PyUnicode_DecodeFSDefaultAndSize() and
   PyUnicode_DecodeFSDefault() use the locale encoding instead of UTF-8 if
   Py_FileSystemDefaultEncoding is NULL
 * redecode_filenames() functions and _Py_code_object_list (issue #9630)
   are no more needed: remove them
2010-10-15 12:04:23 +00:00
Victor Stinner 5d1e3438cd Mark _Py_char2wchar() input argument as constant 2010-10-15 11:15:54 +00:00
Georg Brandl 8349031934 Post-release bumps. 2010-10-12 12:38:48 +00:00
Georg Brandl 002fa2de90 Bump to 3.2a3. 2010-10-10 09:40:34 +00:00
Victor Stinner 257d38ffdd Issue #9738: Document PyErr_SetString() and PyErr_SetFromErrnoWithFilename()
encodings
2010-10-09 10:12:11 +00:00
Victor Stinner 015f4d87ab _Py_wrealpath() requires the size of the output buffer 2010-10-07 22:29:53 +00:00
Victor Stinner a4a759515e _Py_stat() and _Py_fopen(): avoid PyUnicode_AsWideCharString() on Windows
On Windows, Py_UNICODE is wchar_t, so we can avoid the expensive Py_UNICODE*
=> wchar_t* conversion.
2010-10-07 22:23:10 +00:00
Victor Stinner b306d7594f Fix fileutils for Windows
* Don't define _Py_wstat() on Windows, Windows has its own _wstat() function
   with a different API (the stat buffer has another type)
 * Include windows.h
2010-10-07 22:09:40 +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
Victor Stinner c39211f51e Issue #9630: Redecode filenames when setting the filesystem encoding
Redecode the filenames of:

 - all modules: __file__ and __path__ attributes
 - all code objects: co_filename attribute
 - sys.path
 - sys.meta_path
 - sys.executable
 - sys.path_importer_cache (keys)

Keep weak references to all code objects until initfsencoding() is called, to
be able to redecode co_filename attribute of all code objects.
2010-09-29 16:35:47 +00:00
Victor Stinner 137c34c027 Issue #9979: Create function PyUnicode_AsWideCharString(). 2010-09-29 10:25:54 +00:00
Antoine Pitrou 3e1fd27b74 Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
retry the select() loop instead of bailing out.  This is because select()
can incorrectly report a socket as ready for reading (for example, if it
received some data with an invalid checksum).
2010-09-28 21:23:11 +00:00
Kristján Valur Jónsson 3b69db27d7 issue 9910
Add a Py_SetPath api to override magic path computations when starting up python.
2010-09-27 05:32:54 +00:00
Benjamin Peterson d4efd9eb15 add column offset to all syntax errors 2010-09-20 23:02:10 +00:00
Benjamin Peterson 2c53971b37 add PyErr_SyntaxLocationEx, to support adding a column offset 2010-09-20 22:42:10 +00:00
Daniel Stutzbach 38615993b0 Remove pointers to a FAQ entry that no longer exists. Incorporate some text from the old FAQ into the docs 2010-09-14 16:02:01 +00:00
Antoine Pitrou 1df1536fb9 Issue #9828: Destroy the GIL in Py_Finalize(), so that it gets properly
re-created on a subsequent call to Py_Initialize().  The problem (a crash)
wouldn't appear in 3.1 or 2.7 where the GIL's structure is more trivial.
2010-09-13 14:16:46 +00:00
Amaury Forgeot d'Arc feb7307db4 #9210: remove --with-wctype-functions configure option.
The internal unicode database is now always used.

(after 5 years: see
  http://mail.python.org/pipermail/python-dev/2004-December/050193.html
)
2010-09-12 22:42:57 +00:00
Hirokazu Yamamoto f13c6d8d34 Issue #9318: Use Py_LL for old compiler. 2010-09-11 22:35:24 +00:00
Victor Stinner 1205f2774e Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
a non-ASCII byte in the format string.

Document also the encoding.
2010-09-11 00:54:47 +00:00
Victor Stinner 5b519e0201 Issue #9632: Remove sys.setfilesystemencoding() function: use PYTHONFSENCODING
environment variable to set the filesystem encoding at Python startup.
sys.setfilesystemencoding() creates inconsistencies because it is unable to
reencode all filenames in all objects.
2010-09-10 21:57:59 +00:00
Amaury Forgeot d'Arc ba117ef7e9 #4617: Previously it was illegal to delete a name from the local
namespace if it occurs as a free variable in a nested block.  This limitation
of the compiler has been lifted, and a new opcode introduced (DELETE_DEREF).

This sample was valid in 2.6, but fails to compile in 3.x without this change::

   >>> def f():
   ...     def print_error():
   ...        print(e)
   ...     try:
   ...        something
   ...     except Exception as e:
   ...        print_error()
   ...        # implicit "del e" here


This sample has always been invalid in Python, and now works::

   >>> def outer(x):
   ...     def inner():
   ...        return x
   ...     inner()
   ...     del x

There is no need to bump the PYC magic number: the new opcode is used
for code that did not compile before.
2010-09-10 21:39:53 +00:00
Georg Brandl bad092556e Post-release update. 2010-09-05 21:29:17 +00:00
Georg Brandl 58a7b46075 Bump to 3.2a2. 2010-09-05 08:30:40 +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 46408606d8 Rename PyUnicode_strdup() to PyUnicode_AsUnicodeCopy() 2010-09-03 16:18:00 +00:00
Victor Stinner 71133ff368 Create PyUnicode_strdup() function 2010-09-01 23:43:53 +00:00
Victor Stinner c4eb765fc1 Create Py_UNICODE_strcat() function 2010-09-01 23:43:50 +00:00
Antoine Pitrou fce7fd6426 Issue #9549: sys.setdefaultencoding() and PyUnicode_SetDefaultEncoding()
are now removed, since their effect was inexistent in 3.x (the default
encoding is hardcoded to utf-8 and cannot be changed).
2010-09-01 18:54:56 +00:00
Antoine Pitrou f68c2a701b Issue #3101: Helper functions _add_one_to_C() and _add_one_to_F() become
_Py_add_one_to_C() and _Py_add_one_to_F(), respectively.
2010-09-01 12:58:21 +00:00
Daniel Stutzbach a606faa491 Issue 5553: Improved Py_LOCAL_INLINE to actually inline under compilers other than MSC 2010-08-31 19:51:07 +00:00
Antoine Pitrou 67c7ce4bef Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private
to the socket module, and fix the width of socket descriptors to be
correctly detected under 64-bit Windows.
2010-08-28 20:42:55 +00:00
Antoine Pitrou 1a9a9d5433 Issue #1868: Eliminate subtle timing issues in thread-local objects by
getting rid of the cached copy of thread-local attribute dictionary.
2010-08-28 18:17:03 +00:00
Amaury Forgeot d'Arc 324ac65ceb #5127: Even on narrow unicode builds, the C functions that access the Unicode
Database (Py_UNICODE_TOLOWER, Py_UNICODE_ISDECIMAL, and others) now accept
and return characters from the full Unicode range (Py_UCS4).

The differences from Python code are few:
- unicodedata.numeric(), unicodedata.decimal() and unicodedata.digit()
  now return the correct value for large code points
- repr() may consider more characters as printable.
2010-08-18 20:44:58 +00:00
Victor Stinner 6c00c1464f Issue #9425: Create PyModule_GetFilenameObject() function
... to get the filename as a unicode object, instead of a byte string. Function
needed to support unencodable filenames. Deprecate PyModule_GetFilename() in
favor on the new function.
2010-08-17 23:37:11 +00:00
Victor Stinner 6b06da5395 Remove unused functions _PyImport_FindModule and _PyImport_IsScript 2010-08-17 22:54:21 +00:00
Antoine Pitrou 671b4d948e Issue #9612: The set object is now 64-bit clean under Windows. 2010-08-17 17:55:07 +00:00
Victor Stinner ef8d95c498 Issue #9425: Create Py_UNICODE_strncmp() function
The code is based on strncmp() of the libiberty library,
function in the public domain.
2010-08-16 22:03:11 +00:00
Victor Stinner 79766636b6 Issue #9599: Create PySys_FormatStdout() and PySys_FormatStderr()
Write a message formatted by PyUnicode_FromFormatV() to sys.stdout and
sys.stderr.
2010-08-16 17:36:42 +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 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 47fcb5b4c3 Issue #9542: Create PyUnicode_FSDecoder() function
It's a ParseTuple converter: decode bytes objects to unicode using
PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is.

 * Don't specify surrogateescape error handler in the comments nor the
   documentation, but PyUnicode_DecodeFSDefaultAndSize() and
   PyUnicode_EncodeFSDefault() because these functions use strict error handler
   for the mbcs encoding (on Windows).
 * Remove PyUnicode_FSConverter() comment in unicodeobject.c to avoid
   inconsistency with unicodeobject.h.
2010-08-13 23:59:58 +00:00
Victor Stinner f2e08b34f1 Create _Py_wchar2char() function, reverse of _Py_char2wchar()
* Use _Py_wchar2char() in _wstat() and _Py_wfopen()
 * Document _Py_char2wchar()
2010-08-13 23:29:08 +00:00
Antoine Pitrou e9b428f997 Reimplement addbuilddir() in C inside getpath.c, so as to execute it
at interpreter startup before importing any non-builtin modules.
Should fix #9589.
2010-08-13 22:25:01 +00:00
Antoine Pitrou e81c806be7 De-duplicate contents of pytime.h 2010-08-13 15:25:56 +00:00
Victor Stinner 4a2b7a1b14 Issue #9425: Create PyErr_WarnFormat() function
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning
message.

Strip also some trailing spaces.
2010-08-13 14:03:48 +00:00
Alexander Belopolsky f0f45142d5 Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99
va_copy, but available on all python platforms.  Untabified a few
unrelated files.
2010-08-11 17:31:17 +00:00