-
Notifications
You must be signed in to change notification settings - Fork 774
File Opened in Python not passed as FileStream #797
Copy link
Copy link
Closed
Description
Environment
- Pythonnet version: 2.4.0.dev0
- Python version: 3.7.1:260ec2c36a
- Operating System: MSC v.1915 64 bit (AMD64)
Details
- Pass a python opened file to a referenced constructor that takes a Stream as a parameter.
The library used was DiscUtils 0.11.0.0
import os, sys, clr
clr.AddReference("DiscUtils")
import DiscUtils.Iso9660 as Iso9660
def readUdf(path):
with open(path, 'rb') as file: # modes 'r', 'rb' and their + varients all fail
reader = Iso9660.CDReader(file, False)- If there was a crash, please include the traceback here.
Traceback (most recent call last):
File "-snip path-\main.py", line 100, in <module>
if args.read is not None: readUdf(args.read)
File "-snip path-\main.py", line 19, in readUdf
reader = Iso9660.CDReader(file, False)
TypeError: no constructor matches given argumentsI initially got around it by writing a small dll that would have a constructor that would take a string as it's only arguments and then return a new CDReader object. After learning a bit of C# while doing so I later discovered after playing around that the following code would work without issue.
clr.AddReference("DiscUtils")
import DiscUtils.Iso9660 as Iso9660
from System.IO import FileStream, FileMode, FileAccess
def readUdf(path):
file = FileStream(path, FileMode.Open, FileAccess.Read)
reader = Iso9660.CDReader(file, False)I'm not entirely sure if this is actually an issue or not but I would have thought that passing it as a python opened file object would pass it as a FileStream.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels