Commit Graph

4823 Commits

Author SHA1 Message Date
Victor Stinner c379ade1bb pytime.c: rename pygettimeofday_new() to pygettimeofday()
I forgot to rename it in my previous refactoring of pytime.c.
2015-11-10 12:11:39 +01:00
Victor Stinner f9827ea618 Issue #25555: Fix parser and AST: fill lineno and col_offset of "arg" node when
compiling AST from Python objects.
2015-11-06 17:01:48 +01:00
Martin Panter 61d6e4ae9d Issue #24802: Merge null termination fixes from 3.4 into 3.5 2015-11-07 02:56:11 +00:00
Martin Panter eeb896c411 Issue #24802: Copy bytes-like objects to null-terminated buffers if necessary
This avoids possible buffer overreads when int(), float(), compile(), exec()
and eval() are passed bytes-like objects. Similar code is removed from the
complex() constructor, where it was not reachable.

Patch by John Leitch, Serhiy Storchaka and Martin Panter.
2015-11-07 02:32:21 +00:00
Victor Stinner 60a1d3cd15 Issue #25556: Fix LOAD_GLOBAL bytecode when globals type is not dict and the
requested name doesn't exist in globals: clear the KeyError exception before
calling PyObject_GetItem(). Fail also if the raised exception is not a
KeyError.
2015-11-05 13:55:20 +01:00
Martin Panter 2eb819f7a8 Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5 2015-11-02 04:04:57 +00:00
Martin Panter 7462b64911 Issue #25523: Correct "a" article to "an" article
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
or edited some other way to fix the grammar.
2015-11-02 03:37:02 +00:00
Victor Stinner 50856d5ae7 sys.setrecursionlimit() now raises RecursionError
Issue #25274: sys.setrecursionlimit() now raises a RecursionError if the new
recursion limit is too low depending at the current recursion depth. Modify
also the "lower-water mark" formula to make it monotonic. This mark is used to
decide when the overflowed flag of the thread state is reset.
2015-10-13 00:11:21 +02:00
Victor Stinner bc5b80bac1 Close #24784: Fix compilation without thread support
Add "#ifdef WITH_THREAD" around cals to:

