As you start working with geospatial data, you will soon discover that things don't always work the way you expect them to. OGR may crash when attempting to save a geometry into a shapefile, or Shapely may cause a system error when calculating the intersection of two polygons. While this can be frustrating, there are ways to solve these problems once you understand what causes them.
Geospatial data, and libraries such as GDAL/OGR and Shapely, are based around a mathematical model of how a geometry should be structured. Problems occur when your geospatial data doesn't meet this mathematical ideal. Let's take a look at what a mathematically-correct geometry looks like.