-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-32075: Expose ZipImporter Type Object in the include header files. #4470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2db24da
bpo-32075: Expose ZipImporter Type Object in the include header files.
AraHaan 297288a
bpo-32075: Fix Windows CI.
AraHaan 194c7b4
bpo-32075: Remove zipimport.h from Python.h.
AraHaan 2c7656c
bpo-32075: Fixed zipimport.c.
AraHaan 1901323
bpo-32075: fix zipimport.h and add to Python.h.
AraHaan 6cc282a
bpo-32075: Make ZipImporter_Type non-static.
AraHaan 3df3f09
Added an zipimporter doc and some changes.
AraHaan 6a31123
bpo-32075: Reference zipimporter.rst in docs.
AraHaan 87f56fc
bpo-32075: Update zipimport clinic manually.
AraHaan d1db629
bpo-32075: Actually regenerate clinic.
AraHaan 8826977
bpo-32075: Add news entry.
AraHaan e742b93
bpo-32075: changed docs.
AraHaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,4 +114,5 @@ Other Objects | |
gen.rst | ||
coro.rst | ||
datetime.rst | ||
zipimporter.rst | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.. highlightlang:: c | ||
|
||
.. zipimporter: | ||
|
||
ZipImporter Objects | ||
------------------- | ||
|
||
Python for the longest of time had an zipimporter that could not be | ||
subclassed using the C Python API but could in the Python Layer. | ||
On Python 3.6.4 users can subclass it in their C code as it is an | ||
exported Type in the Python Core. On Python 3.7 ZipImporter *might* | ||
be reimplemented in Pure Python instead of C. | ||
|
||
.. c:var:: PyTypeObject PyZipImporter_Type | ||
|
||
This instance of :c:type:`PyTypeObject` represents the Python zipimporter type; | ||
it is the same object as :class:`zipimport.zipimporter` in the Python layer. | ||
|
||
.. note:: | ||
|
||
This type used to be named ZipImporter_Type and not exported. Since then it | ||
caused problems with subtyping it in another type forcing them to copy most | ||
of the implementation from zipimport.c to their extension module which can | ||
not be a reasonable thing. So this change was needed. | ||
|
||
|
||
Type check macros | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
.. c:function:: int PyZipImporter_Check(PyObject *o) | ||
|
||
Return true if the object *o* is a zipimporter type or an instance of a | ||
subtype of the zipimporter type. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef Py_ZIPIMPORT_H | ||
#define Py_ZIPIMPORT_H | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
PyAPI_DATA(PyTypeObject) PyZipImporter_Type; | ||
|
||
#define ZipImporter_Check(op) PyObject_TypeCheck(op, &PyZipImporter_Type) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* !Py_ZIPIMPORT_H */ |
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/C API/2017-11-20-03-05-40.bpo-32075.U-tgAS.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Exposes ZipImporter Type Object in the include header files. This now fixes | ||
the issue where nobody can subclass the ZipImporter type in the C API like | ||
they can on Pure Python. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the rest of the file shouldn't be part of the stable ABI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then how would someone be able to subclass or subtype the zip importer in their C code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relying only on the stable ABI is an opt-in thing when you build an extension, so leaving this out of it won't prevent it from being available overall, just in a certain instance.