# Custom filter in state file break Python shell

**URL:** https://discourse.paraview.org/t/custom-filter-in-state-file-break-python-shell/3379
**Category:** ParaView Support
**Tags:** python
**Created:** [January 22, 2020, 12:03pm UTC](https://discourse.paraview.org/t/custom-filter-in-state-file-break-python-shell/3379 "2020-01-22T12:03:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bilke](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bilke/32/1003_2.png) [@bilke](https://discourse.paraview.org/u/bilke)
#### Post date: [January 22, 2020, 12:03pm UTC](https://discourse.paraview.org/t/custom-filter-in-state-file-break-python-shell/3379/1 "2020-01-22T12:03:07Z")

</div>

We observed the following behavior on Windows with ParaView 5.6.x:

If a state file contains some custom filters (in `<CustomProxyDefinitions>`) they get imported into ParaView persistently (i.e. they end up in the ParaView `.ini`-file and you can also see them via the **Tools | Manage Custom Filters** menu option).

First question: Is this intended behavior?

But now to the real problem: these custom filter break the Python shell:

```auto
> from paraview.simple import *
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:/paraview/ParaView-5.6.0-Windows-msvc2015-64bit/bin\Lib/site-packages\paraview\servermanager.py", line 2242, in find_module
    if vtkPVPythonModule.HasModule(fullname):
AttributeError: 'NoneType' object has no attribute 'HasModule'

```

If I remove the custom filter via the menu manager or directly in the `.ini`-file and restart ParaView the Python shell is fine again.

But I also have to remove the `<CustomProxyDefinitions>`-element from ParaView state file to prevent ParaView from re-adding these custom filters. Have a look at the “infected” state file:

> <https://gist.github.com/bilke/c86410cc2b733ab672871a36f4a1260f#file-infected-part-xml>
>
> There are more than three files. show original

Any idea how and why this happens?  
Thanks a lot!  
Lars

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [January 22, 2020, 3:20pm UTC](https://discourse.paraview.org/t/custom-filter-in-state-file-break-python-shell/3379/2 "2020-01-22T15:20:05Z")

</div>

There was a possibly related issue solved recently: [https://gitlab.kitware.com/paraview/paraview/issues/19340](https://gitlab.kitware.com/paraview/paraview/issues/19340)

Could you try a nightly build from [www.paraview.org/download](http://www.paraview.org/download) and see if the problem is resolve?

---

<div class="post-metadata">

### Author: ![bilke](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bilke/32/1003_2.png) [@bilke](https://discourse.paraview.org/u/bilke)
#### Post date: [January 22, 2020, 9:43pm UTC](https://discourse.paraview.org/t/custom-filter-in-state-file-break-python-shell/3379/3 "2020-01-22T21:43:36Z")

</div>

Thanks for the hint on the merge request! It sounds like this should relate to my problem but I tried the nightly build and my problem is still there:

- Used ParaView-5.8.0-RC1-87-g944a1bb4f3-Windows-Python3.7-msvc2015-64bit
- Loaded my [infected state file](https://gist.github.com/bilke/c86410cc2b733ab672871a36f4a1260f/raw/c36e7d037ca0674cdb705ff48cf43b9cbdce1e51/infected.pvsm)
- The custom filters are added to the local config
- The Python shell gets broken

**But** by looking at the [commit message of the fix](https://gitlab.kitware.com/paraview/paraview/merge_requests/3679/diffs?commit_id=8339b71375684f3cc959eb6a948db6c17e843337) I assume that only the leaking of unused custom filter definitions into state files was fixed, right?

I can attest that an infected state file can be cleaned up by simply re-saving it. The only thing to do manually afterwards is to remove the custom filter definitions via the menu option. Afterwards everything works as expected. So yes, I would say my problem is resolved.
