Comments (7)
Thanks. I have previously had file related problems that only occurred when unit tests were run on Windows. The error is strange though - my first thought would be that the path contains backslashes or a space that's being misinterpreted but it looks OK.
I'll try it later when I'm back in Windows-land.
from bitstring.
Hi. Thanks for the bug report. Could you provide some additional platform details on where you're running this as I'm unable to reproduce the issue? Also the contents of the traceback would be handy.
I've run your test on my Windows 11 machine (under WSL) and no exception is thrown and all the writes work for me.
Thanks.
from bitstring.
Hey Scott,
That's interesting. I wonder what I may have different about my set up?
I'm running it on Windows 11 directly (not under WSL) and this happens whether I run it interactively, in IDLE, from a terminal, or elevated terminal.
The stack trace isn't particularly helpful imo, but here ya go:
PS C:\Users\MikeD\Desktop> py .\bitstream_test.py
Traceback (most recent call last):
File "C:\Users\MikeD\Desktop\bitstream_test.py", line 16, in <module>
with open(path, mode='w') as f:
^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: 'some_file.txt'
And do keep in mind that previous and subsequent reads/writes within that same progam all work . When I open the file afterwards, it has the contents Final write works after deleting the bitstream.
from bitstring.
Hey @scott-griffiths , just curious -- any updates?
from bitstring.
Hi. Yes I've reproduced it locally but I don't have a fix yet. It's Windows specific and I don't have a dev environment set up to easily debug it.
I'll mark it as a bug to be fixed in 4.2, so I'll get around to it eventually! The work-around is just to read the file into memory, assuming that it's not too big, by using a BitStream
instead of ConstBitStream
.
from bitstring.
I'm almost certain the issue is due to the different way that Windows handles memory mapped files.
For efficiency reasons the file is accessed via a read-only mmap, which works fine on all platforms. However Windows' file system locks the file that's been mapped against writing, while Unix-like systems don't.
There's not a huge amount I can do about the underlying problem, as it's a 'feature' of the OS. I could:
- Opt not to use the mmap when on Windows. This isn't really a good option as it would instead break it in terms of expected performance on that OS.
- Document the problem. Hardly a great 'solution' (who reads the documentation?) but I'm struggling to find a better option.
I can't even make the exception more useful as it's not from my code. The OSError: Invalid argument
exception is just misleading as it's not the argument that's the problem.
from bitstring.
This is now documented and so officially a 'feature' rather than a bug. Not very helpful I know but it's due to the OS, and has a poor error message from the core Python.
from bitstring.
Related Issues (20)
- ImportError: cannot import name 'BitString' from 'bitstring' HOT 3
- 4.2.0 crashes upon import with 32 bit python versions HOT 2
- 4.2.0: Bitarray(bytes=...) constructor no longer accepts list of bytes (or integers) HOT 2
- Unpack decoding error HOT 2
- 4.2.0: Typing of BitStream-slice HOT 3
- 4.2.0 crashes upon import when PYTHONOPTIMIZE is set to 2 or larger HOT 2
- 4.2.0: BitArray.join() no longer ignores None types HOT 2
- Change string representation of dtypes to short version when available. HOT 1
- 4.2.x: Reading past the end of stream no longer raises ReadError HOT 2
- Significant slowdown in find / findall for some cases since version 4.1. HOT 7
- DeprecationWarning: invalid escape sequence in tests HOT 1
- Test failures due to lack of gfloat formats import HOT 2
- `BitStream.__add__` throws `AttributeError: 'Bits' object has no attribute '_pos'` HOT 3
- Add levels to dtype definitions in the dtype register HOT 1
- Add offset to Dtype
- Some exotic float codes representing negative zero converted to positive zero.
- Auto scaling rounding wrong way on occasion.
- More configurable default options for pp
- Bug initializing an Array from bytes? HOT 2
- Gfloat version requirement HOT 3
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 bitstring.