* PyGILState_Check()
* _PyImport_AcquireLock()
* _PyImport_ReleaseLock()
2015-10-11 09:54:42 +02:00
Martin Panter e02f8fc44d Issue #24402: Merge input() fix from 3.4 into 3.5 2015-10-10 01:55:23 +00:00
Martin Panter c9a6ab56cf Issue #24402: Fix input() when stdout.fileno() fails; diagnosed by Eryksun
Also factored out some test cases into a new PtyTests class.
2015-10-10 01:25:38 +00:00
Martin Panter 3f930dcd87 Merge typo fixes from 3.4 into 3.5 2015-10-07 11:01:47 +00:00
Martin Panter 9955a373a8 Various minor typos in documentation and comments 2015-10-07 10:26:23 +00:00
Serhiy Storchaka 0b40aab6f0 Issue #25280: Import trace messages emitted in verbose (-v) mode are no
longer formatted twice.
2015-10-01 11:40:22 +03:00
Serhiy Storchaka f731bc09fa Issue #25280: Import trace messages emitted in verbose (-v) mode are no
longer formatted twice.
2015-10-01 11:08:50 +03:00
Victor Stinner 861f067201 Merge 3.4 (os.urandom) 2015-10-01 10:00:23 +02:00
Victor Stinner 78cc2e8968 Issue #25003: os.urandom() doesn't use getentropy() on Solaris because
getentropy() is blocking, whereas os.urandom() should not block. getentropy()
is supported since Solaris 11.3.
2015-10-01 09:59:32 +02:00
Victor Stinner bae2d6203f Issue #25003: On Solaris 11.3 or newer, os.urandom() now uses the getrandom()
function instead of the getentropy() function. The getentropy() function is
blocking to generate very good quality entropy, os.urandom() doesn't need such
high-quality entropy.
2015-10-01 09:47:30 +02:00
Benjamin Peterson 58b53953f8 make opening brace of container literals and comprehensions correspond to the line number and col offset of the AST node (closes #25131) 2015-09-25 22:44:43 -07:00
Victor Stinner ec26f83f2e Issue #25155: Fix _PyTime_Divide() rounding
_PyTime_Divide() rounding was wrong: copy code from Python default which has
now much better unit tests.
2015-09-18 14:21:14 +02:00
Victor Stinner 9a8b177e60 Issue #25155: Add _PyTime_AsTimevalTime_t() function
On Windows, the tv_sec field of the timeval structure has the type C long,
whereas it has the type C time_t on all other platforms. A C long has a size of
32 bits (signed inter, 1 bit for the sign, 31 bits for the value) which is not
enough to store an Epoch timestamp after the year 2038.

Add the _PyTime_AsTimevalTime_t() function written for datetime.datetime.now():
convert a _PyTime_t timestamp to a (secs, us) tuple where secs type is time_t.
It allows to support dates after the year 2038 on Windows.

Enhance also _PyTime_AsTimeval_impl() to detect overflow on the number of
seconds when rounding the number of microseconds.
2015-09-18 13:36:17 +02:00
Victor Stinner cd6e69439c Issue #25160: Fix import_init() comments and messages
import_init() imports the "_imp" module, not the "imp" module.
2015-09-18 09:11:57 +02:00
Benjamin Peterson b685515039 compute stack effect of BUILD_MAP correctly (closes #25060) 2015-09-10 21:02:39 -07:00
Steve Dower f35bd306ff Merge from 3.5.0 branch. 2015-09-06 22:27:42 -07:00
Larry Hastings 714e49371b Issue #24305: Prevent import subsystem stack frames from being counted
by the warnings.warn(stacklevel=) parameter.
2015-09-06 00:39:37 -07:00
Victor Stinner 874dbe895d Merge 3.4 (create_stdio) 2015-09-04 17:29:57 +02:00
Victor Stinner 6fb5bae252 Fix race condition in create_stdio()
Issue #24891: Fix a race condition at Python startup if the file descriptor
of stdin (0), stdout (1) or stderr (2) is closed while Python is creating
sys.stdin, sys.stdout and sys.stderr objects. These attributes are now set
to None if the creation of the object failed, instead of raising an OSError
exception. Initial patch written by Marco Paolini.
2015-09-04 17:27:49 +02:00
Victor Stinner 38b8ae0f5b Issue #24993: Handle import error in namereplace error handler
Handle PyCapsule_Import() failure (exception) in PyCodec_NameReplaceErrors():
return immedialty NULL.
2015-09-03 16:19:40 +02:00
Victor Stinner 5ad5821d09 oops, rename pymonotonic_new() to pymonotonic()
I was not supposed to commit the function with the name pymonotonic_new(). I
forgot to rename it.
2015-09-03 00:14:58 +02:00
Victor Stinner c3c616c3d1 Issue #24707: Remove assertion in monotonic clock
Don't check anymore at runtime that the monotonic clock doesn't go backward.
Yes, it happens. It occurs sometimes each month on a Debian buildbot slave
running in a VM.

The problem is that Python cannot do anything useful if a monotonic clock goes
backward. It was decided in the PEP 418 to not fix the system, but only expose
the clock provided by the OS.
2015-09-03 00:13:46 +02:00
Yury Selivanov b3d531348c Issue #24975: Fix AST compilation for PEP 448 syntax. 2015-09-01 16:10:49 -04:00
Larry Hastings 01b1ff6970 Rebuilt Clinic generated code. 2015-08-24 20:23:27 -07:00
Larry Hastings 1df0b35e3d Issue #24769: Interpreter now starts properly when dynamic loading
is disabled.  Patch by Petr Viktorin.
2015-08-24 19:53:56 -07:00
Brett Cannon 3008bc0f4a Issue #24492: make sure that ``from ... import ...` raises an
ImportError if __name__ is not defined on a package.

Thanks to Armin Rigo for the bug report and diagnosing the cause.
2015-08-11 18:01:31 -07:00
Berker Peksag 0bd5fb0112 Issue #24728: Fix building without threads.
Patch by Louis Dassy.
2015-07-27 16:46:11 +03:00
Yury Selivanov 14acf5f41d Issue #24791: Fix grammar regression for call syntax: 'g(*a or b)'. 2015-08-05 17:54:10 -04:00
Victor Stinner 61d5aab9b9 py_getrandom(): getrandom() *can* return EINTR
See the latest version of getrandom() manual page:
http://man7.org/linux/man-pages/man2/getrandom.2.html#NOTES

    The behavior when a call to getrandom() that is blocked while reading from
    /dev/urandom is interrupted by a signal handler depends on the
    initialization state of the entropy buffer and on the request size, buflen.
    If the entropy is not yet initialized, then the call will fail with the
    EINTR error.  If the entropy pool has been initialized and the request size
    is large (buflen > 256), the call either succeeds, returning a partially
    filled buffer, or fails with the error EINTR.  If the entropy pool has been
    initialized and the request size is small (buflen <= 256), then getrandom()
    will not fail with EINTR.  Instead, it will return all of the bytes that
    have been requested.

Note: py_getrandom() calls getrandom() with flags=0.
2015-07-30 10:13:52 +02:00
Stefan Krah c0cbed1554 Fix refleak. 2015-07-27 12:56:49 +02:00
Yury Selivanov f315c1c016 Issue #24687: Plug refleak on SyntaxError in function parameters annotations. 2015-07-23 09:10:44 +03:00
Yury Selivanov b7666a3093 Issue #24619: More tests; fix nits in compiler.c 2015-07-22 14:48:57 +03:00
Benjamin Peterson d5d77aac60 set items in dict displays from left to right (closes #24569) 2015-07-05 10:37:25 -05:00
Yury Selivanov f488fb422a Issue #19235: Add new RecursionError exception. Patch by Georg Brandl. 2015-07-03 01:04:23 -04:00
Yury Selivanov 9dec03571f Issue #24528: Improve error message for awaits in comprehensions 2015-06-30 12:49:04 -04:00
Yury Selivanov 5376ba9630 Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:

1. Coroutines now have a distinct, separate from generators
   type at the C level: PyGen_Type, and a new typedef PyCoroObject.
   PyCoroObject shares the initial segment of struct layout with
   PyGenObject, making it possible to reuse existing generators
   machinery.  The new type is exposed as 'types.CoroutineType'.

   As a consequence of having a new type, CO_GENERATOR flag is
   no longer applied to coroutines.

2. Having a separate type for coroutines made it possible to add
   an __await__ method to the type.  Although it is not used by the
   interpreter (see details on that below), it makes coroutines
   naturally (without using __instancecheck__) conform to
   collections.abc.Coroutine and collections.abc.Awaitable ABCs.

   [The __instancecheck__ is still used for generator-based
   coroutines, as we don't want to add __await__ for generators.]

3. Add new opcode: GET_YIELD_FROM_ITER.  The opcode is needed to
   allow passing native coroutines to the YIELD_FROM opcode.

   Before this change, 'yield from o' expression was compiled to:

      (o)
      GET_ITER
      LOAD_CONST
      YIELD_FROM

   Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.

   The reason for adding a new opcode is that GET_ITER is used
   in some contexts (such as 'for .. in' loops) where passing
   a coroutine object is invalid.

4. Add two new introspection functions to the inspec module:
   getcoroutinestate(c) and getcoroutinelocals(c).

5. inspect.iscoroutine(o) is updated to test if 'o' is a native
   coroutine object.  Before this commit it used abc.Coroutine,
   and it was requested to update inspect.isgenerator(o) to use
   abc.Generator; it was decided, however, that inspect functions
   should really be tailored for checking for native types.

6. sys.set_coroutine_wrapper(w) API is updated to work with only
   native coroutines.  Since types.coroutine decorator supports
   any type of callables now, it would be confusing that it does
   not work for all types of coroutines.

7. Exceptions logic in generators C implementation was updated
   to raise clearer messages for coroutines:

   Before: TypeError("generator raised StopIteration")
   After: TypeError("coroutine raised StopIteration")
2015-06-22 12:19:30 -04:00
Serhiy Storchaka 289dd19124 Added the const qualifier for char* argument of Py_EnterRecursiveCall(). 2015-06-21 16:27:09 +03:00
Serhiy Storchaka 5fa22fc088 Added the const qualifier for char* argument of Py_EnterRecursiveCall(). 2015-06-21 16:26:28 +03:00
Serhiy Storchaka ccfdf0923a Issue #24436: Added const qualifiers for char* arguments of _PyTraceback_Add.
Patch by Michael Ensslin.
2015-06-21 16:00:33 +03:00
Serhiy Storchaka 73c95f1949 Issue #24436: Added const qualifiers for char* arguments of _PyTraceback_Add.
Patch by Michael Ensslin.
2015-06-21 15:59:46 +03:00
Serhiy Storchaka 553e156921 Fixed indentation of Python examples in C comments. 2015-06-11 00:07:47 +03:00
Serhiy Storchaka d741a88049 Fixed indentation of Python examples in C comments. 2015-06-11 00:06:39 +03:00