Benjamin Peterson
a95e977e41
decrement offset when it points to a newline ( #10186 followup)
2010-10-29 03:28:14 +00:00
Antoine Pitrou
07e20ef50b
Issue #5437 : A preallocated MemoryError instance should not hold traceback
...
data (including local variables caught in the stack trace) alive infinitely.
2010-10-28 22:56:58 +00:00
Victor Stinner
07e4f1565b
sys_update_path(): update sys.path even if argc==0
2010-10-25 17:37:23 +00:00
Georg Brandl
08be72d0aa
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
...
except when configured --with-pydebug.
Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
2010-10-24 15:11:22 +00:00
Benjamin Peterson
d4519c14ca
tighten loop
2010-10-24 03:41:46 +00:00
Benjamin Peterson
503d6c5ae9
remove broken code accounting an offset the size of the line #10186
2010-10-24 02:52:05 +00:00
Benjamin Peterson
8035bc5c04
follow up to #9778 : define and use an unsigned hash type
2010-10-23 16:20:50 +00:00
Antoine Pitrou
9583cac633
Issue #10089 : Add support for arbitrary -X options on the command-line.
...
They can be retrieved through a new attribute `sys._xoptions`.
2010-10-21 13:42:28 +00:00
Benjamin Peterson
b8ffb60ec6
fix uninitialized struct member #10152
2010-10-20 21:25:23 +00:00
Victor Stinner
e474309bb7
initfsencoding(): get_codeset() failure is now a fatal error
...
Don't fallback to utf-8 anymore to avoid mojibake. I never got any error from
his function.
2010-10-19 00:05:51 +00:00
Benjamin Peterson
8f67d0893f
make hashes always the size of pointers; introduce Py_hash_t #9778
2010-10-17 20:54:53 +00:00
Victor Stinner
c049982ea5
compiler_error(): use PyUnicode_DecodeFSDefault() to decode the filename,
...
instead of utf-8 in strict mode.
2010-10-17 19:16:33 +00:00
Victor Stinner
15a71cdad2
PyErr_SyntaxLocationEx() uses PyUnicode_DecodeFSDefault(), instead of
...
PyUnicode_FromString(), to decode the filename.
2010-10-17 19:03:16 +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
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
0a1b8cba90
_Py_wrealpath() uses _Py_char2wchar() to decode the result, to support
...
surrogate characters.
2010-10-16 22:55:47 +00:00
Victor Stinner
350147b5ca
_Py_wreadlink(): catch _Py_char2wchar() failure
2010-10-16 22:52:09 +00:00
Victor Stinner
3f711f4a3e
_Py_wreadlink() uses _Py_char2wchar() to decode the result, to support
...
surrogate characters.
2010-10-16 22:47:37 +00:00
Victor Stinner
2f2ed1f36c
Fix ast_error_finish() and err_input(): filename can be NULL
...
Fix my previous commit (r85569).
2010-10-16 13:42:53 +00:00
Victor Stinner
4c7c8c3023
Issue #9713 , #10114 : Parser functions (eg. PyParser_ASTFromFile) expects
...
filenames encoded to the filesystem encoding with surrogateescape error handler
(to support undecodable bytes), instead of UTF-8 in strict mode.
2010-10-16 13:14:10 +00:00
Benjamin Peterson
230b20684f
don't identify the toplevel namespace by name #9997
2010-10-16 03:45:45 +00:00
Benjamin Peterson
294a9fcba6
fix refleak
2010-10-16 03:12:39 +00:00
Barry Warsaw
8cf4eae522
First (uncontroversial) part of issue 9807.
...
* Expose the build flags to Python as sys.abiflags
* Shared library libpythonX.Y<abiflags>.so
* python-config --abiflags
* Make two distutils tests that failed with --enable-shared (even before this
patch) succeed.
* Fix a few small style issues.
2010-10-16 01:04:07 +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
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
6a4aff10f0
redecode_filename(): don't need to initialize variables
2010-10-15 11:16:59 +00:00
Victor Stinner
5d1e3438cd
Mark _Py_char2wchar() input argument as constant
2010-10-15 11:15:54 +00:00
Antoine Pitrou
b86680e299
Explicitly close some files (from issue #10093 )
2010-10-14 21:15:17 +00:00
Victor Stinner
f4061dac60
_Py_wgetcwd() decodes the path using _Py_char2wchar() to support surrogates
2010-10-14 12:37:19 +00:00
Victor Stinner
8f6b6b0cc3
Issue #9992 : Remove PYTHONFSENCODING environment variable.
2010-10-13 22:02:27 +00:00
Victor Stinner
a00064576a
ceval.c: catch recursion error on _PyUnicode_AsString(co->co_filename)
2010-10-13 10:48:55 +00:00
Antoine Pitrou
19f8edc39d
Issue #10062 : Allow building on platforms which do not have sem_timedwait.
2010-10-10 08:37:22 +00:00
Victor Stinner
6672d0c5bb
fileutils.c: document which encodings are used
2010-10-07 22:53:43 +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
e7c8083bf1
Ooops, fileutils.c contains twice the same code
...
I suppose that I reapplied my local patch creating Python/fileutils.c whereas
the file already existed.
2010-10-07 21:55:44 +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
7ae7c87b05
_wrealpath() and _Py_wreadlink() support surrogates (PEP 383)
...
Use _Py_wchar2char() to support surrogate characters in the input path.
2010-10-07 11:06:49 +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
c08ec9fdba
Create a subfunction for PySys_SetArgvEx()
...
Create sys_update_path() static function. Do nothing if argc==0.
2010-10-06 22:44:06 +00:00
Amaury Forgeot d'Arc
90774dd47b
#9060 Let platforms without dup2() compile the replacement fonction without error.
2010-10-05 22:15:37 +00:00
Brian Curtin
748cacee46
Remove an unreferenced variable. len is no longer needed.
2010-09-29 19:09:33 +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
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
5305a998d5
Since __import__ is not designed for general use, have its docstring point
...
people towards importlib.import_module().
Closes issue #7397 .
2010-09-27 21:08:38 +00:00