(a) Liability of cities.--
(1) When an inmate is committed to any county correctional institution in this Commonwealth either for the nonpayment of a fine or penalty imposed for the violation of any city ordinance or while awaiting a hearing upon any charge for the violation of any city ordinance, the costs of proceedings and the expenses of maintaining the inmate during his confinement by virtue of the commitment shall be borne and paid by the city whose ordinance was alleged to have been violated or to which any such fines or penalties are payable.
(2) The county in which the city is located shall not be liable to the sheriff for any such maintenance or to any officer, magistrate or person for any costs of such proceedings.
(b) Nonapplicability.--This section does not apply to a city of the third class.