summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Enhance and rewrite traceback dump C functionsVictor Stinner2016-03-151-53/+56
| | | | | | | | | | | | | Issue #26564: * Expose _Py_DumpASCII() and _Py_DumpDecimal() in traceback.h * Change the type of the second _Py_DumpASCII() parameter from int to unsigned long * Rewrite _Py_DumpDecimal() and dump_hexadecimal() to write directly characters in the expected order, avoid the need of reversing the string. * dump_hexadecimal() limits width to the size of the buffer * _Py_DumpASCII() does nothing if the object is not a Unicode string * dump_frame() wrtites "???" as the line number if the line number is negative
* Add more checks on the GILVictor Stinner2016-03-143-5/+40
| | | | | | | | | | | | Issue #10915, #15751, #26558: * PyGILState_Check() now returns 1 (success) before the creation of the GIL and after the destruction of the GIL. It allows to use the function early in Python initialization and late in Python finalization. * Add a flag to disable PyGILState_Check(). Disable PyGILState_Check() when Py_NewInterpreter() is called * Add assert(PyGILState_Check()) to: _Py_dup(), _Py_fstat(), _Py_read() and _Py_write()
* Fix Py_FatalError() if called without the GILVictor Stinner2016-03-141-34/+50
| | | | | | Issue #26558: If Py_FatalError() is called without the GIL, don't try to print the current exception, nor try to flush stdout and stderr: only dump the traceback of Python threads.
* Add PYTHONMALLOC env varVictor Stinner2016-03-142-5/+10
| | | | | | | | | | | | | Issue #26516: * Add PYTHONMALLOC environment variable to set the Python memory allocators and/or install debug hooks. * PyMem_SetupDebugHooks() can now also be used on Python compiled in release mode. * The PYTHONMALLOCSTATS environment variable can now also be used on Python compiled in release mode. It now has no effect if set to an empty string. * In debug mode, debug hooks are now also installed on Python memory allocators when Python is configured without pymalloc.
* Merge 3.5 (issue #25888)Yury Selivanov2016-03-021-0/+15
|\
| * coroutines: Error when awaiting on coroutine that's being awaitedYury Selivanov2016-03-021-0/+15
| | | | | | | | Issue #25888
* | Update assertion in compiler_addop_i()Victor Stinner2016-03-011-4/+8
| | | | | | | | | | | | | | In practice, bytecode instruction arguments are unsigned. Update the assertion to make it more explicit that argument must be greater or equal than 0. Rewrite also the comment.
* | Issue #22836: Merge exception reporting from 3.5Martin Panter2016-02-282-5/+19
|\ \ | |/
| * Issue #22836: Keep exception reports sensible despite errorsMartin Panter2016-02-282-5/+19
| |
* | compile.c: inline compiler_use_new_block()Victor Stinner2016-02-271-26/+9
| | | | | | | | | | | | * Inline compiler_use_new_block() function into its only callee, compiler_enter_scope() * Remove unused NEW_BLOCK() macro
* | remove unused c_encoding struct memberBenjamin Peterson2016-02-261-17/+4
| |
* | rewrite parsestr() so it's comprehensible; remove dead codeBenjamin Peterson2016-02-261-24/+12
| |
* | c_encoding can never be NULL, which allows some code simplificationBenjamin Peterson2016-02-261-47/+43
| |
* | Merge for issue #26367Brett Cannon2016-02-201-393/+398
|\ \ | |/
| * Issue #26367: Have importlib.__init__() raise RuntimeError whenBrett Cannon2016-02-201-370/+371
| | | | | | | | | | | | | | 'level' is specified but no __package__. This brings the function inline with builtins.__import__(). Thanks to Manuel Jacob for the patch.
* | Issue #25985: sys.version_info is now used instead of sys.versionSerhiy Storchaka2016-02-111-15/+16
| | | | | | | | to format short Python version.
* | Issue #26312: SystemError is now raised in all programming bugs with usingSerhiy Storchaka2016-02-111-6/+6
| | | | | | | | | | PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some programming bugs.
* | Issue #25698: Prevent possible replacing imported module with the empty oneSerhiy Storchaka2016-02-101-2/+6
|\ \ | |/ | | | | if the stack is too deep.
| * Issue #25698: Prevent possible replacing imported module with the empty oneSerhiy Storchaka2016-02-101-2/+6
| | | | | | | | if the stack is too deep.
* | compiler: don't emit SyntaxWarning on const stmtVictor Stinner2016-02-081-22/+2
| | | | | | | | | | Issue #26204: the compiler doesn't emit SyntaxWarning warnings anymore when constant statements are ignored.
* | compiler now ignores constant statementsVictor Stinner2016-02-081-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compile ignores constant statements and emit a SyntaxWarning warning. Don't emit the warning for string statement because triple quoted string is a common syntax for multiline comments. Don't emit the warning on ellipis neither: 'def f(): ...' is a legit syntax for abstract functions. Changes: * test_ast: ignore SyntaxWarning when compiling test statements. Modify test_load_const() to use assignment expressions rather than constant expression. * test_code: add more kinds of constant statements, ignore SyntaxWarning when testing that the compiler removes constant statements. * test_grammar: ignore SyntaxWarning on the statement "1"
* | Issue #26198: ValueError is now raised instead of TypeError on bufferSerhiy Storchaka2016-02-071-2/+7
| | | | | | | | | | overflow in parsing "es#" and "et#" format units. SystemError is now raised instead of TypeError on programmical error in parsing format string.
* | Issue #26198: Fixed error messages for some argument parsing errors.Serhiy Storchaka2016-02-071-12/+20
|\ \ | |/
| * Issue #26198: Fixed error messages for some argument parsing errors.Serhiy Storchaka2016-02-071-12/+20
| | | | | | | | | | Fixed the documented about buffer overflow error for "es#" and "et#" format units.
* | Switch to more idiomatic C code.Eric V. Smith2016-02-051-3/+4
| |
* | Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was ↵Eric V. Smith2016-02-051-2/+2
| | | | | | | | being corrupted if an error occurred in PyObject_Format().
* | Issue #4806: Merge * unpacking fix from 3.5Martin Panter2016-01-311-8/+10
|\ \ | |/
| * Issue #4806: Avoid masking original TypeError in call with * unpackingMartin Panter2016-01-311-8/+10
| | | | | | | | Based on patch by Hagen Fürstenau and Daniel Urban.
| * code_richcompare() now uses the constants typesVictor Stinner2016-01-221-48/+10
| | | | | | | | | | | | | | | | | | Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, "f1, f2 = lambda: 1, lambda: 1.0" is now correctly compiled to two different functions: f1() returns 1 (int) and f2() returns 1.0 (int), even if 1 and 1.0 are equal. Add a new _PyCode_ConstantKey() private function.
* | Issue #26146: enhance ast.Constant error messageVictor Stinner2016-01-261-1/+3
| | | | | | | | | | | | | | Mention the name of the invalid type in error message of AST validation for constants. Suggestion made by Joseph Jevnik on a review.
* | Issue #26146: remove useless codeVictor Stinner2016-01-261-7/+0
| | | | | | | | | | | | | | | | obj2ast_constant() code is baesd on obj2ast_object() which has a special case for Py_None. But in practice, we don't need to have a special case for constants. Issue noticed by Joseph Jevnik on a review.
* | Fix a refleak in validate_constant()Victor Stinner2016-01-261-0/+2
| | | | | | | | Issue #26146.
* | Add ast.ConstantVictor Stinner2016-01-255-14/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26146: Add a new kind of AST node: ast.Constant. It can be used by external AST optimizers, but the compiler does not emit directly such node. An optimizer can replace the following AST nodes with ast.Constant: * ast.NameConstant: None, False, True * ast.Num: int, float, complex * ast.Str: str * ast.Bytes: bytes * ast.Tuple if items are constants too: tuple * frozenset Update code to accept ast.Constant instead of ast.Num and/or ast.Str: * compiler * docstrings * ast.literal_eval() * Tools/parser/unparse.py
* | Issue #26146: marshal.loads() now uses the empty frozenset singletonVictor Stinner2016-01-231-29/+40
| |
* | Issue #18018: Raise an ImportError if a relative import is attemptedBrett Cannon2016-01-231-3/+8
| | | | | | | | | | | | | | | | with no known parent package. Previously SystemError was raised if the parent package didn't exist (e.g., __package__ was set to ''). Thanks to Florent Xicluna and Yongzhi Pan for reporting the issue.
* | Issue #25791: Warn when __package__ != __spec__.parent.Brett Cannon2016-01-222-93/+121
| | | | | | | | | | | | | | | | | | In a previous change, __spec__.parent was prioritized over __package__. That is a backwards-compatibility break, but we do eventually want __spec__ to be the ground truth for module details. So this change reverts the change in semantics and instead raises an ImportWarning when __package__ != __spec__.parent to give people time to adjust to using spec objects.
* | Use Py_uintptr_t for atomic pointersVictor Stinner2016-01-222-27/+28
| | | | | | | | | | | | | | | | Issue #26161: Use Py_uintptr_t instead of void* for atomic pointers in pyatomic.h. Use atomic_uintptr_t when <stdatomic.h> is used. Using void* causes compilation warnings depending on which implementation of atomic types is used.
* | code_richcompare() now uses the constants typesVictor Stinner2016-01-221-48/+10
| | | | | | | | | | | | | | | | | | Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, "f1, f2 = lambda: 1, lambda: 1.0" is now correctly compiled to two different functions: f1() returns 1 (int) and f2() returns 1.0 (int), even if 1 and 1.0 are equal. Add a new _PyCode_ConstantKey() private function.
* | co_lnotab supports negative line number deltaVictor Stinner2016-01-203-135/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26107: The format of the co_lnotab attribute of code objects changes to support negative line number delta. Changes: * assemble_lnotab(): if line number delta is less than -128 or greater than 127, emit multiple (offset_delta, lineno_delta) in co_lnotab * update functions decoding co_lnotab to use signed 8-bit integers - dis.findlinestarts() - PyCode_Addr2Line() - _PyCode_CheckLineNumber() - frame_setlineno() * update lnotab_notes.txt * increase importlib MAGIC_NUMBER to 3361 * document the change in What's New in Python 3.6 * cleanup also PyCode_Optimize() to use better variable names
* | Merge 3.5Victor Stinner2016-01-203-21/+22
|\ \ | |/ | | | | Issue #26154: Add a new private _PyThreadState_UncheckedGet() function.
| * Add _PyThreadState_UncheckedGet()Victor Stinner2016-01-203-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26154: Add a new private _PyThreadState_UncheckedGet() function which gets the current thread state, but don't call Py_FatalError() if it is NULL. Python 3.5.1 removed the _PyThreadState_Current symbol from the Python C API to no more expose complex and private atomic types. Atomic types depends on the compiler or can even depend on compiler options. The new function _PyThreadState_UncheckedGet() allows to get the variable value without having to care of the exact implementation of atomic types. Changes: * Replace direct usage of the _PyThreadState_Current variable with a call to _PyThreadState_UncheckedGet(). * In pystate.c, replace direct usage of the _PyThreadState_Current variable with the PyThreadState_GET() macro for readability. * Document also PyThreadState_Get() in pystate.h
* | Fix indentation of continuation lines.Georg Brandl2016-01-181-1/+1
| |
* | Fix two instances of wrong indentation.Georg Brandl2016-01-181-2/+2
| |
* | Issue #25791: Raise an ImportWarning when __spec__ or __package__ areBrett Cannon2016-01-152-294/+329
| | | | | | | | | | | | | | | | not defined for a relative import. This is the start of work to try and clean up import semantics to rely more on a module's spec than on the myriad attributes that get set on a module. Thanks to Rose Ames for the patch.
* | Issue #20440: Cleaning up the code by using Py_SETREF.Serhiy Storchaka2016-01-053-14/+5
| |
* | merge 3.5Benjamin Peterson2016-01-011-1/+1
|\ \ | |/
| * merge 3.4Benjamin Peterson2016-01-011-1/+1
| |\
| | * merge 3.3Benjamin Peterson2016-01-011-1/+1
| | |\
| | | * 2016 will be another year of writing copyrighted codeBenjamin Peterson2016-01-011-1/+1
| | | |
* | | | merge 3.5 (#25973)Benjamin Peterson2015-12-291-8/+16
|\ \ \ \ | |/ / /