Skip to content

Encoding issue. PyScope.Exec() #818

Description

@NickSavin

Environment

  • Pythonnet version: 2.4.0.dev
  • Python version: 3.7
  • Operating System: Win10

Details

  • I have a script, represented by a string in .net side:
    string script = "a = \"Привет\"";

I try to run this script, using PyScope.Exec()

public void ExecuteScript(string script, IDictionary<string, object> locals)
        {
            _scriptLocals = new PyDict();

            using (Py.GIL())
            {
                if (locals != null)
                    foreach (var local in locals)
                        _scriptLocals[local.Key] = local.Value.ToPython();

                using (var pythonScope = Py.CreateScope())
                {
                    pythonScope.Exec(script, _scriptLocals);
                }
            }
        }

When I run method pythonScope.Exec(script, _scriptLocals), I get an exception:

SyntaxError : ("(unicode error) 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte", ('', 1, 4, None))

StackTrace is empty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions