How did the government get itself into such a mess over prisoners voting? After human rights judges stretched out the hand of friendship to the UK last week, David Cameron promptly bit it off, willingly giving parliament an undertaking that he would not succumb to what one MP had described as the European court’s ‘diktat’.

Cameron’s problem seems to be that he pays more attention to some of the newspapers than he does to those who could give him sound legal advice. Successive prime ministers have never felt the need for a lawyer in Downing Street, a trusted confidant who could provide informal legal and policy guidance. If a constitutional lawyer had been on hand in 2003 to tell Tony Blair that the lord chancellor was more than just another minister whose responsibilities could be reshuffled at will, Blair would never have announced that the post was being abolished overnight.

Similarly, a lawyer would have advised Cameron that the Strasbourg decision on prisoner voting was a limited, though significant, climbdown by the court - and one that could have formed the basis of an acceptable compromise. Indeed, the prime minister could have learned all he needed to know by reading the first paragraph of a carefully written court press release that had clearly been aimed at the British media.

This said the court had ruled, once again, that ‘general, automatic and indiscriminate disenfranchisement of all serving prisoners’ was incompatible with the human rights convention. But, the press release continued, the court had ‘accepted the UK government’s argument that each state had a wide discretion as to how it regulates the ban, both as regards the types of offence that should result in the loss of the vote and as to whether disenfranchisement should be ordered by a judge in an individual case or should result from general application of the law’.

The case in which the European court had first ruled that a blanket ban on prisoners voting breached the human rights convention was Hirst, decided by the court’s 17-judge grand chamber in 2005. It was five years later, in a case called Frodl, that a seven-judge chamber of the court went further and decided, in effect, that all prisoners should be allowed to vote unless the sentencing judge ordered disenfranchisement for a voting-related offence.

That went too far, the grand chamber indicated last week: there was no need for a judicial decision in individual cases. The court effectively allowed an appeal by the Italian government against a chamber ruling in favour of a murderer called Scoppola, ruling that Italy’s ban on prisoners voting did not breach the human rights convention because Italian law generally limited disenfranchisement to prisoners sentenced to three years or more. Although Italian prisoners sentenced to five years or more lost the vote for life, they could ask for it back three years after release. So there was no blanket ban in Italy: the ill-defined ‘margin of appreciation’ given to individual states had not been overstepped.

The UK is both more generous and less generous to prisoners than Italy: former inmates on the electoral roll can vote in the UK as soon as they are released but the ban on voting applies to all convicted prisoners, however short their sentences.

In an earlier case called Greens and MT, the Strasbourg court had set a six-month time limit for the UK to ‘bring forth legislative proposals’ that would make the law on voting by prisoners compliant with the human rights convention. That deadline was suspended until last week but now begins to run. So the government must, at the very least, publish a bill by November.

Crucially for the government, though, the bill really does not have to go very far to ensure there is no longer a blanket ban. Minor, largely cosmetic changes are all that is needed and it would be years before the court could decide whether they complied with the first protocol to the human rights convention, which guarantees free elections. So here is my plan. We know that remand prisoners - those awaiting trial - are allowed to vote, presumably by post or proxy. Why not extend this privilege for the first three months of a prisoner’s sentence? That would, in effect, reserve disenfranchisement for those sentenced to six months or more. It should pose no greater administrative problems than allowing remand prisoners to vote and it would probably be enough to satisfy the court.

Since it would be such a minor adjustment, it could hardly be opposed by MPs such as Jack Straw and David Davis. But it would undermine the argument they expressed last week - that it is acceptable to defy rulings of the Strasbourg court so long as they do not relate to what the two MPs regard as ‘serious’ breaches of human rights. And despite their claim that any reform would be thrown out by parliament, the coalition could easily command a majority by putting forward a government bill.

Personally, I am not too concerned about whether prisoners can vote or not. I suspect that not many would bother: it is hard enough to persuade non-prisoners that there is any point in voting these days.

But what I care passionately about is the message from those who should know better that it is somehow acceptable for the UK to ignore its international obligations and defy the rulings of a court whose decisions we have promised to respect. Nobody should vote for a government that flouts the rule of law.