Regarding software, can an application or block of code licensed under the GPL (pre version 3), or a similar license requiring the source to be made available under the terms of the license after redistribution or modification, be patented?
That's one of the reasons why version 3 of the GPL specifically states that you must grant all downstream recipients of a covered work an irrevocable, royalty free license to the patented component, or you can't distribute the software. Redhat reached the first licensing deal that complied with this requirement. That is a good step, but not a solution. Patent threats can pop up like moles in a game of whack-a-mole.
There are a myriad of patents that could potentially apply to any sufficiently complex piece of software, such as a file system, and no license (no matter what version or conditions implemented) can solve that problem. The problem is, parts of complex software are often already patented, but the patents are unknown to the author. It can be just a matter of time before a patent holder discovers a possible infringement and begins to take action - or the 'infringing' parts may remain undiscovered forever.
Remember, you're not patenting code, your patenting what it implements or accomplishes. Thus, you could take that bit of code, re-write it in a completely different language and you still have the patent problem to deal with. The copyright changed because the work is your own (thus the license no longer applies), but the patent remains because the code still implements or accomplishes the same thing.
If no patent exists that could apply to the software, then the software itself would be prior art - but that might not stop the patent from being granted.
As far as I'm aware, a block of code or a piece of software can't be patented, period. That's strictly copyright territory.
What can be patented is the process that the code implements. And to that end, a program licensed under the GPL may implement a process covered by a patent. GPLv3, however, mandates that you grant all downstream users a license on the patent.
As for GPLv2 and earlier there is no such requirement. That's one of the huge differences between v2 and v3; before that, people just assumed that "free software" meant "free software", and patents were threatening to ruin that. Hence the change.