Commit Graph

4502 Commits

Author SHA1 Message Date
Larry Hastings 581ee3618c Issue #20326: Argument Clinic now uses a simple, unique signature to
annotate text signatures in docstrings, resulting in fewer false
positives.  "self" parameters are also explicitly marked, allowing
inspect.Signature() to authoritatively detect (and skip) said parameters.

Issue #20326: Argument Clinic now generates separate checksums for the
input and output sections of the block, allowing external tools to verify
that the input has not changed (and thus the output is not out-of-date).
2014-01-28 05:00:08 -08:00
Larry Hastings 5c66189e88 Issue #20189: Four additional builtin types (PyTypeObject,
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
2014-01-24 06:17:25 -08:00
Serhiy Storchaka 2bd59daf58 Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^").  This still not
works correctly with wide East Asian characters.
2014-01-21 22:29:47 +02:00
Serhiy Storchaka 65fd0592fb Issue #2382: SyntaxError cursor "^" now is written at correct position in most
cases when multibyte characters are in line (before "^").  This still not
works correctly with wide East Asian characters.
2014-01-21 22:26:52 +02:00
Victor Stinner 2d854c8e7b Issue #20024: Py_BuildValue() now saves/restores the current exception before
building an item if the build of a previous item failed.
2014-01-21 20:52:17 +01:00
Stefan Krah 34e4628453 Merge from 3.3. 2014-01-20 15:35:38 +01:00
Stefan Krah 6c01e38677 Issue #19036: Including locale.h should not depend on HAVE_LANGINFO_H. 2014-01-20 15:31:08 +01:00
Larry Hastings b7ccb20423 Issue #20294: Argument Clinic now supports argument parsing for __new__ and
__init__ functions.
2014-01-18 23:50:21 -08:00
Larry Hastings bebf73511a Issue #20287: Argument Clinic's output is now configurable, allowing
delaying its output or even redirecting it to a separate file.
2014-01-17 17:47:17 -08:00
Brett Cannon a6dec2e744 Remove an unneeded cast. 2014-01-10 07:43:55 -05:00
Brett Cannon 4caa61d20e Issue #20152: import.c now uses Argument Clinic. 2014-01-09 19:03:32 -05:00
Eric Snow e4314e05d5 Issue 19713: Remove PEP 451-related code that should have been factored out.
This code was an artifact of issuing a DeprecationWarning for the lack
of loader.exec_module().  However, we have deferred such warnings to
later Python versions.
2014-01-07 23:29:19 -07:00
Larry Hastings 77561cccb2 Issue #20141: Improved Argument Clinic's support for the PyArg_Parse "O!"
format unit.
2014-01-07 12:13:13 -08:00
Eric Snow 1500d49c22 Issue 19713: Add PEP 451-related deprecations. 2014-01-06 20:49:04 -07:00
Eric Snow d749c7ae68 Issue #19927: Add __eq__ to path-based loaders in importlib. 2014-01-04 15:06:49 -07:00
Eric Snow fbc785188d Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder. 2014-01-02 22:25:00 -07:00
Benjamin Peterson a015bb1e2b merge 3.3 2013-12-31 22:02:41 -06:00
Benjamin Peterson fa10ae0978 update copyright year 2013-12-31 22:02:22 -06:00
Christian Heimes af01f66817 Issue #16136: Remove VMS support and VMS-related code 2013-12-21 16:19:10 +01:00
Victor Stinner ed0b87d73c Fix the C definition of the sys._debugmallocstats() function: the function has
no parameter
2013-12-19 17:16:42 +01:00
Victor Stinner 5272fa9c57 Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear
the exception to not call open() with an exception set.
2013-12-19 13:39:32 +01:00
Eric Snow 61e851baca Remove some dead code in importlib, introduced with the PEP 451 patch.
Early in the PEP 451 implementation some of the importlib loaders had
their own _get_spec() methods to simplify accommodating them.  However,
later implementations removed the need.  They simply failed to remove
this code at the same time. :)
2013-12-18 23:35:15 -07:00
Serhiy Storchaka 85c2497950 Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
2013-12-17 15:12:46 +02:00
Serhiy Storchaka 48d761e2b4 Issue #16404: Add checks for return value of PyLong_FromLong() in
sys.getwindowsversion() and ossaudiodev.setparameters().
Reported by Ned Batchelder.
2013-12-17 15:11:24 +02:00
Serhiy Storchaka 11ee080ea7 Fixed leak in sys.flags initialization. 2013-12-17 15:00:53 +02:00
Serhiy Storchaka 87a854dc73 Fixed leak in sys.flags initialization. 2013-12-17 14:59:42 +02:00
Victor Stinner 590cebe391 Issue #19787: PyThread_set_key_value() now always set the value
In Python 3.3, PyThread_set_key_value() did nothing if the key already exists
(if the current value is a non-NULL pointer).

