Where a prisoner who is serving a term of imprisonment for an offence against a law of the Commonwealth or of a Territory is released from a prison pursuant to a request by a foreign country under section 26 or 27, the prisoner shall, while in custody in connection with the request (including custody outside Australia), be deemed to be continuing to serve that term of imprisonment.