Comments (8)
I guess the question is "what do you want to do with bufdata
?". In julia v1.11+ IOBuffer(::Vector{UInt8})
doesn't wrap directly the vector passed as input, and looking at the docstring it doesn't look like it promised to do that. Much simpler demonstration:
julia v1.10:
julia> bufdata = UInt8[]
UInt8[]
julia> iobuf = IOBuffer(bufdata, read = true, write = true)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
julia> println(iobuf, "hello")
julia> iobuf.data
6-element Vector{UInt8}:
0x68
0x65
0x6c
0x6c
0x6f
0x0a
julia> bufdata
6-element Vector{UInt8}:
0x68
0x65
0x6c
0x6c
0x6f
0x0a
julia> bufdata === iobuf.data
true
julia master:
julia> bufdata = UInt8[]
UInt8[]
julia> iobuf = IOBuffer(bufdata, read = true, write = true)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
julia> println(iobuf, "hello")
julia> iobuf.data
8-element Memory{UInt8}:
0x68
0x65
0x6c
0x6c
0x6f
0x0a
0x00
0x00
julia> bufdata
UInt8[]
julia> bufdata === iobuf.data
false
from julia.
the issue here is that figuring out what to change it to is pretty hard. This code seems to be built extensively on the assumption that if you give a Vector
to an IOBuffer
, at some unspecified later point in time, after you have done a lot of things with that IOBuffer
, the Vector
you passed in to the IOBuffer
at the beginning will have all the bytes that were read into the IOBuffer
. I think the correct change, might be to remove the bufferdata
field entirely, and replace the uses of String(copy(buffer.bufferdata))
with
seekstart(buffer.buffer)
read(buffer.buffer)
That said, given the API that this package exposes, I think this would likely be a breaking change for the package.
from julia.
there have been some changes to iobuffer recently. Is Luxor accessing the internals of it?
from julia.
I don't think it's doing much of that.
Starting at:
bufdata = UInt8[]
iobuf = IOBuffer(bufdata, read = true, write = true)
there's
Cairo.CairoSVGSurface(iobuf, w, h)
which is the stream
for this (Cairo.jl):
function CairoSVGSurface(stream::T, w::Real, h::Real) where {T<:IO}
callback = get_stream_callback(T)
surf = CairoSurface(C_NULL, w, h, stream)
GC.@preserve surf begin
surf.ptr = ccall((:cairo_svg_surface_create_for_stream,libcairo), Ptr{Nothing},
(Ptr{Nothing}, Ptr{Nothing}, Float64, Float64), callback,
get_stream_ptr(surf), w, h)
end
return surf
end
from julia.
Thanks, Mosรจ! I think I vaguely understand.
Do you think the behaviour of this on master is likely to change, or will I have to change my code somehow?
from julia.
We aren't currently planning on reverting the change, but we perhaps should ask triage on this one. In theory the change only affected internals, but it has broken a lot of people's code that was (intentionally or not) depending on internals.
from julia.
I'm happy to change my code - if you tell me what to change it to! ๐
from julia.
Thanks, Oscar. I think I see what's going on.
I'm not able to rebuild this area of the code at the moment, so I'll close this issue for now.
from julia.
Related Issues (20)
- should matrix-vector mul! also protect against aliasing? HOT 2
- code reports an error to line 0 HOT 6
- Average of Dates HOT 13
- safety consideration for operations with incompletely initialized types HOT 2
- Dimension check too restrictive in copytrito! and lacpy!
- LLVMPtr's address space annotation is lost with opaque pointers
- Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ffad71a9977 -- gc_setmark_pool_ HOT 9
- confusing error thrown by `display` HOT 1
- Make `ScopedValues.get` a method of `Base.get` HOT 6
- Julia without libstdc++ HOT 8
- `--threads` option seems to now result in segfault in `jl_init_thread_heap` (`julia/src/gc.c:3992`) HOT 1
- `strings/annotated` test relies on that StyledStrings have been loaded
- Not all `StridedArray`s follow the strided array API
- GC could do with more consolidated intro user documentation
- Stackoverflow without stacktrace when `convert`ing large tuple HOT 4
- `atexit()` finalizers should not run after encountering `SIGSEGV`
- `@code_llvm` with `debuginfo=:none` does not remove all debug info on Julia 1.11 HOT 4
- Conflation of UInt8 and Int8 in search functions
- `map(f, ::String)` needs `f` to return an `AbstractChar`
- Add a concept of memory-backed contiguous collection in Base HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from julia.