diff --git a/guessit.go b/guessit.go index 62b34d0..07bd317 100644 --- a/guessit.go +++ b/guessit.go @@ -50,6 +50,8 @@ func init() { } func New() (*Guessit, error) { + python3.PyErr_Clear() + module := python3.PyImport_ImportModule("guessit") //ret val: new ref if !(module != nil && python3.PyErr_Occurred() == nil) { return nil, fmt.Errorf("failed to import module 'guessit'") @@ -72,6 +74,8 @@ func New() (*Guessit, error) { } func (g Guessit) Guessit(s string, options ...string) (out Match, err error) { + python3.PyErr_Clear() + if len(s) == 0 { err = fmt.Errorf("input string is empty") return @@ -85,7 +89,6 @@ func (g Guessit) Guessit(s string, options ...string) (out Match, err error) { testdataPy := g.fn.CallFunctionObjArgs(item, opts) //retval: New reference if !(testdataPy != nil && python3.PyErr_Occurred() == nil) { - python3.PyErr_Print() return }