@@ -150,9 +150,11 @@ def valid_contextj(label: str, pos: int) -> bool:
150
150
joining_type = idnadata .joining_types .get (ord (label [i ]))
151
151
if joining_type == ord ('T' ):
152
152
continue
153
- if joining_type in [ord ('L' ), ord ('D' )]:
153
+ elif joining_type in [ord ('L' ), ord ('D' )]:
154
154
ok = True
155
155
break
156
+ else :
157
+ break
156
158
157
159
if not ok :
158
160
return False
@@ -162,9 +164,11 @@ def valid_contextj(label: str, pos: int) -> bool:
162
164
joining_type = idnadata .joining_types .get (ord (label [i ]))
163
165
if joining_type == ord ('T' ):
164
166
continue
165
- if joining_type in [ord ('R' ), ord ('D' )]:
167
+ elif joining_type in [ord ('R' ), ord ('D' )]:
166
168
ok = True
167
169
break
170
+ else :
171
+ break
168
172
return ok
169
173
170
174
if cp_value == 0x200d :
@@ -236,12 +240,8 @@ def check_label(label: Union[str, bytes, bytearray]) -> None:
236
240
if intranges_contain (cp_value , idnadata .codepoint_classes ['PVALID' ]):
237
241
continue
238
242
elif intranges_contain (cp_value , idnadata .codepoint_classes ['CONTEXTJ' ]):
239
- try :
240
- if not valid_contextj (label , pos ):
241
- raise InvalidCodepointContext ('Joiner {} not allowed at position {} in {}' .format (
242
- _unot (cp_value ), pos + 1 , repr (label )))
243
- except ValueError :
244
- raise IDNAError ('Unknown codepoint adjacent to joiner {} at position {} in {}' .format (
243
+ if not valid_contextj (label , pos ):
244
+ raise InvalidCodepointContext ('Joiner {} not allowed at position {} in {}' .format (
245
245
_unot (cp_value ), pos + 1 , repr (label )))
246
246
elif intranges_contain (cp_value , idnadata .codepoint_classes ['CONTEXTO' ]):
247
247
if not valid_contexto (label , pos ):
0 commit comments