Commit Graph

4934 Commits

Author SHA1 Message Date
Victor Stinner 1aa78938b0 Issue #26146: marshal.loads() now uses the empty frozenset singleton 2016-01-23 14:15:48 +01:00
Brett Cannon 9fa812668f Issue #18018: Raise an ImportError if a relative import is attempted
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.
2016-01-22 16:39:02 -08:00
Brett Cannon 849113af6b Issue #25791: Warn when __package__ != __spec__.parent.
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.
2016-01-22 15:25:50 -08:00
Victor Stinner b02ef715a3 Use Py_uintptr_t for atomic pointers
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.
2016-01-22 14:09:55 +01:00
Victor Stinner efb2413ce8 code_richcompare() now uses the constants types
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.
2016-01-22 12:33:12 +01:00
Victor Stinner f3914eb16d co_lnotab supports negative line number delta
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
2016-01-20 12:16:21 +01:00
Victor Stinner b56837a033 Merge 3.5
Issue #26154: Add a new private _PyThreadState_UncheckedGet() function.
2016-01-20 11:19:46 +01:00
Victor Stinner bfd316e750 Add _PyThreadState_UncheckedGet()
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
2016-01-20 11:12:38 +01:00
Georg Brandl 4b5b06203e Fix indentation of continuation lines. 2016-01-18 08:00:15 +01:00
Georg Brandl 5c60ea3fa1 Fix two instances of wrong indentation. 2016-01-18 07:53:59 +01:00
Brett Cannon 63b8505281 Issue #25791: Raise an ImportWarning when __spec__ or __package__ are
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.
2016-01-15 13:33:03 -08:00
Serhiy Storchaka 576f132b98 Issue #20440: Cleaning up the code by using Py_SETREF. 2016-01-05 21:27:54 +02:00
Benjamin Peterson 71db903563 merge 3.5 2016-01-01 10:25:22 -06:00
Benjamin Peterson 4c70293755 merge 3.4 2016-01-01 10:25:12 -06:00
Benjamin Peterson e8c2a957c8 merge 3.3 2016-01-01 10:24:21 -06:00
Benjamin Peterson 75e3630c60 2016 will be another year of writing copyrighted code 2016-01-01 10:23:45 -06:00
Benjamin Peterson 5aab44b301 merge 3.5 (#25973) 2015-12-29 10:08:51 -06:00
Benjamin Peterson 3cc8f4b969 make recording and reporting errors and nonlocal and global directives more robust (closes #25973) 2015-12-29 10:08:34 -06:00
Brett Cannon eae3079041 Issue #25802: Deprecate load_module() on importlib.machinery.SourceFileLoader and SourcelessFileLoader.
They were the only remaining implementations of load_module() not
documented as deprecated.
2015-12-28 17:55:27 -08:00
Serhiy Storchaka 726fc139a5 Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled
automatically.
2015-12-27 15:44:33 +02:00
Serhiy Storchaka 191321d11b Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled
automatically.
2015-12-27 15:41:34 +02:00
Serhiy Storchaka bdb908ea54 Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27 12:38:28 +02:00
Serhiy Storchaka 4a1e70fc31 Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27 12:36:18 +02:00
Serhiy Storchaka ef1585eb9a Issue #25923: Added more const qualifiers to signatures of static and private functions. 2015-12-25 20:01:53 +02:00
Serhiy Storchaka 2d06e84455 Issue #25923: Added the const qualifier to static constant arrays. 2015-12-25 19:53:18 +02:00
Serhiy Storchaka f006940351 Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
2015-12-24 10:39:57 +02:00
Serhiy Storchaka 5a57ade58e Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
2015-12-24 10:35:59 +02:00
Serhiy Storchaka 3fd4a735d8 Issue #25899: Converted non-ASCII characters in docstrings and manpage
to ASCII replacements.  Removed UTF-8 BOM from Misc/NEWS.
Original patch by Chris Angelico.
2015-12-18 13:10:37 +02:00
Serhiy Storchaka 225821c653 Issue #25899: Converted non-ASCII characters in docstrings and manpage
to ASCII replacements.  Original patch by Chris Angelico.
2015-12-18 13:05:04 +02:00
Martin Panter afaf3544aa Merge typo fixes from 3.5 2015-12-17 10:20:21 +00:00
Martin Panter 6f9b010242 Fix a couple of typos in code comments 2015-12-17 10:18:28 +00:00
Martin Panter b4ce1fc31b Issue #5319: New Py_FinalizeEx() API to exit with status 120 on failure 2015-11-30 03:18:29 +00:00
Victor Stinner b4efc963d6 Issue #25557: Refactor _PyDict_LoadGlobal()
Don't fallback to PyDict_GetItemWithError() if the hash is unknown: compute the
hash instead. Add also comments to explain the optimization a little bit.
2015-11-20 09:24:02 +01:00
Victor Stinner e0a0afdf70 Merge 3.5 (pytime) 2015-11-10 12:11:52 +01:00
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
Serhiy Storchaka fad85aadb0 Issue #25558: Use compile-time asserts. 2015-11-07 15:42:38 +02:00
Martin Panter 9513ba3b8f Issue #24802: Merge null termination fixes from 3.5 2015-11-07 03:15:32 +00: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 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
Victor Stinner c106c68aeb 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
Serhiy Storchaka 12b2538ab8 Reuse Py_STRINGIFY() macro in sre_lib.h and dynload_win.c. 2015-11-05 17:43:42 +02:00
Victor Stinner e20310fa19 Issue #25556: Add assertions to PyObject_GetItem() to ensure that an exception
is raised when it returns NULL.

Simplify also ceval.c: rely on the fact that PyObject_GetItem() raised an
exception when it returns NULL.
2015-11-05 13:56:58 +01:00
Victor Stinner ef072961e1 Merge 3.5 2015-11-05 13:55:43 +01: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
Victor Stinner cf01b68b88 sysmodule.c: reuse Py_STRINGIFY() macro 2015-11-05 11:21:38 +01:00
Eric V. Smith a78c7954d5 Issue 25483: Add an opcode to make f-string formatting more robust. 2015-11-03 12:45:05 -05:00
Martin Panter e56a919100 Issue #25523: Merge a-to-an corrections from 3.5 2015-11-02 04:27:17 +00: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