summaryrefslogtreecommitdiff
path: root/Objects/moduleobject.c
AgeCommit message (Collapse)AuthorLines
2018-09-10[3.7] Fix misleading mentions of tp_size in comments. (GH-9136)Benjamin Peterson-2/+2
Many type object initializations labeled a field "tp_size" in the comment, but the name of that field is tp_basicsize.. (cherry picked from commit 0e0bc4e221f592f305d335faf5f8046484eb9238) Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
2018-03-16bpo-32374: m_traverse may be called with m_state=NULL (GH-5140)Miss Islington (bot)-0/+21
Multi-phase initialized modules allow m_traverse to be called while the module is still being initialized, so module authors may need to account for that. (cherry picked from commit c2b0b12d1a137ada1023ab7c10b8d9a0249d95f9) Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
2017-12-14bpo-32225: Implementation of PEP 562 (#4731)Ivan Levkivskyi-4/+18
Implement PEP 562: module __getattr__ and __dir__. The implementation simply updates module_getattro and module_dir.
2017-09-19bpo-31492: Fix assertion failures in case of a module with a bad __name__ ↵Oren Milman-4/+1
attribute. (#3620)
2017-09-14bpo-28411: Isolate PyInterpreterState.modules (#3575)Eric Snow-3/+9
A bunch of code currently uses PyInterpreterState.modules directly instead of PyImport_GetModuleDict(). This complicates efforts to make changes relative to sys.modules. This patch switches to using PyImport_GetModuleDict() uniformly. Also, a number of related uses of sys.modules are updated for uniformity for the same reason. Note that this code was already reviewed and merged as part of #1638. I reverted that and am now splitting it up into more focused parts.
2017-09-13bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)Eric Snow-9/+3
PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
2017-09-07bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow-0/+1
* group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-04bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)Eric Snow-3/+9
sys.modules is the one true source.
2017-03-19bpo-29793: Convert some builtin types constructors to Argument Clinic. (#615)Serhiy Storchaka-17/+24
2016-11-21Issue #28748: Private variable _Py_PackageContext is now of type "const char *"Serhiy Storchaka-1/+1
rather of "char *".
2016-11-20Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka-2/+2
UTF-8 represenatation of Unicode objects.
2016-11-20Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka-4/+4
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-16Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka-1/+1
_PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka-1/+1
_PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
2016-09-26Issue #27914: Fixed a comment in PyModule_ExcDef.Serhiy Storchaka-1/+1
Patch by Xiang Zhang.
2016-08-21Merge #27782 fix from 3.5Nick Coghlan-29/+35
2016-08-21Issue #27782: Fix m_methods handling in multiphase initNick Coghlan-29/+35
Multi-phase extension module import now correctly allows the ``m_methods`` field to be used to add module level functions to instances of non-module types returned from ``Py_create_mod``. Patch by Xiang Zhang.
2016-08-19Issue #12946: Remove dead code in PyModule_GetDictBerker Peksag-2/+1
PyModule_NewObject already sets md_dict to PyDict_New(): m->md_dict = PyDict_New();
2016-04-06Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka-1/+1
2015-12-24Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka-2/+1
macro Py_SETREF.
2015-05-24Issue #24268: Address some PEP 489 refleaksNick Coghlan-0/+1
- missing DECREF in PyModule_FromDefAndSpec2 - missing DECREF in PyType_FromSpecAndBases2 - missing DECREF in _testmultiphase module Patch by Petr Viktorin
2015-05-23PEP 489: Multi-phase extension module initializationNick Coghlan-52/+283
Known limitations of the current implementation: - documentation changes are incomplete - there's a reference leak I haven't tracked down yet The leak is most visible by running: ./python -m test -R3:3 test_importlib However, you can also see it by running: ./python -X showrefcount Importing the array or _testmultiphase modules, and then deleting them from both sys.modules and the local namespace shows significant increases in the total number of active references each cycle. By contrast, with _testcapi (which continues to use single-phase initialisation) the global refcounts stabilise after a couple of cycles.
2015-03-18Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka-1/+1
2014-04-24sprinkle some _PyId goodness around moduleobject.cBenjamin Peterson-9/+19
2014-04-24do not override errors from descriptors on modulesBenjamin Peterson-10/+9
2014-04-24Issue8297: module attribute lookup failures now include module name in error ↵Ethan Furman-2/+26
message.
2014-02-12Issue #19255: Clear error after failed PyDict_SetItem() on shutdown.Serhiy Storchaka-2/+4
This silences a Coverity complain.
2014-02-12Issue #19255: Clear error after failed PyDict_SetItem() on shutdown.Serhiy Storchaka-2/+4
This silences a Coverity complain.
2014-02-10Issue #19255: The builtins module is restored to initial value beforeSerhiy Storchaka-5/+8
cleaning other modules. The sys and builtins modules are cleaned last.
2013-11-22Implement PEP 451 (ModuleSpec).Eric Snow-48/+5
2013-07-31Issue #18214: Improve finalization of Python modules to avoid setting their ↵Antoine Pitrou-8/+21
globals to None, in most cases.
2013-05-04#17115,17116: Have modules initialize the __package__ and __loader__Brett Cannon-13/+26
attributes to None. The long-term goal is for people to be able to rely on these attributes existing and checking for None to see if they have been set. Since import itself sets these attributes when a loader does not the only instances when the attributes are None are from someone overloading __import__() and not using a loader or someone creating a module from scratch. This patch also unifies module initialization. Before you could have different attributes with default values depending on how the module object was created. Now the only way to not get the same default set of attributes is to circumvent initialization by calling ModuleType.__new__() directly.
2012-07-19Issue #15394: Fix ref leaks in PyModule_Create.Meador Inge-1/+7
Patch by Julia Lawall.
2012-07-19Issue #15394: Fix ref leaks in PyModule_Create.Meador Inge-1/+7
Patch by Julia Lawall.
2012-05-24issue 14660: Implement PEP 420, namespace packages.Eric V. Smith-2/+31
2012-04-29Issues #13959, 14647: Re-implement imp.reload() in Lib/imp.py.Brett Cannon-1/+1
Thanks to Eric Snow for the patch.
2011-10-14Rename _Py_identifier to _Py_IDENTIFIER.Martin v. Löwis-1/+1
2011-10-10Use identifier API for PyObject_GetAttrString.Martin v. Löwis-1/+2
2011-09-28Implement PEP 393.Martin v. Löwis-5/+4
2011-05-24indicate return value on __dir__ methodsBenjamin Peterson-1/+1
2011-05-24move specialized dir implementations into __dir__ methods (closes #12166)Benjamin Peterson-1/+29
2011-03-04Issue #3080: Add PyModule_NewObject() functionVictor Stinner-7/+16
2011-02-23Issue #3080: Add PyModule_GetNameObject()Victor Stinner-14/+29
repr(module) uses %R to format module name and filenames, instead of '%s' and '%U', so surrogates from undecodable bytes in a filename (PEP 383) are escaped.
2010-12-14#4236: avoid possible Fatal Error when import is called from __del__R. David Murray-2/+3
Patch by Simon Cross, crasher test code by Martin von Löwis.
2010-12-10Reverted accidental commit (from r87159)Alexander Belopolsky-17/+3
2010-12-10Updated UCD version and unicode.org links to Unicode 6.0.0Alexander Belopolsky-3/+17
2010-12-03Merge branches/pep-0384.Martin v. Löwis-1/+1
2010-10-12prefer clearing global objects to obscure module.__dict__ bugs #10068Benjamin Peterson-4/+1
2010-08-17Issue #9425: Create PyModule_GetFilenameObject() functionVictor Stinner-7/+13
... to get the filename as a unicode object, instead of a byte string. Function needed to support unencodable filenames. Deprecate PyModule_GetFilename() in favor on the new function.
2010-08-13Issue #9425: Create PyErr_WarnFormat() functionVictor Stinner-10/+7
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning message. Strip also some trailing spaces.