From: Serhiy Storchaka Date: Fri, 11 Jan 2013 10:12:32 +0000 (+0200) Subject: Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. X-Git-Tag: v3.4.0a1~1648 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9942e5a9cf4054591134e2495d50615faebe3662;p=python Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now pindent.py works with a "with" statement. pindent.py no longer produces improper indentation. pindent.py now works with continued lines broken after "class" or "def" keywords and with continuations at the start of line. Added regression tests for pindent.py. Modernized pindent.py. --- 9942e5a9cf4054591134e2495d50615faebe3662 diff --cc Misc/NEWS index f1f3039c4e,c324282012..691d72759c --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -621,8 -424,8 +621,10 @@@ Extension Module Tests ----- + - Issue #15539: Added regression tests for Tools/scripts/pindent.py. + +- Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host. + - Issue #16925: test_configparser now works with unittest test discovery. Patch by Zachary Ware. @@@ -777,22 -573,13 +779,27 @@@ Documentatio Tools/Demos ----------- + - Issue #15539: Fix a number of bugs in Tools/scripts/pindent.py. Now + pindent.py works with a "with" statement. pindent.py no longer produces + improper indentation. pindent.py now works with continued lines broken after + "class" or "def" keywords and with continuations at the start of line. + +- Issue #11797: Add a 2to3 fixer that maps reload() to imp.reload(). + +- Issue #10966: Remove the concept of unexpected skipped tests. + +- Issue #9893: Removed the Misc/Vim directory. + +- Removed the Misc/TextMate directory. + +- Issue #16245: Add the Tools/scripts/parse_html5_entities.py script to parse + the list of HTML5 entities and update the html.entities.html5 dictionary. + - Issue #15378: Fix Tools/unicode/comparecodecs.py. Patch by Serhiy Storchaka. +- Issue #13301: use ast.literal_eval() instead of eval() in Tools/i18n/msgfmt.py + Patch by Serhiy Storchaka. + What's New in Python 3.3.0? =========================== diff --cc Tools/scripts/pindent.py index 0151773de2,fd04c92307..25006ae35d --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@@ -427,11 -379,11 +379,11 @@@ def complete_file(filename, stepsize = # end if import os try: os.rename(filename, filename + '~') - except os.error: pass + except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def complete_file @@@ -442,11 -396,11 +396,11 @@@ def delete_file(filename, stepsize = ST # end if import os try: os.rename(filename, filename + '~') - except os.error: pass + except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def delete_file @@@ -457,11 -413,11 +413,11 @@@ def reformat_file(filename, stepsize = # end if import os try: os.rename(filename, filename + '~') - except os.error: pass + except OSError: pass # end try - f = open(filename, 'w') - f.write(result) - f.close() + with open(filename, 'w') as f: + f.write(result) + # end with return 1 # end def reformat_file