-
Notifications
You must be signed in to change notification settings - Fork 5
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
OSError On Clicking "Special Plots" in Demo (Windows) #7
Comments
It's not clear to me which plot this might be. However, the demos in this library are simply the Plotext examples but placed inside a Textual application. My suspicion would be that it's the event plot that is causing the problem (this is a guess based on the error seemingly being related to datetime issues). As such, could you do me a favour and follow Plotext's example for the event plot and let me know what happens? Here's what I get: |
Right, as such, it would seem to be a bug either in Plotext itself, or at least their demo code. It might be a good idea to raise an issue there; I'll have a dive in and see if I can see the issue when I get some time, and I'll keep the issue open for now too -- perhaps when you raise the issue with them link to this. |
As an aside, from within the Python library code (as in the core libraries of Python itself), I see this: # On Windows localtime_s throws an OSError for negative values,
# thus we can't perform fold detection for values of time less
# than the max time fold. See comments in _datetimemodule's
# version of this method for more details.
if t < max_fold_seconds and sys.platform.startswith("win"):
return result that mention of |
Indeed , there is some issue with time0 and Windows... in _date.py line 56... after inspect of the variables: time = range of values 540 - 86220.0 (seconds/day?) sum = -2208903600.0 ~ self.time0 calling "dt.fromtimestamp(time + self.time0)" = <- produces the error , irrespective of passing its value to any other function
SO I guess the real question is... why does passing in - -2208903600.0 produce an error in the datetime module of Python ? Perhaps there is a clue here....
I don't know anything about time folds or posix time at all, but I do see that a very big negative number is being passed into a function with a comment that it will OSError on negative numbers in Windows... So editing line 56 of _date.py , with abs() to ensure a positive number: Renders the page without error (same as the try/except, still dots instead of lines for me, but maybe this is my terminal.) |
Thanks for diving into this further. I think, given the problem seems to be somewhere between Plotext itself and Python on Windows, the easiest thing for me to do for the demo is to just omit that particular plot from the demo when running on Windows. |
See #7 and piccolomo/plotext#189 -- this seems to be an issue somewhere between Plotext itself and Python on Windows; while we could dive into this and try and solve it, for the purposes of a quick demo it makes more sense to remove the problematic plot for now.
I've installed textual-plotext
Ran demo with
python -m textual_plotext in command prompt
When I click "Special Plots" the demo crashes with:
OSError [Errno 22] Invalid Argument
As Attached
the last error is in:
...site-packages\plotext_date.py:56 in time_to_string
│ return self.datetime_to_string(dt.fromtimestamp(time + self.time0), output_form)
full screenshots of stack trace below
Running
plotext 5.2.8
Textual 0.40.0
Python 3.11.3
Windows10 Pro build 19045
error appears in both Command Prompt and Windows PowerShell
The text was updated successfully, but these errors were encountered: