[issue18710] Add PyState_GetModuleAttr

2020-12-15 Thread Petr Viktorin
Petr Viktorin added the comment: Let me summarize the original issue with the following quote from the python-dev thead: > doing some sys.modules acrobatics and re-importing suddenly changes the internal state of a previously imported [_csv] module. The issue is now solved; both reproducers

[issue18710] Add PyState_GetModuleAttr

2019-09-13 Thread Petr Viktorin
Petr Viktorin added the comment: PEP 573 proposes an alternative to PyState_FindModule. -- nosy: +petr.viktorin ___ Python tracker ___

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Eli Bendersky
Eli Bendersky added the comment: > Previously, the only way to add a dialect was through register_dialect that does > > type checking to make sure it gets a legit dialect object. Now, the > _dialects dict is > > directly accessible to Python code and it can add arbitrary objects to > it (both a

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Nick Coghlan
Nick Coghlan added the comment: Breaking the 1:1 interpreter <-> extension module mapping involves adding custom types to sys.modules rather than module objects. Making that work sensibly will involve larger changes to the extension initialisation APIs. import-sig already has plans for this :) -

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Previously, the only way to add a dialect was through register_dialect that > does > type checking to make sure it gets a legit dialect object. Now, the _dialects > dict is > directly accessible to Python code and it can add arbitrary objects to it > (both

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Eli Bendersky
Eli Bendersky added the comment: The patched code looks better than the original one in several respects, but I think it raises some questions. I agree with Victor that the type-checking API is unnatural, but I also think there may be a deeper issue hiding behind. You felt compelled to add the

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: > When the char* type is used, the function has usually the suffix > String. I prefer the PyIdentifier API because it avoids to create a > temporary Python Unicode object. This is a convenience API, not a performance "optimization". > It's the first type that I

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread STINNER Victor
STINNER Victor added the comment: +PyObject * +PyState_GetModuleAttr(struct PyModuleDef *def, + const char *name, + PyObject *restrict_type) When the char* type is used, the function has usually the suffix String. I prefer the PyIdentifier API because i

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Bundling the two was aimed at showcasing the effect the new function can have. The function itself is trivial, there's not much point in reviewing it alone. -- ___ Python tracker

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Christian Heimes
Christian Heimes added the comment: The patch contains the new function and a patch for the CSV module. How about you split it up across two patches: one for the new feature and one for the CSV module? It makes review easier. -- nosy: +christian.heimes

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I don't understand your change. Why do we need to change the _csv > module and why storing module global variables in the module dict is > better than storing them in a simple C structure? I won't repeat what was already said in the python-dev thread: http://m

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread STINNER Victor
STINNER Victor added the comment: I don't understand your change. Why do we need to change the _csv module and why storing module global variables in the module dict is better than storing them in a simple C structure? -- nosy: +haypo ___ Python tra

[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou
New submission from Antoine Pitrou: Attached patch adds PyState_GetModuleAttr() and converts the _csv module to use it (as an example). As you can see, the _csv module grows a little but it now has proper error handling (previously, it didn't check for PyState_FindModule() returning NULL). (A