Commit Graph

169 Commits

Author SHA1 Message Date
Pablo Galindo 37494b441a
bpo-38530: Offer suggestions on AttributeError (#16856)
When printing AttributeError, PyErr_Display will offer suggestions of similar 
attribute names in the object that the exception was raised from:

>>> collections.namedtoplo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you mean: namedtuple?
2021-04-14 02:36:07 +01:00
Lewis Gaul 11159d2c9d
bpo-43080: pprint for dataclass instances (GH-24389)
* Added pprint support for dataclass instances which don't have a custom __repr__.
2021-04-13 19:59:24 -04:00
Inada Naoki 695d47b51e
bpo-43785: Update bz2 document (GH-25351) 2021-04-14 08:22:49 +09:00
Victor Stinner 85918e4ab6
bpo-43774: Add more links to configure options (GH-25363) 2021-04-12 23:27:35 +02:00
Jelle Zijlstra 9825bdfbd5
bpo-43723: Deprecate camelCase aliases from threading (GH-25174)
The snake_case names have existed since Python 2.6, so there is
no reason to keep the old camelCase names around. One similar
method, threading.Thread.isAlive, was already removed in
Python 3.9 (bpo-37804).
2021-04-12 10:42:53 +02:00
Victor Stinner 553ee2781a
bpo-43682: Make staticmethod objects callable (GH-25117)
Static methods (@staticmethod) are now callable as regular functions.
2021-04-12 00:21:22 +02:00
Jelle Zijlstra 522433601a
bpo-43783: Add ParamSpecArgs/Kwargs (GH-25298) 2021-04-10 19:57:05 -07:00
Antti Haapala c3a478b7e5
Fix typo about line number in the 3.10 What's New document (GH-25328)
This was a typo copied from PEP 626.
2021-04-11 01:20:41 +01:00
Victor Stinner 09bbebea16
bpo-43753: Add Py_Is() and Py_IsNone() functions (GH-25227)
Add the Py_Is(x, y) function to test if the 'x' object is the 'y'
object, the same as "x is y" in Python. Add also the Py_IsNone(),
Py_IsTrue(), Py_IsFalse() functions to test if an object is,
respectively, the None singleton, the True singleton or the False
singleton.
2021-04-11 00:17:39 +02:00
Victor Stinner 507a574de3
bpo-43682: @staticmethod inherits attributes (GH-25268)
Static methods (@staticmethod) and class methods (@classmethod) now
inherit the method attributes (__module__, __name__, __qualname__,
__doc__, __annotations__) and have a new __wrapped__ attribute.

Changes:

* Add a repr() method to staticmethod and classmethod types.
* Add tests on the @classmethod decorator.
2021-04-09 17:51:22 +02:00
Victor Stinner a41782cc84
bpo-43774: Document configure options (GH-25283)
Add Doc/using/configure.rst documentation to document configure,
preprocessor, compiler and linker options.

Add a new section about the "Python debug build".
2021-04-08 22:32:21 +02:00
Brett Cannon 57c6cb5100
bpo-42135: Deprecate implementations of find_module() and find_loader() (GH-25169) 2021-04-06 08:56:57 -07:00
Dong-hee Na efccff9ac8
bpo-41870: Update What's News 3.10 about vectorcall (#25219)
* bpo-41870: Update What's News 3.10 about vectorcall

* update

* Update Doc/whatsnew/3.10.rst

Co-authored-by: Victor Stinner <vstinner@python.org>

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-07 00:43:59 +09:00
Brett Cannon f97dc80068
bpo-43672: raise ImportWarning when calling find_loader() (GH-25119) 2021-04-02 12:35:32 -07:00
Zackery Spytz afd1265058
bpo-31956: Add start and stop parameters to array.index() (GH-25059)
Co-Authored-By: Anders Lorentsen <Phaqui@gmail.com>
2021-04-03 00:28:35 +09:00
Victor Stinner 3359cab038
bpo-43688: Support the limited C API in debug mode (GH-25131)
The limited C API is now supported if Python is built in debug mode
(if the Py_DEBUG macro is defined). In the limited C API, the
Py_INCREF() and Py_DECREF() functions are now implemented as opaque
function calls, rather than accessing directly the PyObject.ob_refcnt
member, if Python is built in debug mode and the Py_LIMITED_API macro
targets Python 3.10 or newer. It became possible to support the
limited C API in debug mode because the PyObject structure is the
same in release and debug mode since Python 3.8 (see bpo-36465).

The limited C API is still not supported in the --with-trace-refs
special build (Py_TRACE_REFS macro).
2021-04-02 15:45:37 +02:00
Don Kirkby 18701a0608
Fix typos in 3.10 "What's new" (GH-25104) 2021-04-01 15:00:30 +09:00
Ethan Furman b775106d94
bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)
* Enum: streamline repr() and str(); improve docs

