Comments (7)
Thank you @apmorton for the report, and @picnixz for the fix!
from cpython.
I'd say it's not a bug because pickle._Pickler
is private and should not be used directly. Why do you need the private one?
from cpython.
I'd say it's not a bug because
pickle._Pickler
is private and should not be used directly. Why do you need the private one?
pickle.Pickler
may be provided by pickle._Pickler
if the native extension _pickle
is not presented:
Lines 1770 to 1784 in 42b25dd
from cpython.
Oh! yes, my bad! I'll hide my comment to reduce the noise!
from cpython.
The ZeroCopyBytearray buffer appears to need the following implementation (it's actually in Lib/test/pickletester
) but I confirmed that the issue remains but only if the buffer is empty (otherwise it's fine). The implementation is roughly
class ZeroCopyBytearray(bytearray):
def __reduce_ex__(self, protocol):
if protocol >= 5:
return type(self)._reconstruct, (pickle.PickleBuffer(self),), None
else:
return type(self)._reconstruct, (bytes(self),)
@classmethod
def _reconstruct(cls, obj):
with memoryview(obj) as m:
obj = m.obj
if type(obj) is cls:
# Zero-copy
return obj
else:
return cls(obj)
So, the __reduce_ex__
method makes more things than what you provided in your example, but it does not fix the issue at all.
EDIT: I'm investigating the issue in picnixz@a8c1464
from cpython.
Correct, I minimized the example to only the relevant parts for reproduction.
The issue only happens if you use protocol 5 and end up with two objects having different IDs produce a PickleBuffer with the same underlying buffer ID.
from cpython.
Yes, the issue is that this specific test case is not covered (I've added one and I'll try to fix it), which is why we did not see the issue (by specific case, I mean the two different instances that are empty, not that it still works if I use the same non-empty buffer values).
from cpython.
Related Issues (20)
- zipimport cannot do a namespace import when a directory has no python files, but it contains nested directories with python files inside of a zip file. HOT 7
- segfault in pymalloc_alloc HOT 8
- Skip __index__ handling in PyLong_AsNativeBytes
- tracemalloc: add new `dump_snapshot()` and `load_snapshot()` functions implemented in C HOT 1
- [C API] Add PySet_NextEntry() function HOT 10
- Self-documenting f-string in conversion specifier throws ValueError HOT 7
- Setting the line number is ignored in `INSTRUMENTED_YIELD_VALUE`
- Missing PyDECREF calls for ADDITEMS opcode of _pickle.c HOT 1
- riscv64: Python/perf_jit_trampoline.c:491:6: error: #error "Unsupported target architecture" HOT 2
- Support copy.replace() on AST nodes HOT 6
- Mac M1: ctypes crashes Blender application when I load and run my dylib. HOT 6
- 'And' functionality between lists HOT 4
- Specialization for accurate complex summation in sum()? HOT 9
- argparse: usage text of arguments in mutually exclusive groups no longer wraps in Python 3.13
- Incorrect use of _PyLong_CompactValue() HOT 1
- subprocess.run timeout does not function if shell=True and capture_output=True HOT 2
- `readline.set_history_length` corrupts history files when used in a libedit build HOT 11
- Consider support "all" as an valid action for ``warnings.filterswarnings/simplefilter``. HOT 1
- Use `do-while(0)` to protect `ADJUST_INDICES` macro
- wrong number sorting 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 cpython.