When using a combination of the packages framed, listings, and xcolor, that causes a strange bug, that I cannot manage to fix.
The problem is that, when a box (made with the framed package, and fcolorbox) contains a listing just before a page breaks, the rest of the block appears blank on the next page. Moreover, the block on the firxt page is not framed anymore.

This does not happens if I use fbox instead of fcolorbox.
The minimal example is the following:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{framed}
\usepackage{listings}
\usepackage{xcolor}
\lstnewenvironment{python}{\lstset{language=python}}{}
\renewcommand*{\FrameCommand}{%
\setlength{\fboxrule}{\FrameRule}\setlength{\fboxsep}{\FrameSep}%
\fcolorbox{black}{white}}
\begin{document}
\blindtext
\blindtext
\blindtext
\begin{framed}{Block}
\blindtext
Foo
\blindtext
\begin{python}
def f(x):
foo
\end{python}
THIS NEVER APPEARS
\blindtext
\end{framed}
End of block
\end{document}
What I am looking for is any kind of workaround, not necessarily a full solution.