[Python-checkins] cpython (merge 3.5 -> default): Issue #27452: add line counter and crc to IDLE config test dump.

terry.reedy python-checkins at python.org
Tue Jul 5 20:12:00 EDT 2016


https://hg.python.org/cpython/rev/c2e21bc83066
changeset:   102258:c2e21bc83066
parent:      102255:682a8e36dd18
parent:      102257:127569004538
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Tue Jul 05 20:11:37 2016 -0400
summary:
  Issue #27452: add line counter and crc to IDLE config test dump.

files:
  Lib/idlelib/config.py |  29 ++++++++++++++++++++---------
  1 files changed, 20 insertions(+), 9 deletions(-)


diff --git a/Lib/idlelib/config.py b/Lib/idlelib/config.py
--- a/Lib/idlelib/config.py
+++ b/Lib/idlelib/config.py
@@ -738,19 +738,30 @@
 # TODO Revise test output, write expanded unittest
 #
 if __name__ == '__main__':
+    from zlib import crc32
+    line, crc = 0, 0
+
+    def sprint(obj):
+        global line, crc
+        txt = str(obj)
+        line += 1
+        crc = crc32(txt.encode(encoding='utf-8'), crc)
+        print(txt)
+        #print('***', line, crc, '***')  # uncomment for diagnosis
+
     def dumpCfg(cfg):
-        print('\n', cfg, '\n')
-        for key in cfg:
+        print('\n', cfg, '\n')  # has variable '0xnnnnnnnn' addresses
+        for key in sorted(cfg.keys()):
             sections = cfg[key].sections()
-            print(key)
-            print(sections)
+            sprint(key)
+            sprint(sections)
             for section in sections:
                 options = cfg[key].options(section)
-                print(section)
-                print(options)
+                sprint(section)
+                sprint(options)
                 for option in options:
-                    print(option, '=', cfg[key].Get(section, option))
+                    sprint(option + ' = ' + cfg[key].Get(section, option))
+
     dumpCfg(idleConf.defaultCfg)
     dumpCfg(idleConf.userCfg)
-    print(idleConf.userCfg['main'].Get('Theme', 'name'))
-    #print idleConf.userCfg['highlight'].GetDefHighlight('Foo','normal')
+    print('\nlines = ', line, ', crc = ', crc, sep='')

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list