19
19
from poetry .core .constraints .generic import MultiConstraint
20
20
from poetry .core .constraints .generic import UnionConstraint
21
21
from poetry .core .constraints .version import VersionConstraint
22
+ from poetry .core .constraints .version .exceptions import ParseConstraintError
22
23
from poetry .core .version .grammars import GRAMMAR_PEP_508_MARKERS
23
24
from poetry .core .version .parser import Parser
24
25
@@ -313,7 +314,7 @@ def __init__(
313
314
314
315
parsed_constraint : BaseConstraint | VersionConstraint
315
316
parser : Callable [[str ], BaseConstraint | VersionConstraint ]
316
- constraint_string = str (constraint )
317
+ original_constraint_string = constraint_string = str (constraint )
317
318
318
319
# Extract operator and value
319
320
m = self ._CONSTRAINT_RE .match (constraint_string )
@@ -346,9 +347,7 @@ def __init__(
346
347
if self ._operator == "in" :
347
348
glue = " || "
348
349
349
- parsed_constraint = parser (glue .join (versions ))
350
- else :
351
- parsed_constraint = parser (constraint_string )
350
+ constraint_string = glue .join (versions )
352
351
else :
353
352
# if we have a in/not in operator we split the constraint
354
353
# into a union/multi-constraint of single constraint
@@ -357,7 +356,10 @@ def __init__(
357
356
values = re .split ("[ ,]+" , self ._value )
358
357
constraint_string = glue .join (f"{ op } { value } " for value in values )
359
358
359
+ try :
360
360
parsed_constraint = parser (constraint_string )
361
+ except ParseConstraintError as e :
362
+ raise InvalidMarker (f"Invalid marker: { original_constraint_string } " ) from e
361
363
362
364
super ().__init__ (name , parsed_constraint )
363
365
0 commit comments