- repr() is now ``enum_class.member_name``
- stdlib global enums are ``module_name.member_name``
- str() is now ``member_name``
- add HOW-TO section for ``Enum``
- change main documentation to be an API reference
2021-03-30 21:17:26 -07:00
Brett Cannon a7ff6df60c
bpo-42134: Raise ImportWarning when calling find_module() in the import system (GH-25044) 2021-03-30 08:43:03 -07:00
Inada Naoki 4827483f47
bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)
See [PEP 597](https://www.python.org/dev/peps/pep-0597/).

* Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`.
* Add EncodingWarning
* Add io.text_encoding()
* open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled.
* _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python)
* bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding().
* What's new entry
2021-03-29 12:28:14 +09:00
Brett Cannon 1899087b21
bpo-42136: Deprecate module_repr() as found in importlib (GH-25022) 2021-03-26 11:55:07 -07:00
blopblopy 56816bb845
"exists" -> "exist" in What's New 3.10 (GH-25019) 2021-03-25 09:14:22 -07:00
Brett Cannon 9cb31d6716
bpo-42137: have ModuleType.__repr__ prefer __spec__ over module_repr() (GH-24953)
This is to work towards the removal of the use of  module_repr() in Python 3.12 (documented as deprecated since 3.4).
2021-03-24 08:26:56 -07:00
Victor Stinner 8370e07e1e
bpo-43244: Remove the pyarena.h header (GH-25007)
Remove the pyarena.h header file with functions:

* PyArena_New()
* PyArena_Free()
* PyArena_Malloc()
* PyArena_AddPyObject()

These functions were undocumented, excluded from the limited C API,
and were only used internally by the compiler.

Add pycore_pyarena.h header. Rename functions:

* PyArena_New() => _PyArena_New()
* PyArena_Free() => _PyArena_Free()
* PyArena_Malloc() => _PyArena_Malloc()
* PyArena_AddPyObject() => _PyArena_AddPyObject()
2021-03-24 02:23:01 +01:00
Victor Stinner 57364ce34e
bpo-43244: Remove parser_interface.h header file (GH-25001)
Remove parser functions using the "struct _mod" type, because the
AST C API was removed:

* PyParser_ASTFromFile()
* PyParser_ASTFromFileObject()
* PyParser_ASTFromFilename()
* PyParser_ASTFromString()
* PyParser_ASTFromStringObject()

These functions were undocumented and excluded from the limited C
API.

Add pycore_parser.h internal header file. Rename functions:

* PyParser_ASTFromFileObject() => _PyParser_ASTFromFile()
* PyParser_ASTFromStringObject() => _PyParser_ASTFromString()

These functions are no longer exported (replace PyAPI_FUNC() with
extern).

Remove also _PyPegen_run_parser_from_file() function. Update
test_peg_generator to use _PyPegen_run_parser_from_file_pointer()
instead.
2021-03-24 01:29:09 +01:00
Pablo Galindo a054f6b2b1
bpo-43452: Document the PyType_Lookup optimizations in the What's New for 3.10 (GH-24949) 2021-03-24 00:04:52 +00:00
Victor Stinner a81fca6ec8
bpo-43244: Add pycore_compile.h header file (GH-25000)
Remove the compiler functions using "struct _mod" type, because the
public AST C API was removed:

* PyAST_Compile()
* PyAST_CompileEx()
* PyAST_CompileObject()
* PyFuture_FromAST()
* PyFuture_FromASTObject()

These functions were undocumented and excluded from the limited C API.

Rename functions:

* PyAST_CompileObject() => _PyAST_Compile()
* PyFuture_FromASTObject() => _PyFuture_FromAST()

Moreover, _PyFuture_FromAST() is no longer exported (replace
PyAPI_FUNC() with extern). _PyAST_Compile() remains exported for
test_peg_generator.

Remove also compatibility functions:

* PyAST_Compile()
* PyAST_CompileEx()
* PyFuture_FromAST()
2021-03-24 00:51:50 +01:00
Joshua Bronson f0a6fde882
bpo-31861: Add aiter and anext to builtins (#23847)
Co-authored-by: jab <jab@users.noreply.github.com>
Co-authored-by: Daniel Pope <mauve@mauveweb.co.uk>
Co-authored-by: Justin Wang <justin39@gmail.com>
2021-03-23 15:47:21 -07:00
Victor Stinner 94faa0724f
bpo-43244: Remove ast.h, asdl.h, Python-ast.h headers (GH-24933)
These functions were undocumented and excluded from the limited C
API.

Most names defined by these header files were not prefixed by "Py"
and so could create names conflicts. For example, Python-ast.h
defined a "Yield" macro which was conflict with the "Yield" name used
by the Windows <winbase.h> header.

Use the Python ast module instead.

* Move Include/asdl.h to Include/internal/pycore_asdl.h.
* Move Include/Python-ast.h to Include/internal/pycore_ast.h.
* Remove ast.h header file.
* pycore_symtable.h no longer includes Python-ast.h.
2021-03-23 20:47:40 +01:00
Victor Stinner cd27af70d5
bpo-41718: Update runpy startup time What's New (GH-24998) 2021-03-23 20:22:40 +01:00
Rui Cunha b05b48dd7a
bpo-43571: Add IPPROTO_MPTCP macro (GH-24946)
Add IPPROTO_MPTCP constant when defined in the system headers.
2021-03-20 15:04:56 -07:00
Mark Shannon 148bc05844
Mention that code.co_lnotab is deprecated in what's new for 3.10. (#24902) 2021-03-19 17:30:24 +00:00
Victor Stinner 28ad12f8fe
bpo-43244: Remove symtable.h header file (GH-24910)
Rename Include/symtable.h to to Include/internal/pycore_symtable.h,
don't export symbols anymore (replace PyAPI_FUNC and PyAPI_DATA with
extern) and rename functions:

* PyST_GetScope() to _PyST_GetScope()
* PySymtable_BuildObject() to _PySymtable_Build()
* PySymtable_Free() to _PySymtable_Free()

Remove PySymtable_Build(), Py_SymtableString() and
Py_SymtableStringObject() functions.

The Py_SymtableString() function was part the stable ABI by mistake
but it could not be used, since the symtable.h header file was
excluded from the limited C API.

The Python symtable module remains available and is unchanged.
2021-03-19 12:41:49 +01:00
Christian Heimes 32eba61ea4
bpo-43466: Add --with-openssl-rpath configure option (GH-24820) 2021-03-19 10:29:25 +01:00
Victor Stinner eec8e61992
bpo-43244: Remove the PyAST_Validate() function (GH-24911)
Remove the PyAST_Validate() function. It is no longer possible to
build a AST object (mod_ty type) with the public C API. The function
was already excluded from the limited C API (PEP 384).

Rename PyAST_Validate() function to _PyAST_Validate(), move it to the
internal C API, and don't export it anymore (replace PyAPI_FUNC with
extern).

The function was added in bpo-12575 by
the commit 832bfe2ebd.
2021-03-18 14:57:49 +01:00
Mark Shannon 6086ae7fd4
Add PEP 626 to what's new in 3.10. (#24892) 2021-03-16 13:43:58 +00:00
Jason R. Coombs 35d5068928
bpo-43428: Improve documentation for importlib.metadata changes. (GH-24858)
* bpo-43428: Sync with importlib_metadata 3.7.3 (16ac3a95)

* Add 'versionadded' for importlib.metadata.packages_distributions

* Add section in what's new for Python 3.10 highlighting most salient changes and relevant backport.
2021-03-14 22:20:49 -04:00
Antoine Pitrou ba251c2ae6
bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)
Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
2021-03-11 23:35:45 +01:00
Pablo Galindo b4f9089d4a
bpo-43439: Add audit hooks for gc functions (GH-24794) 2021-03-10 00:53:57 +00:00
Pablo Galindo 8747c1f233
Improve the description of the improvements in bpo-42202 (GH-24738) 2021-03-04 01:29:29 +00:00
Julien Palard b04f1cb9df
Doc: typo fix. (GH-24721) 2021-03-03 11:32:12 +01:00
Ken Jin 727a68b6e5
Reorder contents of 3.10's What's New (#24687) 2021-03-02 16:52:03 -08:00
Ned Deily a65b050516
bpo-42603: Add whatsnew and ACKS entries. (GH-24675) 2021-03-01 00:27:20 -05:00
Carol Willing 41934b399b
GH-42128: Add Pattern Matching to What's New (#24667)
* Add Pattern Matching to What's New

* add review suggestions

* fix stray indent

* Add suggestions from gvr and lr

* trim whitespace
2021-02-28 15:43:17 -08:00
Dennis Sweeney e8f5ddd33e
Add whatsnew note for GH-22904 (#24672) 2021-02-28 15:32:04 -06:00
Alex cc02b4f2e8
bpo-38302: __pow__/__rpow__ now called when __ipow__ returns NotImplemented (#16459) 2021-02-26 11:58:39 -08:00
Pablo Galindo d439fb304c
bpo-43277: Add PySet_CheckExact to the C-API (GH-24598)
For some mysterious reason we have PySet_Check, PyFrozenSet_Check, PyAnySet_Check, PyAnySet_CheckExact and PyFrozenSet_CheckExact but no PySet_CheckExact.
2021-02-20 18:03:08 +00:00
Victor Stinner 46496f9d12
bpo-42990: Functions inherit current builtins (GH-24564)
The types.FunctionType constructor now inherits the current builtins
if the globals dictionary has no "__builtins__" key, rather than
using {"None": None} as builtins: same behavior as eval() and exec()
functions.

Defining a function with "def function(...): ..." in Python is not
affected, globals cannot be overriden with this syntax: it also
inherits the current builtins.

PyFrame_New(), PyEval_EvalCode(), PyEval_EvalCodeEx(),
PyFunction_New() and PyFunction_NewWithQualName() now inherits the
current builtins namespace if the globals dictionary has no
"__builtins__" key.

* Add _PyEval_GetBuiltins() function.
* _PyEval_BuiltinsFromGlobals() now uses _PyEval_GetBuiltins() if
  builtins cannot be found in globals.
* Add tstate parameter to _PyEval_BuiltinsFromGlobals().
2021-02-20 15:17:18 +01:00
Nicholas Sim 4a6bf276ed
bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561)
Include/{odictobject.h,parser_interface.h,picklebufobject.h,pydebug.h,pyfpe.h}
into Include/cpython/.

Parser: peg_api: include Python.h instead of parser_interface.h.
2021-02-19 15:55:46 +01:00
Victor Stinner a3c3ffa68e
bpo-42990: Add __builtins__ attribute to functions (GH-24559)
Expose the new PyFunctionObject.func_builtins member in Python as a
new __builtins__ attribute on functions.

Document also the behavior change in What's New in Python 3.10.
2021-02-18 12:35:37 +01:00