Mercurial > p > roundup > code
comparison roundup/configuration.py @ 8455:6d6f689d3701
fix: python < 3.12 returns ParsingError not RuntimeError; print exception
RuntimeError added in 3.12. Support older configparser.ParsingError.
Supporting older version also requires different test string for the
two versions.
Also use str(exception) rather than exception.args[0] for producing
message to user. Include exception name in output.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 22 Sep 2025 13:57:52 -0400 |
| parents | e91ff70e4563 |
| children | f7fadbac5856 |
comparison
equal
deleted
inserted
replaced
| 8452:e91ff70e4563 | 8455:6d6f689d3701 |
|---|---|
| 2637 try: | 2637 try: |
| 2638 logging.config.fileConfig( | 2638 logging.config.fileConfig( |
| 2639 _file, | 2639 _file, |
| 2640 disable_existing_loggers=self[ | 2640 disable_existing_loggers=self[ |
| 2641 "LOGGING_DISABLE_LOGGERS"]) | 2641 "LOGGING_DISABLE_LOGGERS"]) |
| 2642 except (ValueError, RuntimeError, | 2642 except (ValueError, RuntimeError, configparser.ParsingError, |
| 2643 KeyError, NameError, ModuleNotFoundError) as e: | 2643 KeyError, NameError, ModuleNotFoundError) as e: |
| 2644 # configparser.DuplicateOptionError includes | 2644 # configparser.DuplicateOptionError includes |
| 2645 # filename, line number and a useful error. | 2645 # filename, line number and a useful error. |
| 2646 # so we don't have to augment it. | 2646 # so we don't have to augment it. |
| 2647 context = [] | 2647 context = [] |
| 2658 | 2658 |
| 2659 raise LoggingConfigError( | 2659 raise LoggingConfigError( |
| 2660 "Error loading logging config from %(file)s.\n\n" | 2660 "Error loading logging config from %(file)s.\n\n" |
| 2661 " %(msg)s\n\n%(context)s\n" % { | 2661 " %(msg)s\n\n%(context)s\n" % { |
| 2662 "file": _file, | 2662 "file": _file, |
| 2663 "msg": e.args[0], | 2663 "msg": type(e).__name__ + ": " + str(e), |
| 2664 "context": " ".join(context), | 2664 "context": " ".join(context), |
| 2665 } | 2665 } |
| 2666 ) | 2666 ) |
| 2667 elif _file.endswith(".json"): | 2667 elif _file.endswith(".json"): |
| 2668 config_dict = self.load_config_dict_from_json_file(_file) | 2668 config_dict = self.load_config_dict_from_json_file(_file) |
