Skip to content

Commit

Permalink
Merge pull request #131 from kjd/issue-128
Browse files Browse the repository at this point in the history
Register 'idna2008' codec (issue #128)
  • Loading branch information
kjd committed Nov 1, 2022
2 parents 18d8bf3 + f040ad8 commit 410d9ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions idna/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ class StreamReader(Codec, codecs.StreamReader):
pass


def getregentry() -> codecs.CodecInfo:
def getregentry(name: str) -> Optional[codecs.CodecInfo]:
if name != 'idna' and name != 'idna2008':
return None

# Compatibility as a search_function for codecs.register()
return codecs.CodecInfo(
name='idna',
name='idna2008',
encode=Codec().encode, # type: ignore
decode=Codec().decode, # type: ignore
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamwriter=StreamWriter,
streamreader=StreamReader,
)

codecs.register(getregentry)

0 comments on commit 410d9ec

Please sign in to comment.