Commit Graph

5208 Commits

Author SHA1 Message Date
Steve Dower 940f33a50f Issue #23524: Finish removing _PyVerify_fd from sources 2016-09-08 11:21:54 -07:00
Eric Snow f3fd06a2e4 Issue #28026: Raise ImportError when exec_module() exists but create_module() is missing. 2016-09-08 11:12:31 -07:00
Steve Dower cc16be85c0 Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
Brett Cannon 035a100382 Issue #26667: Add path-like object support to importlib.util. 2016-09-07 18:39:18 -07:00
Brett Cannon 52794db825 Issue #27911: Remove some unnecessary error checks in import.c.
Thanks to Xiang Zhang for the patch.
2016-09-07 17:00:43 -07:00
Eric Snow 46f97b85a8 Issue #15767: Use ModuleNotFoundError. 2016-09-07 16:56:15 -07:00
Brett Cannon 5c4de2863b Add the co_extra field and accompanying APIs to code objects.
This completes PEP 523.
2016-09-07 11:16:41 -07:00
Benjamin Peterson 2f8bfef158 replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
Victor Stinner e66987e626 os.urandom() now blocks on Linux
Issue #27776: The os.urandom() function does now block on Linux 3.17 and newer
until the system urandom entropy pool is initialized to increase the security.

