GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-141070: Add PyUnstable_Object_Dump() function by vstinner · Pull Request #141072 · python/cpython Conversation
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The tests seem to be failing on Windows. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ah yes, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few English nitpicks on the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Peter Bierma <[email protected]>
There was an error while loading. Please reload this page.
|
I think this is a great candidate for unstable API. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Kumar Aditya <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
|
I created a C API Working Group decision issue. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hm, @encukou, why make this an unstable API? I don't think we ever plan to remove the ability to print objects from the C API. If you're concerned about people relying on the exact output, we can just tell them "don't do that" in the docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
That we don't, but Or is there a use case where you call this from a releasable extension? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Absolutely, we do it ourselves. It's a convenient debugging tool, but it's also quite handy as a last-ditch effort to display something to the user, like with I think as long as we specify the function as "dump non-specific debugging information about an object", it should be fine to add it as a non-unstable API. If we do add it to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| * Add a new :c:func:`PyImport_CreateModuleFromInitfunc` C-API for creating | ||
| a module from a *spec* and *initfunc*. | ||
| (Contributed by Itamar Oren in :gh:`116146`.) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Entries should be sorted.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that. What's the sort key?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"Sorted alphabetically". @hugovk added comments like that in the What's New document:
.. Add C API deprecations above alphabetically, not here at the end.
We should add a similar comment for C API "New features". I think that it was @AA-Turner who started to sort items in What's New In Python 3.14.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I renamed the function to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That's debugging helper. Unstable API is great for those :)
There's a bunch of unstable API like that -- I think some people would be sad to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ZeroIntensity: I prefer the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| _PyObject_Dump(PyObject* op) | ||
| PyUnstable_Object_Dump(PyObject* op) | ||
| { | ||
| if (_PyObject_IsFreed(op)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a special case for op == NULL?
And for type == NULL?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It displays freed in both cases. There is now an unit test for that.
How do you suggest to format op==NULL and/or type==NULL?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If this is already tested, then good. I was not sure that _PyObject_IsFreed() works with NULL (it could crash).
If type==NULL (very unlikely), then type->tp_name and repr() will crash. They will also crash if type was freed or if it is just a garbage. We could skip prints in that case avoid crash, although it may be too late.
Looking at the code, it seems the ideas I had (testing against the patterns used to fill the freed memory) was already implemented in _PyMem_IsPtrFreed().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If type==NULL (very unlikely), then type->tp_name and repr() will crash
_PyObject_IsFreed() checks _PyMem_IsPtrFreed(Py_TYPE(op)). We just display freed in this case, without displaying tp_name or trying to call repr().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
What's the point of an unstable API that we can't remove? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Promote _PyObject_Dump() as a public function. * Keep _PyObject_Dump() alias to PyUnstable_Object_Dump() for backward compatibility. * Replace _PyObject_Dump() with PyUnstable_Object_Dump(). Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Kumar Aditya <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.