Guard advancing past leading meta-comments.
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index 1307042..c8423f1 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -1360,10 +1360,12 @@
                             (set-buffer funcbuffer)
                             (count-lines
                              (point-min)
-                             (string-match "^\\([^#]\\|#[^#]\\|#$\\)"
-                                           (buffer-substring (point-min)
-                                                             (point-max)
-                                                             funcbuffer)))))))
+                             (max (point-min)
+                                  (string-match "^\\([^#]\\|#[^#]\\|#$\\)"
+                                                (buffer-substring (point-min)
+                                                                  (point-max)
+                                                                  funcbuffer))
+                                  ))))))
              (list lineno funcbuffer))
 
             ((= (elt filename 0) ?\<)