This change is part of the PEP 524.
2016-09-06 16:33:52 -07:00
Brett Cannon eaecc692df Issue #27974: Remove importlib._bootstrap._ManageReload.
Class was dead code. Thanks to Xiang Zhang for the patch.
2016-09-06 16:20:46 -07:00
Benjamin Peterson ca47063998 replace Py_(u)intptr_t with the c99 standard types 2016-09-06 13:47:26 -07:00
Benjamin Peterson 9b3d77052f replace Python aliases for standard integer types with the standard integer types (#17884) 2016-09-06 13:24:00 -07:00
Benjamin Peterson 5d75f441ef dtoa.c: remove code for platforms with 64-bit integers (#17884) 2016-09-06 12:44:21 -07:00
Serhiy Storchaka ea525a2d1a Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation. 2016-09-06 22:07:53 +03:00
Benjamin Peterson 4fe55106d1 require standard int types to be defined (#17884) 2016-09-06 11:58:01 -07:00
Benjamin Peterson af580dff4a replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
Victor Stinner 3466bde1cc Avoid calling functions with an empty string as format string
Directly pass NULL rather than an empty string.
2016-09-05 18:16:01 -07:00
Victor Stinner ad8c83ad6b Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
2016-09-05 17:53:15 -07:00
Benjamin Peterson ed4aa83ff7 require a long long data type (closes #27961) 2016-09-05 17:44:18 -07:00
Brett Cannon 3cebf93872 Implement the frame evaluation API aspect of PEP 523. 2016-09-05 15:33:46 -07:00
Larry Hastings 10108a7b9a Issue #27355: Removed support for Windows CE. It was never finished,
and Windows CE is no longer a relevant platform for Python.
2016-09-05 15:11:23 -07:00
Eric Snow 92a6c170e6 Issue #24254: Preserve class attribute definition order. 2016-09-05 14:50:11 -07:00
Eric V. Smith 6a4efce7a5 Closes issue 27921: Disallow backslashes anywhere in f-strings. This is a temporary restriction. In 3.6 beta 2, the plan is to again allow backslashes in the string parts of f-strings, but disallow them in the expression parts. 2016-09-03 09:18:34 -04:00
Raymond Hettinger 3b09cd64e0 Merge 2016-09-03 01:55:39 -07:00
Raymond Hettinger 74942c9252 Merge 2016-08-31 08:44:26 -07:00
Raymond Hettinger 15f44ab043 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-08-30 10:47:49 -07:00
Serhiy Storchaka 1f9326196e Issue #27818: Speed up parsing width and precision in format() strings for
numbers.  Patch by Stefan Behnel.
2016-08-29 15:57:26 +03:00
Raymond Hettinger f74c33ad5c Merge 2016-08-25 21:12:16 -07:00
Raymond Hettinger 7ea386e56e Issue 19504: Change "customise" to "customize" American spelling. 2016-08-25 21:11:50 -07:00
Victor Stinner e90bdb19f2 Issue #27830: Revert, remove _PyFunction_FastCallKeywords() 2016-08-25 23:26:50 +02:00
Victor Stinner 577e1f8cb4 Add _PyObject_FastCallKeywords()
Issue #27830: Similar to _PyObject_FastCallDict(), but keyword arguments are
also passed in the same C array than positional arguments, rather than being
passed as a Python dict.
2016-08-25 00:29:32 +02:00
Victor Stinner 74319ae219 Use Py_ssize_t type for number of arguments
Issue #27848: use Py_ssize_t rather than C int for the number of function
positional and keyword arguments.
2016-08-25 00:04:09 +02:00
Victor Stinner cdb5cee980 Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-24 01:45:13 +02:00
Victor Stinner f0cba67d0b Backed out changeset 70f88b097f60 (map_next) 2016-08-24 00:54:47 +02:00
Victor Stinner a9ba1ab21b Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-23 17:56:06 +02:00
Victor Stinner d1c2a8e2b5 Issue #27809: builtin___build_class__() uses fast call 2016-08-23 01:34:35 +02:00
Victor Stinner 6e2333dfdf PyEval_CallObjectWithKeywords() doesn't inc/decref
Issue #27809: PyEval_CallObjectWithKeywords() doesn't increment temporary the
reference counter of the args tuple (positional arguments). The caller already
holds a strong reference to it.
2016-08-23 00:25:01 +02:00
Victor Stinner f45a56150b Issue #27809: PyErr_SetImportError() uses fast call 2016-08-23 00:04:41 +02:00
Victor Stinner 3a84097291 Add _PyErr_CreateException()
Issue #27809: Helper function optimized to create an exception: use fastcall
whenever possible.
2016-08-22 23:59:08 +02:00
Victor Stinner 463b86a881 Issue #27809: Use _PyObject_FastCallDict()
Modify:

* init_subclass()
* builtin___build_class__()

Fix also a bug in init_subclass(): check for super() failure.
2016-08-22 23:33:13 +02:00
Victor Stinner 155ea65e5c PyEval_CallObjectWithKeywords() uses fast call with kwargs
Issue #27809. _PyObject_FastCallDict() now supports keyword arguments, and so
the args==NULL fast-path can also be used when kwargs is not NULL.
2016-08-22 23:26:00 +02:00
Victor Stinner 2990fa11bc Issue #27809: Use _PyObject_FastCallDict()
Modify:

* builtin_sorted()
* classmethoddescr_call()
* methoddescr_call()
* wrapperdescr_call()
2016-08-22 23:21:55 +02:00
Victor Stinner 6fea7f7ffc Issue #27809: Cleanup _PyEval_EvalCodeWithName()
* Rename nm to name
* PEP 7: add { ... } to if/else blocks
2016-08-22 23:17:30 +02:00
Victor Stinner b900939186 _PyFunction_FastCallDict() supports keyword args
Issue #27809:

* Rename _PyFunction_FastCall() to _PyFunction_FastCallDict()
* Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict()
*  _PyFunction_FastCallDict() now supports keyword arguments
2016-08-22 23:15:44 +02:00
Victor Stinner 559bb6a713 Rename _PyObject_FastCall() to _PyObject_FastCallDict()
Issue #27809:

* Rename _PyObject_FastCall() function to _PyObject_FastCallDict()
* Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1()
  macros calling _PyObject_FastCallDict()
2016-08-22 22:48:54 +02:00
Berker Peksag c98afb7a26 Issue #27587: Merge from 3.5 2016-08-22 18:07:02 +03:00
Berker Peksag 4b7b565c58 Issue #27587: Move null pointer check earlier in _PyState_AddModule()
This was found by PVS-Studio:

V595 The 'def' pointer was utilized before it was verified
against nullptr. Check lines: 286, 292. pystate.c 286

Initial patch by Christian Heimes.
2016-08-22 18:05:56 +03:00
Victor Stinner 2eedc119c2 Optimize call to Python function without argument
Issue #27128. When a Python function is called with no arguments, but all
parameters have a default value: use default values as arguments for the fast
path.
2016-08-22 12:29:42 +02:00
Victor Stinner a88b2f4e5e Fix reference leak in tb_printinternal()
Issue #26823.
2016-08-20 03:05:13 +02:00
Victor Stinner c3ccaae6f3 sys_pyfile_write_unicode() now uses fast call
Issue #27128.
2016-08-20 01:24:22 +02:00
Victor Stinner 78da82bf3e call_trampoline() now uses fast call
Issue #27128.
2016-08-20 01:22:57 +02:00
Victor Stinner 71cb64acc2 PyErr_PrintEx() now uses fast call
Issue #27128.
2016-08-20 00:57:43 +02:00
Victor Stinner df142fdc4b import_name() now uses fast call
Issue #27128: import_name() now calls _PyObject_FastCall() to avoid the
creation of a temporary tuple.
2016-08-20 00:44:42 +02:00
Victor Stinner 8a31c82093 Fix PyObject_Call() parameter names
Issue #27128: arg=>args, kw=>kwargs.

Same change for PyEval_CallObjectWithKeywords().
2016-08-19 17:12:23 +02:00
Victor Stinner 3f745bf1d9 PyEval_CallObjectWithKeywords() uses fast call
Issue #27128: Modify PyEval_CallObjectWithKeywords() to use
_PyObject_FastCall() when args==NULL and kw==NULL. It avoids the creation of a
temporary empty tuple for positional arguments.
2016-08-19 16:42:42 +02:00
Victor Stinner 9be7e7b52f Add _PyObject_FastCall()
Issue #27128: Add _PyObject_FastCall(), a new calling convention avoiding a
temporary tuple to pass positional parameters in most cases, but create a
temporary tuple if needed (ex: for the tp_call slot).

The API is prepared to support keyword parameters, but the full implementation
will come later (_PyFunction_FastCall() doesn't support keyword parameters
yet).

Add also:

* _PyStack_AsTuple() helper function: convert a "stack" of parameters to
  a tuple.
* _PyCFunction_FastCall(): fast call implementation for C functions
* _PyFunction_FastCall(): fast call implementation for Python functions
2016-08-19 16:11:43 +02:00
Victor Stinner 0a6996d87d Merge 3.5 (fix raise) 2016-08-18 18:14:15 +02:00
Victor Stinner eec9331b20 Fix SystemError in "raise" statement
Issue #27558: Fix a SystemError in the implementation of "raise" statement.
In a brand new thread, raise a RuntimeError since there is no active
exception to reraise.

Patch written by Xiang Zhang.
2016-08-18 18:13:10 +02:00
Ned Deily dc35cda2de Issue #27594: Prevent assertion error when running test_ast with coverage
enabled: ensure code object has a valid first line number.
Patch suggested by Ivan Levkivskyi.
2016-08-17 17:18:33 -04:00
Victor Stinner 17061a99b0 Use Py_ssize_t in _PyEval_EvalCodeWithName()
Issue #27128, #18295: replace int type with Py_ssize_t for index variables used
for positional arguments. It should help to avoid integer overflow and help to
emit better machine code for "i++" (no trap needed for overflow).

Make also the total_args variable constant.
2016-08-16 23:39:42 +02:00
Victor Stinner c70200165c Issue #27128: Cleanup _PyEval_EvalCodeWithName()
* Add comments
* Add empty lines for readability
* PEP 7 style for if block
* Remove useless assert(globals != NULL); (globals is tested a few lines
  before)
2016-08-16 23:40:29 +02:00
Victor Stinner 3ee933f1c3 Issue #27776: dev_urandom(raise=0) now closes the file descriptor on error 2016-08-16 18:27:44 +02:00
Victor Stinner 6974cf2c27 Issue #27776: Cleanup random.c
Merge dev_urandom_python() and dev_urandom_noraise() functions to reduce code
duplication.
2016-08-16 18:46:38 +02:00
Victor Stinner cecdd9634b Issue #27776: _PyRandom_Init() doesn't call PyErr_CheckSignals() anymore
Modify py_getrandom() to not call PyErr_CheckSignals() if raise is zero.
_PyRandom_Init() is called very early in the Python initialization, so it's
safer to not call PyErr_CheckSignals().
2016-08-16 15:19:09 +02:00
Victor Stinner 4bad3b622e Issue #27776: Cleanup random.c
* Add pyurandom() helper function to factorize the code
* don't call Py_FatalError() in helper functions, but only in _PyRandom_Init()
  if pyurandom() failed, to uniformize the code
2016-08-16 15:23:58 +02:00
Nick Coghlan d00342347e Issue #26823: Abbreviate recursive tracebacks
Large sections of repeated lines in tracebacks are now abbreviated as
"[Previous line repeated {count} more times]" by both the traceback
module and the builtin traceback rendering.

Patch by Emanuel Barry.
2016-08-15 13:11:34 +10:00
Serhiy Storchaka 9171a8b4ce Issue #27574: Decreased an overhead of parsing keyword arguments in functions
implemented with using Argument Clinic.
2016-08-14 10:52:18 +03:00
Raymond Hettinger 08eef3ff49 Re-linewrap comments 2016-08-07 20:20:33 -07:00
Martin Panter 02b75abf73 Merge spelling and grammar fixes from 3.5 2016-08-05 01:51:39 +00:00
Martin Panter 69332c1a64 Fix spelling and grammar in documentation and code comments 2016-08-04 13:07:31 +00:00
Serhiy Storchaka 133138a284 Issue #22557: Now importing already imported modules is up to 2.5 times faster. 2016-08-02 22:51:21 +03:00
Martin Panter d2f87472fe Issue #17596: MINGW: add wincrypt.h in Python/random.c
Based on patch by Roumen Petrov.
2016-07-29 04:00:44 +00:00
Martin Panter 36261d7446 Issue #16191: Merge comment fixes from 3.5 2016-07-18 08:25:01 +00:00
Martin Panter 95f53c13ce Issue #16191: Fix up references to renamed variables 2016-07-18 08:23:26 +00:00
Serhiy Storchaka caaf53e748 Issue #27419: Added temporary workaround for subinterpreters. 2016-07-17 14:16:04 +03:00
Serhiy Storchaka 80ab069f1b Issue #27419: Added temporary workaround for subinterpreters. 2016-07-17 14:15:28 +03:00
Serhiy Storchaka 7905f99a27 Issue #27419: Standard __import__() no longer look up "__import__" in globals
or builtins for importing submodules or "from import".  Fixed a crash if
raise a warning about unabling to resolve package from __spec__ or
__package__.
2016-07-17 12:51:34 +03:00
Serhiy Storchaka b3b65e618c Issue #27419: Standard __import__() no longer look up "__import__" in globals
or builtins for importing submodules or "from import".  Fixed handling an
error of non-string package name.
2016-07-17 12:47:17 +03:00
Brett Cannon b2f8a801c2 Check in update for importlib_external.h 2016-07-16 10:46:10 -07:00
Brett Cannon 7ca63cb7cc Fix regressions introduced by fixes for issue #27083. 2016-07-16 10:44:13 -07:00
Brett Cannon b3e73b30ff Merge for #27083 2016-07-15 11:55:21 -07:00
Benjamin Peterson ce7b27d169 merge 3.5 (#27514) 2016-07-14 22:02:09 -07:00
Benjamin Peterson e09ed5419b make too many nested blocks be a SyntaxError instead of a SystemError (closes #27514)
Patch by Ammar Askar.
2016-07-14 22:00:03 -07:00
Brett Cannon 2247e5c48c Update frozen importlib code 2016-07-08 16:44:54 -07:00
Brett Cannon fdcdd9ed80 Issue #26896: Disambiguate uses of "importer" with "finder".
Thanks to Oren Milman for the patch.
2016-07-08 11:00:00 -07:00
Serhiy Storchaka 2954f83999 - Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 18:20:03 +03:00
Serhiy Storchaka 1a2b24f02d Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 17:35:15 +03:00
Serhiy Storchaka 7e160ce356 Issue #23034: The output of a special Python build with defined COUNT_ALLOCS,
SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now off by  default.  It can
be re-enabled using the "-X showalloccount" option.  It now outputs to stderr
instead of stdout.
2016-07-03 21:03:53 +03:00
Serhiy Storchaka fbd1523525 Issue #27352: Correct the validation of the ImportFrom AST node and simplify
the implementation of the IMPORT_NAME opcode.
2016-06-27 21:39:12 +03:00
Serhiy Storchaka da9c513414 Issue #27255: Added more predictions in ceval.c. 2016-06-27 18:58:57 +03:00
Serhiy Storchaka cfdfbb4d3c Issue #27342: Replaced some Py_XDECREFs with Py_DECREFs.
Patch by Xiang Zhang.
2016-06-18 09:44:03 +03:00
Victor Stinner d7292b5e9f Issue #27336: Fix compilation on Windows
Replace "#if WITH_THREAD" with "#ifdef WITH_THREAD".
2016-06-17 12:29:00 +02:00
Berker Peksag 531396c764 Issue #27336: Fix compilation failures --without-threads 2016-06-17 13:25:01 +03:00
Victor Stinner a63073a807 Merge 3.5 2016-06-17 00:01:30 +02:00
Victor Stinner ec721f3305 py_getrandom(): use long type for the syscall() result
Issue #27278. It should fix a conversion warning.

In practice, the Linux kernel doesn't return more than 32 MB per call to the
getrandom() syscall.
2016-06-16 23:53:47 +02:00
Serhiy Storchaka 607f8a5e28 Issue #27301: Fixed incorrect return codes for errors in compile.c. 2016-06-15 20:07:53 +03:00
Serhiy Storchaka 694de3bff7 Issue #27301: Fixed incorrect return codes for errors in compile.c. 2016-06-15 20:06:07 +03:00
Victor Stinner d017176209 Merge 3.5 2016-06-14 16:36:00 +02:00
Victor Stinner c72828ba33 cleanup random.c
Casting Py_ssize_t to Py_ssize_t is useless.
2016-06-14 16:35:49 +02:00
Victor Stinner 370f5136d4 Merge 3.5 (os.urandom, issue #27278) 2016-06-14 16:33:17 +02:00