Skip to content

Commit b7be10d

Browse files
committed
removed nonlocal usage
1 parent 29a5af9 commit b7be10d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

py/selenium/webdriver/common/bidi/network.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,10 @@ def add_request_handler(self, callback, url_pattern=''):
144144
str: The request ID of the intercepted response.
145145
"""
146146
self.__add_intercept(phases=[self.PHASES['before_request']])
147-
request_id = None
148147
def callback_on_url_match(data):
149-
nonlocal request_id
150148
if url_pattern in data['request']['url']:
151149
# create request object to pass to callback
152-
request_id = data['request'].get('requestId', None)
150+
request_id = data['request'].get('requestId', uuid.uuid4())
153151
url = data['request'].get('url')
154152
method = data['request'].get('method')
155153
headers = data['request'].get('headers', {})
@@ -186,12 +184,10 @@ def add_response_handler(self, callback, url_pattern=''):
186184
str: The request ID of the intercepted response.
187185
"""
188186
self.__add_intercept(phases=[self.PHASES['response_started']])
189-
request_id = None
190187
def callback_on_url_match(data):
191188
# create response object to pass to callback
192-
nonlocal request_id
193189
if url_pattern in data['response']['url']:
194-
request_id = data['request'].get('requestId', None)
190+
request_id = data['request'].get('requestId', uuid.uuid4())
195191
url = data['response'].get('url')
196192
status_code = data['response'].get('status')
197193
body = data['response'].get('body', None)

0 commit comments

Comments
 (0)