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
Fix depwarn on 0.5 #267
Fix depwarn on 0.5 #267
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
julia 0.4 | ||
Compat 0.7.14 | ||
Compat 0.7.15 | ||
Conda 0.1.6 | ||
MacroTools 0.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,7 +261,7 @@ type PyTypeObject | |
# Julia-specific fields, after the end of the Python structure: | ||
|
||
# save the tp_name Julia string so that it is not garbage-collected | ||
tp_name_save::ASCIIString | ||
tp_name_save # This is a gc slot that is never read from | ||
|
||
function PyTypeObject(name::AbstractString, basicsize::Integer, init::Function) | ||
# figure out Py_TPFLAGS_DEFAULT, depending on Python version | ||
|
@@ -280,7 +280,8 @@ type PyTypeObject | |
Py_TPFLAGS_HAVE_CLASS | | ||
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | | ||
Py_TPFLAGS_HAVE_INDEX) | ||
name_save = bytestring(name) | ||
# This and the `unsafe_convert` below emulate a `ccall` | ||
name_save = Base.cconvert(Ptr{UInt8}, name) | ||
t = new(0,C_NULL,0, | ||
unsafe_convert(Ptr{UInt8}, name_save), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not if you want to support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
convert(Int, basicsize), 0, | ||
|
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.
Should be
String(name)
. Thename
argument is anAbstractString
, and could potentially be some other string type likeUTF16String
, and needs to be converted to UTF-8, which is what thebytestring
call did.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 is the
ccall
interface. The code here is exactly the same as if you writeccall(..., (..., Ptr{UInt8}, ...,), ..., name, ...)
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.
I'm not sure what you're talking about. CPython never looks at the
tp_name_save
field; this is is something I tacked on to the end of the struct so that the Julia-side object would cache a reference to the string to make sure it is not garbage collected for as long as I keep the Julia type object around (forever).