@@ -87,12 +87,9 @@ def size_for_addr(codec: CodecBase, buf_io: io.BytesIO) -> int:
87
87
88
88
89
89
def string_iter (string : str ) -> Generator [Tuple [Protocol , CodecBase , Optional [str ]], None , None ]:
90
- print (f"[DEBUG] Parsing string: { string } " )
91
90
if not string :
92
- print ("[DEBUG] Empty string error" )
93
91
raise exceptions .StringParseError ("Empty string" , string )
94
92
if not string .startswith ('/' ):
95
- print ("[DEBUG] Must begin with / error" )
96
93
raise exceptions .StringParseError ("Must begin with /" , string )
97
94
# consume trailing slashes
98
95
string = string .rstrip ('/' )
@@ -102,13 +99,10 @@ def string_iter(string: str) -> Generator[Tuple[Protocol, CodecBase, Optional[st
102
99
sp .pop (0 )
103
100
while sp :
104
101
element = sp .pop (0 )
105
- print (f"[DEBUG] Element: '{ element } ' Remaining: { sp } " )
106
102
if not element : # Skip empty elements from multiple slashes
107
- print ("[DEBUG] Skipping empty element" )
108
103
continue
109
104
try :
110
105
proto = protocol_with_name (element )
111
- print (f"[DEBUG] Found protocol: { proto .name } " )
112
106
if proto .codec is None :
113
107
# Create a dummy codec with size 0 for protocols without a codec
114
108
codec = CodecBase ()
@@ -117,49 +111,40 @@ def string_iter(string: str) -> Generator[Tuple[Protocol, CodecBase, Optional[st
117
111
else :
118
112
codec = codec_by_name (proto .codec )
119
113
except (ImportError , exceptions .ProtocolNotFoundError ) as exc :
120
- print (f"[DEBUG] Unknown Protocol: { element } " )
121
114
raise exceptions .StringParseError ("Unknown Protocol" , string , element ) from exc
122
115
value = None
123
116
if codec is not None and codec .SIZE != 0 :
124
117
if proto .name == 'unix' :
125
118
# For unix, join all remaining elements as the value
126
119
path_value = '/' .join (sp ) if sp else ''
127
120
if not path_value :
128
- print (f"[DEBUG] Protocol { proto .name } requires path but none left" )
129
121
raise exceptions .StringParseError ("Protocol requires path" , string , proto .name )
130
122
try :
131
123
codec .to_bytes (proto , path_value )
132
124
value = path_value
133
- print (f"[DEBUG] Using path value '{ value } ' for protocol { proto .name } " )
134
125
sp .clear () # All remaining elements are part of the path
135
126
except Exception as exc :
136
- print (f"[DEBUG] Invalid path value '{ path_value } ' for protocol { proto .name } " )
137
127
raise exceptions .StringParseError (
138
128
f"Invalid path value for protocol { proto .name } " ,
139
129
string ,
140
130
proto .name ,
141
131
exc
142
132
) from exc
143
133
else :
144
- print (f"[DEBUG] Protocol { proto .name } requires a value. Remaining: { sp } " )
145
134
# Skip empty elements for value
146
135
while sp and not sp [0 ]:
147
- print ("[DEBUG] Skipping empty element for value" )
148
136
sp .pop (0 )
149
137
if not sp :
150
- print (f"[DEBUG] Protocol { proto .name } requires address but none left" )
151
138
raise exceptions .StringParseError (
152
139
"Protocol requires address" ,
153
140
string ,
154
141
proto .name
155
142
)
156
143
next_elem = sp [0 ]
157
- print (f"[DEBUG] Next element for value: '{ next_elem } '" )
158
144
# First try to validate as value for current protocol
159
145
try :
160
146
codec .to_bytes (proto , next_elem )
161
147
value = sp .pop (0 )
162
- print (f"[DEBUG] Using value '{ value } ' for protocol { proto .name } " )
163
148
except Exception as exc :
164
149
# If value validation fails, check if it's a protocol name
165
150
if next_elem .isalnum ():
@@ -169,9 +154,6 @@ def string_iter(string: str) -> Generator[Tuple[Protocol, CodecBase, Optional[st
169
154
# If we have a protocol that requires a value and we're seeing
170
155
# another protocol,
171
156
# raise a StringParseError
172
- print (
173
- f"[DEBUG] Next element '{ next_elem } ' is a protocol name. Error!"
174
- )
175
157
raise exceptions .StringParseError (
176
158
f"Protocol { proto .name } requires a value" ,
177
159
string ,
@@ -180,7 +162,6 @@ def string_iter(string: str) -> Generator[Tuple[Protocol, CodecBase, Optional[st
180
162
)
181
163
except exceptions .ProtocolNotFoundError :
182
164
# If it's not a protocol name, raise the original value validation error
183
- print (f"[DEBUG] Invalid value '{ next_elem } ' for protocol { proto .name } " )
184
165
raise exceptions .StringParseError (
185
166
f"Invalid value for protocol { proto .name } " ,
186
167
string ,
@@ -189,7 +170,6 @@ def string_iter(string: str) -> Generator[Tuple[Protocol, CodecBase, Optional[st
189
170
) from exc
190
171
else :
191
172
# If it's not alphanumeric, raise the original value validation error
192
- print (f"[DEBUG] Invalid value '{ next_elem } ' for protocol { proto .name } " )
193
173
raise exceptions .StringParseError (
194
174
f"Invalid value for protocol { proto .name } " ,
195
175
string ,
0 commit comments