Segmentation fault when using a custom file system handler
Toni Ruža <[email protected]> Mon, 9 Jul 2018 02:22:44 -0700 (PDT)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, I can't get a custom file system handler to work; attached is a minimal example that reproduces the segmentation fault. Python 3.6 wxPython 4.0.1 Tried it on Mac and Linux. Best regards, Toni -- You received this message because you are subscribed to the Google Groups "wxPython-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
custom_file_system_handler.py
(text/x-python, 596 B)
from io import BytesIO
import wx
class MyFileSystemHandler(wx.FileSystemHandler):
def CanOpen(self, location):
return True
def OpenFile(self, fs, location):
print('OpenFile:', location)
fsfile = wx.FSFile(BytesIO(b'hello'), location,
'text/plain', '', wx.DateTime.Now())
stream = fsfile.GetStream()
assert stream.IsOk()
return fsfile
app = wx.App(False)
wx.FileSystem.AddHandler(MyFileSystemHandler())
hello_file = wx.FileSystem().OpenFile('myprot:hello', wx.FS_READ)
print(hello_file.GetStream().read())