summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). ↵Serhiy Storchaka2018-10-142-3/+5
| | | | | | | (GH-9852) bytes and bytearray constructors converted unexpected exceptions (e.g. MemoryError and KeyboardInterrupt) to TypeError.
* bpo-34940: Fix the error handling in _check_for_legacy_statements(). (GH-9764)Zackery Spytz2018-10-121-8/+18
|
* Micro-optimize list index range checks (GH-9784)Raymond Hettinger2018-10-111-5/+18
|
* Add missing closing quote and trailing period in str.isidentifier() ↵Emanuele Gaifas2018-10-082-4/+4
| | | | | docstring (GH-9756) This rectifies commit ffc5a14d00db984c8e72c7b67da8a493e17e2c14.
* bpo-33014: Clarify str.isidentifier docstring (GH-6088)Sanyam Khurana2018-10-082-6/+6
| | | | | | * bpo-33014: Clarify str.isidentifier docstring * bpo-33014: Add code example in isidentifier documentation
* bpo-34910: Ensure that PyObject_Print() always returns -1 on error. (GH-9733)Zackery Spytz2018-10-061-2/+3
|
* bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() ↵Zackery Spytz2018-10-051-1/+1
| | | | | | | (GH-9705) The _PyLong_FromByteArray() call in int_from_bytes_impl() was unchecked.
* bpo-34879: Fix a possible null pointer dereference in bytesobject.c (GH-9683)Zackery Spytz2018-10-031-1/+1
| | | | | formatfloat() was not checking if PyBytes_FromStringAndSize() failed, which could lead to a null pointer dereference in _PyBytes_FormatEx().
* bpo-30156: Remove property_descr_get() optimization (GH-9541)Victor Stinner2018-10-011-28/+5
| | | | | | | | | | | | | | | | property_descr_get() uses a "cached" tuple to optimize function calls. But this tuple can be discovered in debug mode with sys.getobjects(). Remove the optimization, it's not really worth it and it causes 3 different crashes last years. Microbenchmark: ./python -m perf timeit -v \ -s "from collections import namedtuple; P = namedtuple('P', 'x y'); p = P(1, 2)" \ --duplicate 1024 "p.x" Result: Mean +- std dev: [ref] 32.8 ns +- 0.8 ns -> [patch] 40.4 ns +- 1.3 ns: 1.23x slower (+23%)
* bpo-34320: Fix dict(o) didn't copy order of dict subclass (GH-8624)INADA Naoki2018-09-261-1/+3
| | | | | | | When dict subclass overrides order (`__iter__()`, `keys()`, and `items()`), `dict(o)` should use it instead of dict ordering. https://bugs.python.org/issue34320
* Fix compiler warning with a type cast (GH-9300)Raymond Hettinger2018-09-141-1/+1
|
* Fix-up parenthesis, organization, and NULL check (GH-9297)Raymond Hettinger2018-09-141-6/+11
|
* bpo-33073: Adding as_integer_ratio to ints. (GH-8750)Lisa Roach2018-09-142-1/+60
|
* closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218)Benjamin Peterson2018-09-122-2/+2
|
* bpo-1621: Avoid signed integer overflow in set_table_resize(). (GH-9059)Sergey Fedoseev2018-09-111-8/+3
| | | | | | | | Address a C undefined behavior signed integer overflow issue in set object table resizing. Our -fwrapv compiler flag and practical reasons why sets are unlikely to get this large should mean this was never an issue but it was incorrect code that generates code analysis warnings. <!-- issue-number: [bpo-1621](https://www.bugs.python.org/issue1621) --> https://bugs.python.org/issue1621 <!-- /issue-number -->
* Revert "bpo-34595: Add %T format to PyUnicode_FromFormatV() (GH-9080)" (GH-9187)Victor Stinner2018-09-111-52/+53
| | | This reverts commit 886483e2b9bbabf60ab769683269b873381dd5ee.
* Fix misleading mentions of tp_size in comments (GH-9093)Peter Eisentraut2018-09-102-3/+3
| | | | Many type object initializations labeled a field "tp_size" in the comment, but the name of that field is tp_basicsize.
* bpo-34595: Add %T format to PyUnicode_FromFormatV() (GH-9080)Victor Stinner2018-09-071-53/+52
| | | | | | | | | * Add %T format to PyUnicode_FromFormatV(), and so to PyUnicode_FromFormat() and PyErr_Format(), to format an object type name: equivalent to "%s" with Py_TYPE(obj)->tp_name. * Replace Py_TYPE(obj)->tp_name with %T format in unicodeobject.c. * Add unit test on %T format. * Rename unicode_fromformat_write_cstr() to unicode_fromformat_write_utf8(), to make the intent more explicit.
* bpo-25750: fix refcounts in type_getattro() (GH-6118)jdemeyer2018-09-071-6/+11
| | | | When calling tp_descr_get(self, obj, type), make sure that we own a strong reference to "self".
* closes bpo-34599: Improve performance of _Py_bytes_capitalize(). (GH-9083)Sergey Fedoseev2018-09-071-17/+3
|
* bpo-34523: Support surrogatepass in locale codecs (GH-8995)Victor Stinner2018-08-292-73/+102
| | | | | | | | | | | | | | | | | | | | Add support for the "surrogatepass" error handler in PyUnicode_DecodeFSDefault() and PyUnicode_EncodeFSDefault() for the UTF-8 encoding. Changes: * _Py_DecodeUTF8Ex() and _Py_EncodeUTF8Ex() now support the surrogatepass error handler (_Py_ERROR_SURROGATEPASS). * _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() now use the _Py_error_handler enum instead of "int surrogateescape" to pass the error handler. These functions now return -3 if the error handler is unknown. * Add unit tests on _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() in test_codecs. * Rename get_error_handler() to _Py_GetErrorHandler() and expose it as a private function. * _freeze_importlib doesn't need config.filesystem_errors="strict" workaround anymore.
* bpo-34523: Add _PyCoreConfig.filesystem_encoding (GH-8963)Victor Stinner2018-08-291-24/+18
| | | | | | | | | | | | | | | | | | | | | | | _PyCoreConfig_Read() is now responsible to choose the filesystem encoding and error handler. Using Py_Main(), the encoding is now chosen even before calling Py_Initialize(). _PyCoreConfig.filesystem_encoding is now the reference, instead of Py_FileSystemDefaultEncoding, for the Python filesystem encoding. Changes: * Add filesystem_encoding and filesystem_errors to _PyCoreConfig * _PyCoreConfig_Read() now reads the locale encoding for the file system encoding. * PyUnicode_EncodeFSDefault() and PyUnicode_DecodeFSDefaultAndSize() now use the interpreter configuration rather than Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors global configuration variables. * Add _Py_SetFileSystemEncoding() and _Py_ClearFileSystemEncoding() private functions to only modify Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors in coreconfig.c. * _Py_CoerceLegacyLocale() now takes an int rather than _PyCoreConfig for the warning.
* closes bpo-34504: Remove the useless NULL check in PySequence_Check(). (GH-8935)Alexey Izbyshev2018-08-251-1/+1
| | | Reported by Svace static analyzer.
* closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before ↵Alexey Izbyshev2018-08-251-4/+9
| | | | | dereferencing it. (GH-8930) Reported by Svace static analyzer.
* closes bpo-34493: Objects/genobject.c: Add missing NULL check to ↵Alexey Izbyshev2018-08-251-0/+3
| | | | compute_cr_origin() (GH-8911)
* closes bpo-34468: Objects/rangeobject.c: Fix an always-false condition in ↵Alexey Izbyshev2018-08-241-4/+4
| | | | | | | | range_repr() (GH-8880) Also, propagate the error from PyNumber_AsSsize_t() because we don't care only about OverflowError which is not reported if the second argument is NULL. Reported by Svace static analyzer.
* closes bpo-34477: Objects/typeobject.c: Add missing NULL check to ↵Alexey Izbyshev2018-08-241-0/+3
| | | | | type_init() (GH-8876) Reported by Svace static analyzer.
* bpo-34436: Fix check that disables overallocation for the last fmt specifier ↵Alexey Izbyshev2018-08-231-3/+3
| | | | | (GH-8826) Reported by Svace static analyzer.
* bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)Alexey Izbyshev2018-08-191-2/+3
| | | Reported by Svace static analyzer.
* bpo-22602: Raise an exception in the UTF-7 decoder for ill-formed sequences ↵Zackery Spytz2018-08-191-0/+5
| | | | | | | starting with "+". (GH-8741) The UTF-7 decoder now raises UnicodeDecodeError for ill-formed sequences starting with "+" (as specified in RFC 2152).
* bpo-34151: Improve performance of some list operations (GH-8332)Sergey Fedoseev2018-08-111-15/+36
|
* bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)Victor Stinner2018-08-036-10/+10
| | | | sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
* bpo-1617161: Make the hash and equality of methods not depending on the ↵Serhiy Storchaka2018-07-313-37/+20
| | | | | | | | | | | value of self. (GH-7848) * The hash of BuiltinMethodType instances no longer depends on the hash of __self__. It depends now on the hash of id(__self__). * The hash and equality of ModuleType and MethodWrapperType instances no longer depend on the hash and equality of __self__. They depend now on the hash and equality of id(__self__). * MethodWrapperType instances no longer support ordering.
* bpo-20260: Implement non-bitwise unsigned int converters for Argument ↵Serhiy Storchaka2018-07-261-0/+96
| | | | Clinic. (GH-8434)
* bpo-34170: Add _PyCoreConfig.bytes_warning (GH-8447)Victor Stinner2018-07-242-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add more fields to _PyCoreConfig: * _check_hash_pycs_mode * bytes_warning * debug * inspect * interactive * legacy_windows_fs_encoding * legacy_windows_stdio * optimization_level * quiet * unbuffered_stdio * user_site_directory * verbose * write_bytecode Changes: * Remove pymain_get_global_config() and pymain_set_global_config() which became useless. These functions have been replaced by _PyCoreConfig_GetGlobalConfig() and _PyCoreConfig_SetGlobalConfig(). * sys.flags.dont_write_bytecode value is now restricted to 1 even if -B option is specified multiple times on the command line. * PyThreadState_Clear() now uses the config from the current interpreter rather than using global Py_VerboseFlag
* bpo-33720: Refactor marshalling/unmarshalling floats. (GH-8071)Serhiy Storchaka2018-07-241-1/+1
|
* bpo-32500: Fix error messages for sequence and mapping C API. (GH-7846)Serhiy Storchaka2018-07-231-0/+20
| | | | | Fix error messages for PySequence_Size(), PySequence_GetItem(), PySequence_SetItem() and PySequence_DelItem() called with a mapping and PyMapping_Size() called with a sequence.
* bpo-24618: Add a check in the code constructor. (GH-8283)Serhiy Storchaka2018-07-161-3/+15
| | | Check that the size of the varnames tuple is enough at least for all arguments.
* bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)INADA Naoki2018-07-141-0/+2
| | | | | | `_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char. It caused buffer overflow in `_Py_string_to_number_with_underscores()`. This bug is introduced in 9b6c60cb.
* bpo-33597: Reduce PyGC_Head size (GH-7043)INADA Naoki2018-07-101-6/+7
|
* bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)Yury Selivanov2018-07-061-0/+7
|
* fix two typos in Objects/odictobject.c comments (GH-8040)Robert Krzyzanowski2018-07-061-2/+2
|
* bpo-20180: complete AC conversion of Objects/stringlib/transmogrify.h (GH-8039)Tal Einat2018-07-065-76/+243
| | | | * converted bytes methods: expandtabs, ljust, rjust, center, zfill * updated char_convertor to properly set the C default value
* bpo-33418: Add tp_clear for function object (GH-8058)INADA Naoki2018-07-041-13/+21
| | | | | Without tp_clear, GC can't break cyclic reference. It will cause memory leak when cyclic reference is created intentionally.
* Change tp_size to tp_basicsize in comment and realign the comments (GH-6775)Bup2018-06-191-38/+38
|
* bpo-33818: PyExceptionClass_Name() will now return "const char *". (GH-7581)Serhiy Storchaka2018-06-151-2/+2
|
* Clean up after bpo-33738. (GH-7627)Serhiy Storchaka2018-06-111-1/+1
| | | | | * Add declarations even if they are overridden by macros. * Make the declaration and the definition of PyExceptionClass_Name consistent.
* bpo-33738: Address review comments in GH #7477 (GH-7585)Christian Tismer2018-06-102-0/+3
|
* bpo-33738: Fix macros which contradict PEP 384 (GH-7477)Christian Tismer2018-06-092-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During development of the limited API support for PySide, we saw an error in a macro that accessed a type field. This patch fixes the 7 errors in the Python headers. Macros which were not written as capitals were implemented as function. To do the necessary analysis again, a script was included that parses all headers and looks for "->tp_" in serctions which can be reached with active limited API. It is easily possible to call this script as a test. Error listing: ../../Include/objimpl.h:243 #define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) Action: commented only ../../Include/objimpl.h:362 #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) Action: commented only ../../Include/objimpl.h:364 #define PyObject_GET_WEAKREFS_LISTPTR(o) \ ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) Action: commented only ../../Include/pyerrors.h:143 #define PyExceptionClass_Name(x) \ ((char *)(((PyTypeObject*)(x))->tp_name)) Action: implemented function ../../Include/abstract.h:593 #define PyIter_Check(obj) \ ((obj)->ob_type->tp_iternext != NULL && \ (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) Action: implemented function ../../Include/abstract.h:713 #define PyIndex_Check(obj) \ ((obj)->ob_type->tp_as_number != NULL && \ (obj)->ob_type->tp_as_number->nb_index != NULL) Action: implemented function ../../Include/abstract.h:924 #define PySequence_ITEM(o, i)\ ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) Action: commented only
* bpo-33786: Fix asynchronous generators to handle GeneratorExit in athrow() ↵Yury Selivanov2018-06-081-8/+7
| | | | (GH-7467)