Ticket #13374: django-pypy.diff

File django-pypy.diff, 4.4 KB (added by Alex Gaynor, 14 years ago)
  • django/core/management/commands/makemessages.py

    diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
    index 000ed0a..955a822 100644
    a b def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    185185                src = open(os.path.join(dirpath, file), "rU").read()
    186186                src = pythonize_re.sub('\n#', src)
    187187                thefile = '%s.py' % file
    188                 open(os.path.join(dirpath, thefile), "w").write(src)
     188                f = open(os.path.join(dirpath, thefile), "w")
     189                try:
     190                    f.write(src)
     191                finally:
     192                    f.close()
    189193                cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
    190194                msgs, errors = _popen(cmd)
    191195                if errors:
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    199203                else:
    200204                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
    201205                if msgs:
    202                     open(potfile, 'ab').write(msgs)
     206                    f = open(potfile, 'ab')
     207                    try:
     208                        f.write(msgs)
     209                    finally:
     210                        f.close()
    203211                os.unlink(os.path.join(dirpath, thefile))
    204212            elif domain == 'django' and (file_ext == '.py' or file_ext in extensions):
    205213                thefile = file
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    207215                    src = open(os.path.join(dirpath, file), "rU").read()
    208216                    thefile = '%s.py' % file
    209217                    try:
    210                         open(os.path.join(dirpath, thefile), "w").write(templatize(src))
     218                        f = open(os.path.join(dirpath, thefile), "w")
     219                        try:
     220                            f.write(templatize(src))
     221                        finally:
     222                            f.close()
    211223                    except SyntaxError, msg:
    212224                        msg = "%s (file: %s)" % (msg, os.path.join(dirpath, file))
    213225                        raise SyntaxError(msg)
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    229241                else:
    230242                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
    231243                if msgs:
    232                     open(potfile, 'ab').write(msgs)
     244                    f = open(potfile, 'ab')
     245                    try:
     246                        f.write(msgs)
     247                    finally:
     248                        f.close()
    233249                if thefile != file:
    234250                    os.unlink(os.path.join(dirpath, thefile))
    235251
    def make_messages(locale=None, domain='django', verbosity='1', all=False,  
    237253            msgs, errors = _popen('msguniq --to-code=utf-8 "%s"' % potfile)
    238254            if errors:
    239255                raise CommandError("errors happened while running msguniq\n%s" % errors)
    240             open(potfile, 'w').write(msgs)
     256            f = open(potfile, 'w')
     257            try:
     258                f.write(msgs)
     259            finally:
     260                f.close()
    241261            if os.path.exists(pofile):
    242262                msgs, errors = _popen('msgmerge -q "%s" "%s"' % (pofile, potfile))
    243263                if errors:
    244264                    raise CommandError("errors happened while running msgmerge\n%s" % errors)
    245265            elif not invoked_for_django:
    246266                msgs = copy_plural_forms(msgs, locale, domain, verbosity)
    247             open(pofile, 'wb').write(msgs)
     267            f = open(pofile, 'wb')
     268            try:
     269                f.write(msgs)
     270            finally:
     271                f.close()
    248272            os.unlink(potfile)
    249273
    250274
  • tests/regressiontests/forms/localflavor/se.py

    diff --git a/tests/regressiontests/forms/localflavor/se.py b/tests/regressiontests/forms/localflavor/se.py
    index 44bd953..2d92761 100644
    a b tests = r"""  
    1212>>> olddate = datetime.date
    1313>>> datetime.date = MockDate
    1414>>> datetime.date.today()
    15 MockDate(2008, 5, 14)
     15...MockDate(2008, 5, 14)
    1616
    1717
    1818# SECountySelect #####################################################
Back to Top