Canada has introduced legislation that prevents astronauts from the country committing crimes when they are in space.