diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index a903c3c..796262b 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -11,7 +11,8 @@ from django.core.management.base import CommandError, NoArgsCommand
 from django.utils.text import get_text_list
 from django.utils.jslex import prepare_js_for_gettext
 
-plural_forms_re = re.compile(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', re.MULTILINE | re.DOTALL)
+plural_forms_re = re.compile(
+    r'^(?P<value>"Plural-Forms.+?\\n")\s*$', re.MULTILINE | re.DOTALL)
 
 def handle_extensions(extensions=('html',)):
     """
@@ -37,13 +38,16 @@ def handle_extensions(extensions=('html',)):
             ext_list[i] = '.%s' % ext_list[i]
     return set([x for x in ext_list if x != '.py'])
 
+
 def _popen(cmd):
     """
     Friendly wrapper around Popen for Windows
     """
-    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True)
+    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE,
+              close_fds=os.name != 'nt', universal_newlines=True)
     return p.communicate()
 
+
 def walk(root, topdown=True, onerror=None, followlinks=False):
     """
     A version of os.walk that can follow symlinks for Python < 2.6
@@ -57,6 +61,7 @@ def walk(root, topdown=True, onerror=None, followlinks=False):
                     for link_dirpath, link_dirnames, link_filenames in walk(p):
                         yield (link_dirpath, link_dirnames, link_filenames)
 
+
 def is_ignored(path, ignore_patterns):
     """
     Helper function to check if the given path should be ignored or not.
@@ -66,6 +71,7 @@ def is_ignored(path, ignore_patterns):
             return True
     return False
 
+
 def find_files(root, ignore_patterns, verbosity, symlinks=False):
     """
     Helper function to get all files in the given root.
@@ -82,6 +88,7 @@ def find_files(root, ignore_patterns, verbosity, symlinks=False):
     all_files.sort()
     return all_files
 
+
 def copy_plural_forms(msgs, locale, domain, verbosity):
     """
     Copies plural forms header contents from a Django catalog of locale to
@@ -89,18 +96,21 @@ def copy_plural_forms(msgs, locale, domain, verbosity):
     contents of a newly created .po file.
     """
     import django
-    django_dir = os.path.normpath(os.path.join(os.path.dirname(django.__file__)))
+    django_dir = os.path.normpath(
+                     os.path.join(os.path.dirname(django.__file__)))
     if domain == 'djangojs':
         domains = ('djangojs', 'django')
     else:
         domains = ('django',)
     for domain in domains:
-        django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
+        django_po = os.path.join(django_dir, 'conf', 'locale', locale,
+                                 'LC_MESSAGES', '%s.po' % domain)
         if os.path.exists(django_po):
             m = plural_forms_re.search(open(django_po, 'rU').read())
             if m:
                 if verbosity > 1:
-                    sys.stderr.write("copying plural forms: %s\n" % m.group('value'))
+                    sys.stderr.write(
+                        "copying plural forms: %s\n" % m.group('value'))
                 lines = []
                 seen = False
                 for line in msgs.split('\n'):
@@ -115,8 +125,7 @@ def copy_plural_forms(msgs, locale, domain, verbosity):
 
 def make_messages(locale=None, domain='django', verbosity='1', all=False,
         extensions=None, symlinks=False, ignore_patterns=[], no_wrap=False,
-        no_location=False,
-        no_obsolete=False):
+        no_location=False, no_obsolete=False, keep_pot=False):
     """
     Uses the locale directory from the Django SVN tree or an application/
     project to process all
@@ -139,13 +148,22 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
     elif os.path.isdir('locale'):
         localedir = os.path.abspath('locale')
     else:
-        raise CommandError("This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or application, maybe you are just missing the conf/locale (in the django tree) or locale (for project and application) directory? It is not created automatically, you have to create it by hand if you want to enable i18n for your project or application.")
+        raise CommandError(
+            "This script should be run from the Django SVN tree or your "
+            "project or app tree. If you did indeed run it from the SVN "
+            "checkout or your project or application, maybe you are just "
+            "missing the conf/locale (in the django tree) or locale (for "
+            "project and application) directory? It is not created "
+            "automatically, you have to create it by hand if you want to "
+            "enable i18n for your project or application.")
 
     if domain not in ('django', 'djangojs'):
-        raise CommandError("currently makemessages only supports domains 'django' and 'djangojs'")
+        raise CommandError("currently makemessages only supports domains "
+                           "'django' and 'djangojs'")
 
     if (locale is None and not all) or domain is None:
-        message = "Type '%s help %s' for usage information." % (os.path.basename(sys.argv[0]), sys.argv[1])
+        message = "Type '%s help %s' for usage information." % (
+                  os.path.basename(sys.argv[0]), sys.argv[1])
         raise CommandError(message)
 
     # We require gettext version 0.15 or newer.
@@ -154,7 +172,10 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
     if match:
         xversion = (int(match.group('major')), int(match.group('minor')))
         if xversion < (0, 15):
-            raise CommandError("Django internationalization requires GNU gettext 0.15 or newer. You are using version %s, please upgrade your gettext toolset." % match.group())
+            raise CommandError(
+                "Django internationalization requires GNU gettext 0.15 or "
+                "newer. You are using version %s, please upgrade your gettext "
+                "toolset." % match.group())
 
     languages = []
     if locale is not None:
@@ -179,11 +200,13 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
         if os.path.exists(potfile):
             os.unlink(potfile)
 
-        for dirpath, file in find_files(".", ignore_patterns, verbosity, symlinks=symlinks):
+        for dirpath, file in find_files(".", ignore_patterns, verbosity,
+                                        symlinks=symlinks):
             file_base, file_ext = os.path.splitext(file)
             if domain == 'djangojs' and file_ext in extensions:
                 if verbosity > 1:
-                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
+                    sys.stdout.write('processing file %s in %s\n'
+                                     % (file, dirpath))
                 src = open(os.path.join(dirpath, file), "rU").read()
                 src = prepare_js_for_gettext(src)
                 thefile = '%s.c' % file
@@ -196,14 +219,13 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
                     'xgettext -d %s -L C %s %s --keyword=gettext_noop '
                     '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 '
                     '--keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 '
-                    '--from-code UTF-8 --add-comments=Translators -o - "%s"' % (
-                        domain, wrap, location, os.path.join(dirpath, thefile)
-                    )
+                    '--from-code UTF-8 --add-comments=Translators -o - "%s"'
+                    % (domain, wrap, location, os.path.join(dirpath, thefile))
                 )
                 msgs, errors = _popen(cmd)
                 if errors:
                     os.unlink(os.path.join(dirpath, thefile))
-                    if os.path.exists(potfile):
+                    if os.path.exists(potfile) and not keep_pot:
                         os.unlink(potfile)
                     raise CommandError(
                         "errors happened while running xgettext on %s\n%s" %
@@ -223,7 +245,8 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
                     finally:
                         f.close()
                 os.unlink(os.path.join(dirpath, thefile))
-            elif domain == 'django' and (file_ext == '.py' or file_ext in extensions):
+            elif (domain == 'django'
+                  and (file_ext == '.py' or file_ext in extensions)):
                 thefile = file
                 orig_file = os.path.join(dirpath, file)
                 if file_ext in extensions:
@@ -235,7 +258,8 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
                     finally:
                         f.close()
                 if verbosity > 1:
-                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
+                    sys.stdout.write('processing file %s in %s\n'
+                                     % (file, dirpath))
                 cmd = (
                     'xgettext -d %s -L Python %s %s --keyword=gettext_noop '
                     '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 '
@@ -250,7 +274,7 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
                 if errors:
                     if thefile != file:
                         os.unlink(os.path.join(dirpath, thefile))
-                    if os.path.exists(potfile):
+                    if os.path.exists(potfile) and not keep_pot:
                         os.unlink(potfile)
                     raise CommandError(
                         "errors happened while running xgettext on %s\n%s" %
@@ -277,7 +301,8 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
             msgs, errors = _popen('msguniq %s %s --to-code=utf-8 "%s"' %
                                   (wrap, location, potfile))
             if errors:
-                os.unlink(potfile)
+                if not keep_pot:
+                    os.unlink(potfile)
                 raise CommandError(
                     "errors happened while running msguniq\n%s" % errors)
             if os.path.exists(pofile):
@@ -289,22 +314,26 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
                 msgs, errors = _popen('msgmerge %s %s -q "%s" "%s"' %
                                       (wrap, location, pofile, potfile))
                 if errors:
-                    os.unlink(potfile)
+                    if not keep_pot:
+                        os.unlink(potfile)
                     raise CommandError(
                         "errors happened while running msgmerge\n%s" % errors)
             elif not invoked_for_django:
                 msgs = copy_plural_forms(msgs, locale, domain, verbosity)
             msgs = msgs.replace(
-                "#. #-#-#-#-#  %s.pot (PACKAGE VERSION)  #-#-#-#-#\n" % domain, "")
+                "#. #-#-#-#-#  %s.pot (PACKAGE VERSION)  #-#-#-#-#\n"
+                % domain, "")
             f = open(pofile, 'wb')
             try:
                 f.write(msgs)
             finally:
                 f.close()
-            os.unlink(potfile)
+            if not keep_pot:
+                os.unlink(potfile)
             if no_obsolete:
-                msgs, errors = _popen('msgattrib %s %s -o "%s" --no-obsolete "%s"' %
-                                      (wrap, location, pofile, pofile))
+                msgs, errors = _popen(
+                    'msgattrib %s %s -o "%s" --no-obsolete "%s"'
+                    %(wrap, location, pofile, pofile))
                 if errors:
                     raise CommandError(
                         "errors happened while running msgattrib\n%s" % errors)
@@ -313,32 +342,45 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
 class Command(NoArgsCommand):
     option_list = NoArgsCommand.option_list + (
         make_option('--locale', '-l', default=None, dest='locale',
-            help='Creates or updates the message files for the given locale (e.g. pt_BR).'),
+            help='Creates or updates the message files for the given locale '
+                 '(e.g. pt_BR).'),
         make_option('--domain', '-d', default='django', dest='domain',
             help='The domain of the message files (default: "django").'),
         make_option('--all', '-a', action='store_true', dest='all',
-            default=False, help='Updates the message files for all existing locales.'),
-        make_option('--extension', '-e', dest='extensions',
-            help='The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs"). Separate multiple extensions with commas, or use -e multiple times.',
-            action='append'),
+            default=False, help='Updates the message files for all existing '
+                                'locales.'),
+        make_option('--extension', '-e', dest='extensions', action='append',
+            help='The file extension(s) to examine (default: "html,txt", or '
+                 '"js" if the domain is "djangojs"). Separate multiple '
+                 'extensions with commas, or use -e multiple times.'),
         make_option('--symlinks', '-s', action='store_true', dest='symlinks',
-            default=False, help='Follows symlinks to directories when examining source code and templates for translation strings.'),
+            default=False, help='Follows symlinks to directories when '
+                                'examining source code and templates for '
+                                'translation strings.'),
         make_option('--ignore', '-i', action='append', dest='ignore_patterns',
-            default=[], metavar='PATTERN', help='Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.'),
-        make_option('--no-default-ignore', action='store_false', dest='use_default_ignore_patterns',
-            default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*' and '*~'."),
+            default=[], metavar='PATTERN',
+            help='Ignore files or directories matching this glob-style '
+                 'pattern. Use multiple times to ignore more.'),
+        make_option('--no-default-ignore', action='store_false',
+            default=True, dest='use_default_ignore_patterns',
+            help="Don't ignore the common glob-style patterns 'CVS', '.*' and "
+                 "'*~'."),
         make_option('--no-wrap', action='store_true', dest='no_wrap',
-            default=False, help="Don't break long message lines into several lines"),
+            default=False, help="Don't break long message lines into several "
+                                "lines"),
         make_option('--no-location', action='store_true', dest='no_location',
             default=False, help="Don't write '#: filename:line' lines"),
         make_option('--no-obsolete', action='store_true', dest='no_obsolete',
             default=False, help="Remove obsolete message strings"),
+        make_option('--keep-pot', action='store_true', dest='keep_pot',
+            default=False, help="Keep .pot file after making messages. Useful "
+                                "when debugging."),
     )
     help = ( "Runs over the entire source tree of the current directory and "
-"pulls out all strings marked for translation. It creates (or updates) a message "
-"file in the conf/locale (in the django tree) or locale (for projects and "
-"applications) directory.\n\nYou must run this command with one of either the "
-"--locale or --all options.")
+"pulls out all strings marked for translation. It creates (or updates) a "
+"message file in the conf/locale (in the django tree) or locale (for projects "
+"and applications) directory.\n\nYou must run this command with one of either "
+"the --locale or --all options.")
 
     requires_model_validation = False
     can_import_settings = False
@@ -357,6 +399,7 @@ class Command(NoArgsCommand):
         no_wrap = options.get('no_wrap')
         no_location = options.get('no_location')
         no_obsolete = options.get('no_obsolete')
+        keep_pot = options.get('keep_pot')
         if domain == 'djangojs':
             extensions = handle_extensions(extensions or ['js'])
         else:
@@ -366,4 +409,6 @@ class Command(NoArgsCommand):
             sys.stdout.write('examining files with the extensions: %s\n'
                              % get_text_list(list(extensions), 'and'))
 
-        make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_location, no_obsolete)
+        make_messages(locale, domain, verbosity, process_all, extensions,
+            symlinks, ignore_patterns, no_wrap, no_location, no_obsolete,
+            keep_pot)
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 8b83a43..5d71901 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -483,6 +483,14 @@ Use the ``--no-location`` option to not write '``#: filename:line``'
 comment lines in language files. Note that using this option makes it harder
 for technically skilled translators to understand each message's context.
 
+.. django-admin-option:: --keep-pot
+
+.. versionadded:: 1.4
+
+Use the ``--keep-pot`` option to prevent django from deleting the temporary
+.pot file it generates before creating the .po file. This is useful for
+debugging errors which may prevent the final language files from being created.
+
 reset <appname appname ...>
 ---------------------------
 
diff --git a/tests/regressiontests/i18n/commands/extraction.py b/tests/regressiontests/i18n/commands/extraction.py
index 6566ef4..7a2683c 100644
--- a/tests/regressiontests/i18n/commands/extraction.py
+++ b/tests/regressiontests/i18n/commands/extraction.py
@@ -265,3 +265,36 @@ class NoLocationExtractorTests(ExtractorTests):
         with open(self.PO_FILE, 'r') as fp:
             po_contents = fp.read()
             self.assertTrue('#: templates/test.html:55' in po_contents)
+
+
+class KeepPotFileExtractorTests(ExtractorTests):
+
+    def setUp(self):
+        self.POT_FILE = self.PO_FILE + 't'
+        super(KeepPotFileExtractorTests, self).setUp()
+
+    def tearDown(self):
+        super(KeepPotFileExtractorTests, self).tearDown()
+        os.chdir(self.test_dir)
+        try:
+            os.unlink(self.POT_FILE)
+        except OSError:
+            pass
+        os.chdir(self._cwd)
+
+    def test_keep_pot_disabled_by_default(self):
+        os.chdir(self.test_dir)
+        management.call_command('makemessages', locale=LOCALE, verbosity=0)
+        self.assertFalse(os.path.exists(self.POT_FILE))
+
+    def test_keep_pot_explicitly_disabled(self):
+        os.chdir(self.test_dir)
+        management.call_command('makemessages', locale=LOCALE, verbosity=0,
+            keep_pot=False)
+        self.assertFalse(os.path.exists(self.POT_FILE))
+
+    def test_keep_pot_enabled(self):
+        os.chdir(self.test_dir)
+        management.call_command('makemessages', locale=LOCALE, verbosity=0,
+            keep_pot=True)
+        self.assertTrue(os.path.exists(self.POT_FILE))
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index cc17d74..a87de2e 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -29,7 +29,7 @@ if can_run_extraction_tests:
     from .commands.extraction import (ExtractorTests, BasicExtractorTests,
         JavascriptExtractorTests, IgnoredExtractorTests, SymlinkExtractorTests,
         CopyPluralFormsExtractorTests, NoWrapExtractorTests,
-        NoLocationExtractorTests)
+        NoLocationExtractorTests, KeepPotFileExtractorTests)
 if can_run_compilation_tests:
     from .commands.compilation import (PoFileTests, PoFileContentsTests,
         PercentRenderingTests)
