Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #8: Use dict on py>=3.7; Improved exceptions, and mapping vs iterable #14

Merged
merged 1 commit into from Jul 22, 2020

Conversation

andy-maier
Copy link
Contributor

See commit message.

Note: It is not worth reviewing the docstrings of this PR, as the docs are updated in PR #5

@andy-maier andy-maier self-assigned this Jul 22, 2020
@andy-maier andy-maier linked an issue Jul 22, 2020 that may be closed by this pull request
@andy-maier andy-maier changed the title Changed OrderedDict to dict on py>=3.7; Suppressed duplicate exc. message Fixes #8: Changed OrderedDict to dict on py>=3.7; Suppressed duplicate exc. message Jul 22, 2020
@andy-maier andy-maier force-pushed the andy/reduce-ordereddict branch 2 times, most recently from 507b603 to fc459a8 Compare July 22, 2020 05:34
@andy-maier andy-maier added this to the 1.0.0 milestone Jul 22, 2020
@coveralls
Copy link

coveralls commented Jul 22, 2020

Coverage Status

Coverage decreased (-0.9%) to 97.041% when pulling 8af5101 on andy/reduce-ordereddict into b041d9f on master.

@andy-maier andy-maier changed the title Fixes #8: Changed OrderedDict to dict on py>=3.7; Suppressed duplicate exc. message Fixes #8: Use dict on py>=3.7; Improved exceptions, and mapping vs iterable Jul 22, 2020
@andy-maier andy-maier force-pushed the andy/reduce-ordereddict branch 4 times, most recently from 2c7f18c to 4608943 Compare July 22, 2020 07:01
Details:

* Starting with Python 3.7, the standard dict is guaranteed to be
  ordered on all Python implementations. Therefore, there is no
  reason to use OrderedDict anymore on py>=3.7, and the standard
  dict is faster. This change uses dict on py>=3.7 and otherwise
  OrderedDict for the implementation of NocaseDict.

* The issuing of message 'During handling of the above exception,
  another exception occurred' is now suppressed by setting
  exc.__cause__ = None. This works on both Python 2 and 3.

* Improved the detection of mapping vs iterable as the init
  argument by generalizing the type checking for mapping to
  be derived from (NocaseDict, Mapping, UserDict), and to expect
  an iterable otherwise, failing with TypeError when it cannot
  be iterated on.

* Exception messages have been cleaned up and improved, and in
  some cases re-raised with better message. No different
  exception types are raised than before this change.

* Along with the new re.-raising of exceptions, it surfaced
  that some error cases had not been tested so far, mainly
  in the area of providing iterables of tuples (key, value)
  where the tuple items did not contain exactly two items.
  Added testcases to cover these error cases.

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
@andy-maier andy-maier merged commit 844d173 into master Jul 22, 2020
@andy-maier andy-maier deleted the andy/reduce-ordereddict branch July 22, 2020 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use OrderedDict only before py37
3 participants