Skip to content

Commit 1621fa5

Browse files
committed
Fix the error message of KeyAlreadyPresent
Close #185
1 parent 352de24 commit 1621fa5

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixed
66

7+
- Use the plain python string representation of `Key` in `KeyAlreadyPresent` error message. ([#185](https://github.com/sdispater/tomlkit/issues/185))
78
- Fix the `astimezone()` and `replace()` methods of datetime objects. ([#188](https://github.com/sdispater/tomlkit/issues/188))
89
- Add type definitions for `items()` function. ([#190](https://github.com/sdispater/tomlkit/issues/190))
910

tomlkit/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class KeyAlreadyPresent(TOMLKitError):
194194
"""
195195

196196
def __init__(self, key):
197+
key = getattr(key, "key", key)
197198
message = f'Key "{key}" already exists.'
198199

199200
super().__init__(message)

0 commit comments

Comments
 (0)