Commit graph

5451 commits

Author SHA1 Message Date
Nick Coghlan 6ea4186de3 bpo-28180: Implementation for PEP 538 (#659)
- new PYTHONCOERCECLOCALE config setting
- coerces legacy C locale to C.UTF-8, C.utf8 or UTF-8 by default
- always uses C.UTF-8 on Android
- uses `surrogateescape` on stdin and stdout in the coercion
  target locales
- configure option to disable locale coercion at build time
- configure option to disable C locale warning at build time
2017-06-11 13:16:15 +10:00
Sylvain 7445381c60 bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051)
The function '_PyArg_ParseStack()' and
'_PyArg_UnpackStack' were failing (with error
"XXX() takes Y argument (Z given)") before
the function '_PyArg_NoStackKeywords()' was called.
Thus, the latter did not raise its more meaningful
error : "XXX() takes no keyword arguments".
2017-06-10 07:51:48 +03:00
Serhiy Storchaka f9f1ccace3 Fix regression in error message introduced in bpo-29951. (#2028)
* Fix regression in error message introduced in bpo-29951.

* Add test.

* Make the test more strong.
2017-06-09 18:27:06 +02:00
Serhiy Storchaka 2e9cd5825c bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (#1888)
'invalid character in identifier' now is raised instead of
'f-string: empty expression not allowed' if a subexpression contains
only whitespaces and they are not accepted by Python parser.
2017-06-08 23:43:54 +03:00
Serhiy Storchaka 6cca5c8459 bpo-30592: Fixed error messages for some builtins. (#1996)
Error messages when pass keyword arguments to some builtins that
don't support keyword arguments contained double parenthesis: "()()".
The regression was introduced by bpo-30534.
2017-06-08 14:41:19 +03:00
Victor Stinner 865de27dd7 bpo-30598: _PySys_EndInit() now duplicates warnoptions (#1998)
Fix a reference in subinterpreters, like test_callbacks_leak() of
test_atexit.

warnoptions is a list used to pass options from the command line to
the sys module constructor. Before this change, the list was shared
by multiple interpreter which is not the expected behaviour. Each
interpreter should have their own independent mutable world.

This change duplicates the list in each interpreter. So each
interpreter owns its own list, so each interpreter can clear its own
list.
2017-06-08 13:27:47 +02:00
Stéphane Wirtel ab1cb80b43 bpo-30547: Fix multiple reference leaks (#1995)
Fix regressions introduced by:

- bpo-22257: commits 1abcf6700b and 6b4be195cd

Co-Authored-By: Victor Stinner <victor.stinner@gmail.com>
Co-Authored-By: Louie Lu <git@louie.lu>
2017-06-08 13:13:20 +02:00
Serhiy Storchaka 5eb788bf7f bpo-30534: Fixed error messages when pass keyword arguments (#1901)
to functions implemented in C that don't support this.

Also unified error messages for functions that don't take positional or keyword
arguments.
2017-06-06 18:45:22 +03:00
Segev Finer 48fb766f70 bpo-30567: Fix refleak in sys.getwindowsversion (#1940) 2017-06-04 20:52:27 +03:00
Amit Kumar 2e6bb4484e Add reference to help('FORMATTING') in format() builtin (GH-166) 2017-05-29 11:02:26 +10:00
Antoine Pitrou 4a8bcdf79c bpo-16500: Use register_at_fork() in the threading module (#1843)
* bpo-16500: Use register_at_fork() in the threading module

* Update comment at top of _after_fork()
2017-05-28 14:02:26 +02:00
Antoine Pitrou f7ecfac0c1 Doc nits for bpo-16500 (#1841)
* Doc nits for bpo-16500

* Fix more references
2017-05-28 11:35:14 +02:00
Antoine Pitrou 346cbd351e bpo-16500: Allow registering at-fork handlers (#1715)
* bpo-16500: Allow registering at-fork handlers

* Address Serhiy's comments

* Add doc for new C API

* Add doc for new Python-facing function

* Add NEWS entry + doc nit
2017-05-27 17:50:54 +02:00
Eric Snow 18c1356ff6 Drop a duplicate line. (#1809) 2017-05-25 10:05:50 -07:00
Segev Finer 7ff1e88a57 Delete sigcheck.c since it appears unused (#1723) 2017-05-25 13:00:18 +02:00
Serhiy Storchaka 0cd7a3f196 bpo-29104: Fixed parsing backslashes in f-strings. (#490) 2017-05-25 13:33:55 +03:00
Eric Snow c7ec9985bb bpo-22257: Private C-API for main interpreter initialization (PEP 432). (#1729)
(patch by Nick Coghlan)
2017-05-23 23:00:52 -07:00
Eric Snow 1abcf6700b bpo-22257: Private C-API for core runtime initialization (PEP 432). (#1772)
(patch by Nick Coghlan)
2017-05-23 21:46:51 -07:00
Steve Dower 9b33bf50da Improves test_underpth_nosite_file to reveal why it fails. (#1763)
* Improves test_underpth_nosite_file to reveal why it fails.

* Enable building with Windows 10 SDK.

* Fix WinSDK detection

* Fix initialization on Windows when a ._pth file exists.

* Fix tabs

* Adds comment about Py_GetPath call.
2017-05-23 16:25:25 -07:00
Zachary Ware 84c6607a81 Update importlib.h (GH-1762) 2017-05-23 12:23:05 -05:00
Eric Snow 6b4be195cd bpo-22257: Small changes for PEP 432. (#1728)
PEP 432 specifies a number of large changes to interpreter startup code, including exposing a cleaner C-API. The major changes depend on a number of smaller changes. This patch includes all those smaller changes.
2017-05-22 21:36:03 -07:00
Eric Snow e377416c10 bpo-29102: Add a unique ID to PyInterpreterState. (#1639) 2017-05-22 19:46:40 -07:00
Jason Fried f82c951d1c bpo-30395 _PyGILState_Reinit deadlock fix (#1734)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
2017-05-22 16:58:55 -07:00
Nathaniel J. Smith ab4413a7e9 bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081)
If we have a chain of generators/coroutines that are 'yield from'ing
each other, then resuming the stack works like:

- call send() on the outermost generator
- this enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- which calls send() on the next generator
- which enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- ...etc.

However, every time we enter _PyEval_EvalFrameDefault, the first thing
we do is to check for pending signals, and if there are any then we
run the signal handler. And if it raises an exception, then we
immediately propagate that exception *instead* of starting to execute
bytecode. This means that e.g. a SIGINT at the wrong moment can "break
the chain" – it can be raised in the middle of our yield from chain,
with the bottom part of the stack abandoned for the garbage collector.

The fix is pretty simple: there's already a special case in
_PyEval_EvalFrameEx where it skips running signal handlers if the next
opcode is SETUP_FINALLY. (I don't see how this accomplishes anything
useful, but that's another story.) If we extend this check to also
skip running signal handlers when the next opcode is YIELD_FROM, then
that closes the hole – now the exception can only be raised at the
innermost stack frame.

This shouldn't have any performance implications, because the opcode
check happens inside the "slow path" after we've already determined
that there's a pending signal or something similar for us to process;
the vast majority of the time this isn't true and the new check
doesn't run at all.
2017-05-17 13:33:23 -07:00
Xiang Zhang 2ddf5a19c3 bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) 2017-05-10 18:19:41 +08:00
Serhiy Storchaka f93234bb8a bpo-30024: Circular imports involving absolute imports with binding (#1264)
a submodule to a name are now supported.
2017-05-09 22:31:05 +03:00
Masayuki Yamamoto fdaeea620f bpo-30279: Remove unused Python/thread_foobar.h (#1473)
Python/thread_foobar.h is the template code that is threading adaptation
for new platforms, also hasn't been used on actual platforms.
Python/thread_*.h give concrete examples of adaptation instead of the
template code.
2017-05-05 10:04:13 +02:00
Victor Stinner 1c4670ea0c bpo-30225: Fix is_valid_fd() on macOS Tiger (#1443)
is_valid_fd() now uses fstat() instead of dup() on macOS to return 0
on a pipe when the other side of the pipe is closed. fstat() fails
with EBADF in that case, whereas dup() succeed.
2017-05-04 00:45:56 +02:00
Serhiy Storchaka bf623ae884 bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)
raised an error.

Replace them with using concrete types API that never fails if appropriate.
2017-04-19 20:03:52 +03:00
Serhiy Storchaka 55fe1ae970 bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
Serhiy Storchaka 813f943c59 bpo-29838: Add asserts for checking results of sq_length and mq_length slots. (#700)
Negative result should be returned only when an error is set.
2017-04-16 09:21:44 +03:00
Michael Seifert 64c8f705c0 bpo-29951: Include function name for some error messages in PyArg_ParseTuple* (#916)
Also changed format specifier for function name from "%s" to "%.200s"
and exception messages should start with lowercase letter.
2017-04-09 10:47:12 +03:00
Serhiy Storchaka d4edfc9abf bpo-29935: Fixed error messages in the index() method of tuple, list and deque (#887)
when pass indices of wrong type.
2017-03-30 18:29:23 +03:00
Serhiy Storchaka 762bf40438 bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
if pass `accept={int, NoneType}`.
2017-03-30 09:15:31 +03:00
Serhiy Storchaka ba85d69a3e bpo-29878: Add global instances of int for 0 and 1. (#852) 2017-03-30 09:09:41 +03:00
Serhiy Storchaka aefa7ebf0f bpo-6532: Make the thread id an unsigned integer. (#781)
* bpo-6532: Make the thread id an unsigned integer.

From C API side the type of results of PyThread_start_new_thread() and
PyThread_get_thread_ident(), the id parameter of
PyThreadState_SetAsyncExc(), and the thread_id field of PyThreadState
changed from "long" to "unsigned long".

* Restore a check in thread_get_ident().
2017-03-23 14:48:39 +01:00
Daniel Birnstiel d7fa6b259e bpo-29859: Fix error messages from return codes for pthread_* calls (GH-741) 2017-03-21 22:06:06 +09:00
Serhiy Storchaka fff9a31a91 bpo-29865: Use PyXXX_GET_SIZE macros rather than Py_SIZE for concrete types. (#748) 2017-03-21 08:53:25 +02:00
Xiang Zhang 4830f581af bpo-29849: fix a memory leak in import_from (GH-712) 2017-03-21 11:13:42 +08:00
Serhiy Storchaka 80ec8364f1 bpo-29748: Added the slice index converter in Argument Clinic. (#549) 2017-03-19 19:37:40 +02:00
Serhiy Storchaka c2cf128571 bpo-8256: Fixed possible failing or crashing input() (#517)
if attributes "encoding" or "errors" of sys.stdin or sys.stdout
are not set or are not strings.
2017-03-12 13:50:36 +02:00
Serhiy Storchaka 202fda55c2 bpo-24037: Add Argument Clinic converter bool(accept={int}). (#485) 2017-03-12 10:10:47 +02:00
Serhiy Storchaka 0767ad40bf bpo-20185: Convert the marshal module to Argument Clinic. (#541)
Based on patch by Vajrasky Kok.
2017-03-12 09:20:15 +02:00
Serhiy Storchaka c611a5b1d4 bpo-29746: Update marshal docs to Python 3. (#547) 2017-03-12 08:53:22 +02:00
Xiang Zhang 0710d75425 bpo-29770: remove outdated PYO related info (GH-590) 2017-03-11 13:02:52 +08:00
Victor Stinner 0f6d73343d bpo-29619: Convert st_ino using unsigned integer (#557)
bpo-29619: os.stat() and os.DirEntry.inodeo() now convert inode
(st_ino) using unsigned integers.
2017-03-09 17:34:28 +01:00
Serhiy Storchaka 370fd202f1 Use Py_RETURN_FALSE/Py_RETURN_TRUE rather than PyBool_FromLong(0)/PyBool_FromLong(1). (#567) 2017-03-08 20:47:48 +02:00
INADA Naoki 93fac8dd35 bpo-29676: fix lsprof can't profile C method call. (GH523)
When LOAD_METHOD is used for calling C mehtod, PyMethodDescrObject
was passed to profilefunc from 5566bbb.
But lsprof traces only PyCFunctionObject. Additionally, there can be
some third party extension which assumes passed arg is
PyCFunctionObject without calling PyCFunction_Check().

So make PyCFunctionObject from PyMethodDescrObject when
tstate->c_profilefunc is set.
2017-03-07 14:24:37 +09:00
Ned Deily 5c4b0d063a bpo-27593: Get SCM build info from git instead of hg. (#446)
sys.version and the platform module python_build(),
python_branch(), and python_revision() functions now use
git information rather than hg when building from a repo.

Based on original patches by Brett Cannon and Steve Dower.
2017-03-04 00:19:55 -05:00
Yury Selivanov 398ff91ac0 bpo-28893: Set __cause__ for errors in async iteration protocol (#407) 2017-03-02 22:20:00 -05:00