6 Given a function $y=f(x)$ defined on the set of all real numbers that satisfies $f(x+2 \pi)=f(x)$, and the functions
$$
\begin{array}{l}
g(x)=\frac{f(x)+f(-x)}{2}, \\
h(x)=\frac{f(x)-f(-x)}{2} .
\end{array}
$$

If the functions $p(x)$ and $q(x)$ are defined as
$$
\begin{array}{c}
p(x)=\left\{\begin{array}{cc}
\frac{g(x)-g(x+\pi)}{2 \cos x} & \left(x \neq k \pi+\frac{\pi}{2}\right), \\
0 & \left(x=k \pi+\frac{\pi}{2}\right),
\end{array}\right. \\
q(x)=\left\{\begin{array}{cc}
\frac{h(x)+h(x+\pi)}{2 \sin 2 x} & \left(x \neq \frac{k \pi}{2}\right), \\
0 & \left(x=\frac{k \pi}{2}\right),
\end{array}\right.
\end{array}
$$

where $k \in \mathbf{Z}$, then which of the following statements about $p(x)$ and $q(x)$ is correct? ( ).
(A) Both are odd functions with a period of $\pi$
(B) Both are even functions with a period of $\pi$
(C) Neither has odd or even properties but both have periodicity
(D) Neither has periodicity but both have odd or even properties
6 Clearly, $g(-x)=g(x), h(-x)=-h(x)$. Since $f(x+2 \pi)=f(x)$, we have
$$
\begin{aligned}
g(x+2 \pi) & =\frac{f(x+2 \pi)+f(-x-2 \pi)}{2} \\
& =\frac{f(x)+f(-x)}{2} \\
& =g(x), \\
h(x+2 \pi) & =\frac{f(x+2 \pi)-f(-x-2 \pi)}{2} \\
& =\frac{f(x)-f(-x)}{2} \\
& =h(x) .
\end{aligned}
$$

When $x \neq k \pi+\frac{\pi}{2}$,
$$
\begin{aligned}
p(-x) & =\frac{g(-x)-g(-x+\pi)}{2 \cos (-x)} \\
& =\frac{g(x)-g(x-\pi)}{2 \cos x} \\
& =\frac{g(x)-g(x+\pi)}{2 \cos x} \\
& =p(x), \\
p(x+\pi) & =\frac{g(x+\pi)-g(x+2 \pi)}{2 \cos (x+\pi)} \\
& =\frac{g(x+\pi)-g(x)}{-2 \cos x} \\
& =\frac{g(x)-g(x+\pi)}{2 \cos x} \\
& =p(x) .
\end{aligned}
$$

When $x=k \pi+\frac{\pi}{2}$, $p(-x)=p(x)=p(x+\pi)=0$.
Therefore, for $x \in \mathbf{R}$, $p(-x)=p(x)$ and $p(x+\pi)=p(x)$. Similarly, for $x \in \mathbf{R}$, $q(-x)=q(x)$ and $q(x+\pi)=q(x)$. Hence, the correct choice is B.