Hebrews 10:5 (ESV) states
Consequently, when Christ came into the world, he said, “Sacrifices and offerings you have not desired, but a body have you prepared for me;
This is an apparent reference to Psalm 40:6:
In sacrifice and offering you have not delighted, but you have given me an open ear.
The footnote in my Bible on the Psalm mentions that literally this verse would be "ears you have dug for me".
I can understand an idiomatic translation; digging out ones ears is a Hebrew idiom roughly equivalent to having an "open ear" in English. But moving to "a body have you prepared for me" seems to be far beyond translating an idiom.
I looked at one of these sites that has a whole bunch (17) of translations; all translate that phrase in Hebrews fairly similar (mentioning preparation of a body). In the case of the Psalm, likewise, they all seem to mention something about ears. Whether "you have made me listen" or "you have pierced my ears" or one of the ESV translations I mentioned above.
So most translations seem to point to the translation from Hebrew to Greek is a rather liberal one. Am I understanding this correctly? And if so, how does digging out an ear relate to preparing a body?