Cut the top off the pumpkin and set aside. Scoop out the seeds and fibres from the middle and discard.
Using a sharp knife and a spoon, carefully hollow out the pumpkin, removing the flesh and setting aside. (It is imperative that you do not cut right up to the inside of the skin or pierce it. Leave 2cm/1in of flesh all around the inside.)
Roughly chop the scooped-out pumpkin flesh.
Melt the butter in a large pan with a lid over a low heat and add the onions. Cook the onions gently for 10-15 minutes, until they are softened and golden-brown.
Add the pumpkin flesh, the cinnamon and nutmeg, and season, to taste, with salt and freshly ground black pepper. Increase the heat to medium and cover with the lid. Cook for 40-45 minutes, stirring occasionally to prevent the base from burning, until the pumpkin is cooked through.
Add the stock and bring to the boil. Remove from the heat and allow to cool slightly. Transfer the soup to a food processor in batches and blend until smooth.
Return the soup to the pan and bring to a low simmer and cook for a further half an hour.
Forty-five minutes before eating, preheat the oven to 170C/335F/Gas 3.
Pour the soup into the hollow pumpkin shell, add the sherry and stir to combine.
Place the reserved pumpkin 'lid' onto the pumpkin and place onto a large baking tray. Cook in the oven for about 45 minutes, to bring the soup up to temperature.
To serve, carefully remove from the oven and serve the soup in the pumpkin at the table. Ladle into bowls and serve.