When _PyGILState_NoteThreadState() is called twice on the same thread with a
different Python thread state, it still keeps the old Python thread state to
keep the old behaviour. Replacing the Python thread state with the new state
introduces new bugs: see issues #10915 and #15751.
2013-12-13 11:08:56 +01:00
Victor Stinner 441adb8c57 Backout changeset 46393019b650
test_capi is failing and the fix is not trivial, I prefer to revert
2013-12-13 04:14:41 +01:00
Victor Stinner cd0cb8ccd3 Close #19787: PyThread_set_key_value() now always set the value. In Python 3.3,
the function did nothing if the key already exists (if the current value is a
non-NULL pointer).

_testcapi.run_in_subinterp() now correctly sets the new Python thread state of
the current thread when a subinterpreter is created.
2013-12-13 03:22:00 +01:00
Victor Stinner fdeb6ec45a Issue #14432: Remove the thread state field from the frame structure. Fix a
crash when a generator is created in a C thread that is destroyed while the
generator is still used. The issue was that a generator contains a frame, and
the frame kept a reference to the Python state of the destroyed C thread. The
crash occurs when a trace function is setup.
2013-12-13 02:01:38 +01:00
Victor Stinner 62ca10051b Close #19576: PyGILState_Ensure() now initializes threads. At startup, Python
has no concrete GIL. If PyGILState_Ensure() is called from a new thread for the
first time and PyEval_InitThreads() was not called yet, a GIL needs to be
created.
2013-12-13 01:46:43 +01:00
Eric Snow b282b3d804 Issue #18864: Add a setter for ModuleSpec.has_location. 2013-12-10 22:16:41 -07:00
Victor Stinner 52ce3b04d0 Issue #19817: Fix print_exception(), clear the exception on error 2013-12-09 02:10:08 +01:00
Benjamin Peterson d45a46b60d merge 3.3 (#19910) 2013-12-06 20:12:51 -05:00
Benjamin Peterson 933142a8f2 document that compile() can take bytes (closes #19910) 2013-12-06 20:12:39 -05:00
Christian Heimes 724b828e79 upcast int to size_t to silence two autological-constant-out-of-range-compare warnings with clang. 2013-12-04 08:42:46 +01:00
Victor Stinner be0708f066 Closes #19831: Stop tracemalloc later at Python shutdown to be able to use
tracemalloc in objects destructor

Replace atexit handler with an harcoded C function _PyTraceMalloc_Fini().
2013-12-01 10:03:26 +01:00
Brett Cannon d2476c6e4b Issue #19698: Remove exec_module() from the built-in and extension
module loaders.

Due to the fact that the call signatures for extension modules and
built-in modules does not allow for the specifying of what module to
initialize and that on Windows all extension modules are built-in
modules, work to clean up built-in and extension module initialization
will have to wait until Python 3.5. Because of this the semantics of
exec_module() would be incorrect, so removing the methods for now is
the best option; load_module() is still used as a fallback by
importlib and so this won't affect semantics.
2013-11-29 11:00:11 -05:00
Mark Dickinson 1df88677e9 Issue #19638: Merge from 3.3 2013-11-26 16:19:38 +00:00
Mark Dickinson f45bbb6211 Issue #19638: Raise ValueError instead of crashing when converting billion character strings to float. 2013-11-26 16:19:13 +00:00
Zachary Ware a4b7a7548c Issue #3158: doctest can now find doctests in functions and methods
written in C.

As a part of this, a few doctests have been added to the builtins module
(on hex(), oct(), and bin()), a doctest has been fixed (hopefully on all
platforms) on float, and test_builtins now runs doctests in builtins.
2013-11-24 01:19:09 -06:00
Larry Hastings 3a9079742f Issue #19722: Added opcode.stack_effect(), which accurately
computes the stack effect of bytecode instructions.
2013-11-23 14:49:22 -08:00
Antoine Pitrou 8933521b3d Fix refleak introduced by 4f730c045f5f (issue #18408) and unveiled by 95eea8624d05 (issue #16596). 2013-11-23 14:05:23 +01:00
Victor Stinner ed3b0bca3e Issue #18874: Implement the PEP 454 (tracemalloc) 2013-11-23 12:27:24 +01:00
Brett Cannon 224b261258 User the repr for a module name in more places 2013-11-22 14:52:36 -05:00
Brett Cannon 175e7257b1 Remove a commented-out line 2013-11-22 12:07:43 -05:00
Brett Cannon fddc311fe8 Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows) 2013-11-22 11:58:17 -05:00
Eric Snow b523f8433a Implement PEP 451 (ModuleSpec). 2013-11-22 09:05:39 -07:00
Nick Coghlan c72e4e6dcc Issue #19619: Blacklist non-text codecs in method API
str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings,
rather than attempting the encoding or decoding operation and
then throwing a TypeError for an unexpected output type.

The latter mechanism remains in place for third party non-text
encodings.
2013-11-22 22:39:36 +10:00
Guido van Rossum 8820c239f7 Better behavior when stepping over yield[from]. Fixes issue 16596. By Xavier de Gaye. 2013-11-21 11:30:06 -08:00
Christian Heimes a5bcd7c0ee Issue #19183: too many tests depend on the sort order of repr().
The bitshift and xor op for 32bit builds has changed the order of hash values.
2013-11-20 12:49:05 +01:00
Christian Heimes 985ecdcfc2 ssue #19183: Implement PEP 456 'secure and interchangeable hash algorithm'.
Python now uses SipHash24 on all major platforms.
2013-11-20 11:46:18 +01:00
Victor Stinner f8e3221fa5 Issue #9566, #19617: Fix more compiler warnings in compile.c on Windows 64-bit 2013-11-19 23:56:34 +01:00
Victor Stinner 85fe8a645e Issue #9566, #19617: New try to fix compilation on Windows
Some compilers (ex: Visual Studio) decode -2147483648 as a unsigned integer
instead of an signed integer.
2013-11-19 23:03:25 +01:00
Victor Stinner b679a2eb78 Issue #9566, #19617: Fix compilation on Windows
INT32_MIN and INT32_MAX constants are unknown on Windows.
2013-11-19 22:28:01 +01:00
Victor Stinner ad9a066050 Issue #9566: compile.c uses Py_ssize_t instead of int to store sizes to fix
compiler warnings on Windows 64-bit. Use Py_SAFE_DOWNCAST() where the final
downcast is needed.

The bytecode doesn't support integer parameters larger than 32-bit yet.
2013-11-19 22:23:20 +01:00
Victor Stinner 4a58707a34 Add _PyUnicodeWriter_WriteASCIIString() function 2013-11-19 12:54:53 +01:00
Serhiy Storchaka 58cf607d13 Issue #12892: The utf-16* and utf-32* codecs now reject (lone) surrogates.
The utf-16* and utf-32* encoders no longer allow surrogate code points
(U+D800-U+DFFF) to be encoded.
The utf-32* decoders no longer decode byte sequences that correspond to
surrogate code points.
The surrogatepass error handler now works with the utf-16* and utf-32* codecs.

Based on patches by Victor Stinner and Kang-Hao (Kenny) Lu.
2013-11-19 11:32:41 +02:00
Victor Stinner cb29ec5f74 PY_FORMAT_SIZE_T should not be used with PyErr_Format(), PyErr_Format("%zd") is
portable
2013-11-18 02:05:31 +01:00
Victor Stinner 74387f5cac Use Py_ssize_t type for sizes in getargs.c
Fix compiler warnings on Windows 64-bit
2013-11-18 01:21:12 +01:00
Victor Stinner b11d6cb711 fileutils.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not declared on IRIX nor Windows.
2013-11-15 18:14:11 +01:00
Victor Stinner 2384714819 sysmodule.c: fix sys_update_path(), use Py_ARRAY_LENGTH() to get the size of
the fullpath buffer, not PATH_MAX. fullpath is declared using MAXPATHLEN or
MAX_PATH depending on the OS, and PATH_MAX is not declared on IRIX.
2013-11-15 17:33:43 +01:00
Victor Stinner 2f5bbc6a12 pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get the size of
the env_home buffer, not PATH_MAX+1. env_home is declared using MAXPATHLEN+1,
and PATH_MAX is not declared on IRIX.
2013-11-15 17:09:24 +01:00
Victor Stinner da062558db Fix compiler warning (on Windows 64-bit): explicit cast Py_ssize_t to unsigned
char, n is in range [0; 255] (a tuple cannot have a negative length)
2013-11-16 00:13:29 +01:00
Victor Stinner 0c083461a5 Fix compiler warning in win32_urandom(): explicit cast to DWORD in
CryptGenRandom()
2013-11-15 23:26:25 +01:00
Victor Stinner c31ebb60f9 (Merge 3.3) fileutils.c: use MAXPATHLEN instead of PATH_MAX
PATH_MAX is not declared on IRIX nor Windows.
2013-11-15 18:14:33 +01:00
Victor Stinner 50e0157013 (Merge 3.3) sysmodule.c: fix sys_update_path(), use Py_ARRAY_LENGTH() to get
the size of the fullpath buffer, not PATH_MAX. fullpath is declared using
MAXPATHLEN or MAX_PATH depending on the OS, and PATH_MAX is not declared on
IRIX.
2013-11-15 17:35:31 +01:00
Victor Stinner b5a7a0aa3f (Merge 3.3) pythonrun.c: fix Py_GetPythonHome(), use Py_ARRAY_LENGTH() to get
the size of the env_home buffer, not PATH_MAX+1. env_home is declared using
MAXPATHLEN+1, and PATH_MAX is not declared on IRIX.
2013-11-15 17:12:14 +01:00
Nick Coghlan c4c2580d43 Close 19609: narrow scope of codec exc chaining 2013-11-15 21:47:37 +10:00
Victor Stinner 5eb4f59cd9 Issue #19437: Fix init_builtin(), handle _PyImport_FindExtensionObject()
failure
2013-11-14 22:38:52 +01:00
Stefan Krah 49d0479357 Add unused third arg for the benefit of Valgrind. 2013-11-14 15:35:47 +01:00
Victor Stinner c82729e44f Issue #19437: Fix fold_unaryops_on_constants() of the peephole optimizer, clear
the exception when PyList_Append() fails
2013-11-14 01:21:00 +01:00
Nick Coghlan 8b097b4ed7 Close #17828: better handling of codec errors
- output type errors now redirect users to the type-neutral
  convenience functions in the codecs module
- stateless errors that occur during encoding and decoding
  will now be automatically wrapped in exceptions that give
  the name of the codec involved
2013-11-13 23:49:21 +10:00
Victor Stinner 22af2599a9 Issue #19437: Fix PyImport_ImportModuleLevelObject(), handle
PyUnicode_Substring() failure (ex: MemoryError)
2013-11-13 12:11:36 +01:00
Victor Stinner 3f36a5736b Issue #19515: Remove identifiers duplicated in the same file.
Patch written by Andrei Dorian Duma.
2013-11-12 21:39:02 +01:00
Victor Stinner dcf17f8a55 Issue #19466: Fix typo. Patch written by Vajrasky Kok. 2013-11-12 17:18:51 +01:00
Victor Stinner 45956b9a33 Close #19466: Clear the frames of daemon threads earlier during the Python
shutdown to call objects destructors. So "unclosed file" resource warnings are
now corretly emitted for daemon threads.
2013-11-12 16:37:55 +01:00
Victor Stinner bd303c165b Issue #19512, #19515: remove shared identifiers, move identifiers where they
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
2013-11-07 23:07:29 +01:00
Victor Stinner efa7a0e155 print_error_text() doesn't encode the filename anymore
Use aslo PyUnicode_FromFormat() to format the line so only one call to
PyFile_WriteObject() is needed. tb_displayline() of Python/traceback.c has
similar implementation.
2013-11-07 12:37:56 +01:00
Victor Stinner 79ed4c744a remove an outdated comment
The comment is meaningless since changeset 4e985a96a612.
2013-11-07 00:53:56 +01:00
Victor Stinner 53e9ec48e5 Issue #19512: Use the new _PyId_builtins identifier 2013-11-07 00:43:05 +01:00
Victor Stinner ad14ccd047 Issue #19512: add _PyUnicode_CompareWithId() function
_PyUnicode_CompareWithId() is faster than PyUnicode_CompareWithASCIIString()
when both strings are equal and interned.

Add also _PyId_builtins identifier for "builtins" common string.
2013-11-07 00:46:04 +01:00
Victor Stinner 937114f704 print_exception(): don't encode the module name to UTF-8
Replace _PyUnicode_AsString()+strcmp() with PyUnicode_CompareWithASCIIString().
2013-11-07 00:12:30 +01:00
Victor Stinner eaa2883d15 Issue #19512: builtin print() function uses an identifier instead of literal
string "flush" to call the flush method
2013-11-07 00:01:51 +01:00
Victor Stinner ae9f161b43 Issue #19512: __build_class() builtin now uses an identifier for the "metaclass" string 2013-11-06 22:46:51 +01:00
Victor Stinner 090543736f Issue #19512: add some common identifiers to only create common strings once,
instead of creating temporary Unicode string objects

Add also more identifiers in pythonrun.c to avoid temporary Unicode string
objets for the interactive interpreter.
2013-11-06 22:41:44 +01:00
Victor Stinner cab75e3e1e Issue #19512: PRINT_EXPR bytecode now uses an identifier to get sys.displayhook
to only create the "displayhook" string once
2013-11-06 22:38:37 +01:00
Victor Stinner d67bd45537 Issue #19512: Add _PySys_GetObjectId() and _PySys_SetObjectId() functions 2013-11-06 22:36:40 +01:00
Victor Stinner b44562b6b9 Issue #19512: eval() and exec() now use an identifier for "__builtins__" string 2013-11-06 19:03:11 +01:00
Victor Stinner 95701bdf40 Issue #19512: Add PyRun_InteractiveOneObject() function
Only decode the filename once. PyRun_InteractiveOneObject() uses an identifier
for "<string>" string, so the byte string is only decoded once.
2013-11-06 18:41:07 +01:00
Victor Stinner 4ee41c5839 Issue #19512: _print_total_refs() now uses an identifier to get "showrefcount"
key from sys._xoptions
2013-11-06 18:28:21 +01:00
Victor Stinner d02fbb8f71 Issue #19512: sys_displayhook() now uses an identifier for "builtins"
dictionary key and only decodes "\n" string once to write a newline.

So "builtins" and "\n" are only decoded once from UTF-8, at the first call.
2013-11-06 18:27:13 +01:00
Victor Stinner 98e818b8e3 Issue #19437: Fix compiler_class(), handle compiler_lookup_arg() failure 2013-11-05 18:07:34 +01:00
Brett Cannon 2b8fc303ad Abstract out stat calls in importlib for easier experimentation. 2013-11-01 14:04:24 -04:00
Brett Cannon f6901c8baa Issue #19410: Put back in special-casing of '' for
importlib.machinery.FileFinder.

While originally moved to stop special-casing '' as PathFinder farther
up the typical call chain now uses the cwd in the instance of '', it
was deemed an unnecessary risk to breaking subclasses of FileFinder to
take the special-casing out.
2013-11-01 10:37:57 -04:00
Eric Snow cdf601281f Issue #19413: Restore pre-3.3 reload() semantics of re-finding modules. 2013-10-31 22:22:15 -06:00
Victor Stinner dcdd05b0b4 Close #19442: warn_explicit() does nothing when called late during Python shutdown
After more tests, I now think that it is the safest option.
2013-11-01 00:55:30 +01:00
Victor Stinner 359fabc19f Issue #19437: Cleanup r_ref() of the marshal module 2013-10-31 17:09:01 +01:00
Victor Stinner d5cae6f143 Issue #19437: Fix r_object() of marshal module, handle PyDict_SetItem() failure
for TYPE_DICT and stop immedialty on first r_object() failure
2013-10-31 17:14:52 +01:00
Victor Stinner b1b7b1834b Issue #19437: Fix r_object() of marshal module, handle r_byte() failure for
TYPE_SMALL_TUPLE
2013-10-31 17:07:08 +01:00