nedsociety / pysandboxie

A python binding to Sandboxie
MIT License
12 stars 2 forks source link

unicode error python 3.9.0 #11

Closed nubonics closed 2 years ago

nubonics commented 2 years ago

I am attempting to use the example provided, however, with python 3.9.0, I seem to be stopped by a unicode error.

Traceback:

Traceback (most recent call last):
  File "C:\Users\nubonix\PycharmProjects\cliOverseer\main.py", line 8, in <module>
    sbie.create_sandbox('testpy', settings=settings)
  File "C:\Users\nubonix\PycharmProjects\cliOverseer\venv\lib\site-packages\sandboxie\sandboxie.py", line 234, in create_sandbox
    cfg = self._readini()
  File "C:\Users\nubonix\PycharmProjects\cliOverseer\venv\lib\site-packages\sandboxie\sandboxie.py", line 144, in _readini
    for line in f:
  File "C:\Users\nubonix\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x0a in position 0: truncated data

Code:

import sandboxie

# Initialize Sandboxie object
sbie = sandboxie.Sandboxie()

# Create a sandbox "testpy" with default settings
settings = sbie.make_sandbox_setting('default')
sbie.create_sandbox('testpy', settings=settings)

# Executes notepad inside it
proc = sbie.execute(['notepad.exe'], 'testpy')
# and retrieve its exit code
print(proc.wait())

# Run, terminate processes, delete the contents, and remove the sandbox entirely
sbie.execute(['notepad.exe'], 'testpy')
sbie.terminate_sandbox_processes('testpy')
nedsociety commented 2 years ago

I was not able to reproduce the issue.

nubonics commented 2 years ago

version: Sandboxie Plus 1.2.8 Sandboxie.ini: has been modified by another 3rd party software Sandboxie.ini: gave another error with a fresh install of sandboxie Sandboxie.ini encoding: dont know, and i dont know how to tell Operating system: windows 11

nedsociety commented 2 years ago

For the other problem regarding a fresh install you might want to update pysandboxie to the latest commit (#5). If that's not your problem then it might be worth a new issue.

For the modified Sandboxie.ini it should be saved in UTF-16-LE as that's how Sandboxie creates it.