Another COM question
Volucris
volucris at hotmail.com
Sun Apr 8 02:15:21 EDT 2001
I get the following error when I call my Python COM object though VB:
Unexpected Python Error: exceptions.UnicodeError: ASCII encoding error:
ordinal not in range(128)
This only happens with decrypt(); encrypt() seems fine. Here's my code:
--py--
class Engine:
#COM server stuff
_public_methods_ = ['encrypt', 'decrypt']
_reg_progid_ = "Demo.Engine"
_reg_clsid_ = "{7A99346E-2895-43FA-8E3C-2AD441521312}"
def encrypt(self, data, password):
password = str(password)
if len(password) < 1: raise ValueError, "Password is empty string."
import rotor
data = str(data)
e = rotor.newrotor(password)
data = e.encrypt(data)
return data
def decrypt(self, data, password):
password = str(password)
if len(password) < 1: raise ValueError, "Password is empty string."
import rotor
data = str(data)
e = rotor.newrotor(password)
data = e.decrypt(data)
return data
--VB--
Private Sub Command1_Click() 'Encrypt button
Dim ce As Object, p As String
p = InputBox("Password:")
Set ce = CreateObject("Demo.Engine")
Text1.Text = ce.encrypt(Text1.Text, p)
End Sub
Private Sub Command2_Click() 'Decrypt button
Dim ce As Object, p As String
p = InputBox("Password:")
Set ce = CreateObject("Demo.Engine")
Text1.Text = ce.encrypt(Text1.Text, p)
End Sub
Does this have something to do with COM dealing in Unicode? Or what?
greg
More information about the Python-list
mailing list