In some courses, inserting the calendar_upcoming or calendar_month block causes a few errors to be displayed:
Notice: Trying to get property of non-object in C:\xampp\htdocs\moodle2-hq\lib\moodlelib.php on line 5842
That one's repeated three times, followed by:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
I've narrowed it down to the call to calendar_session_vars($this->page->course) on line 19 of block_calendar_upcoming.php and line 23 of block_calendar_month.php. For some courses, the course object that gets passed in to this function contains a coursenode object, while in other seemingly identical courses it does not (it presumably gets added at some stage after the block is generated in these cases). If the coursenode object is present in the course object that gets passed in to calendar_session_vars(), the above errors occur - removing the coursenode object prevents them from happening.
I've attached a patch which, if the coursenode is present, clones the course object, removes the coursenode from the clone, and places the clone into $SESSION->cal_courses_shown rather than the original. If somebody who understands this better than I do has a suggestion on a better fix, please contribute - this may not be the best way to fix it, but it does the trick.