2222This module contains utilities that have been optimized in Cython 
2323""" 
2424
25- from  cpython.pystate cimport PyThreadState_SetAsyncExc
26- from  cpython.ref cimport PyObject
25+ import  cython 
26+ from  cython .cimports .cpython .pystate  import  PyThreadState_SetAsyncExc 
27+ from  cython .cimports .cpython .ref  import  PyObject 
2728from  ._signals  import  TerminateException 
2829
2930
30- def  url_directory_name (str  url ):
31+ def  url_directory_name (url :  str ):
3132    """Normalizes a url into a directory name 
3233
3334    Args: 
@@ -47,8 +48,8 @@ def url_directory_name(str url):
4748# Args: 
4849#   thread_id (int): the thread id in which to throw the exception 
4950# 
50- def  terminate_thread (long  thread_id ):
51-     res =  PyThreadState_SetAsyncExc(thread_id, < PyObject* >  TerminateException)
51+ def  terminate_thread (thread_id :  cython . long ):
52+     res  =  PyThreadState_SetAsyncExc (thread_id , cython . cast ( cython . pointer ( PyObject ),  TerminateException ) )
5253    assert  res  ==  1 
5354
5455
@@ -60,9 +61,9 @@ def terminate_thread(long thread_id):
6061# Returns: 
6162#    (bool): True if all characters are valid, False otherwise. 
6263# 
63- def  valid_chars_name (str  name ):
64-     cdef  int  char_value 
65-     cdef  int  forbidden_char 
64+ def  valid_chars_name (name :  str ):
65+     char_value :  cython . int 
66+     forbidden_char :  cython . int 
6667
6768    for  char_value  in  name :
6869        # 0-31 are control chars, 127 is DEL, and >127 means non-ASCII 
@@ -96,7 +97,7 @@ def valid_chars_name(str name):
9697# 
9798# This transforms the value to "_" if is it not a ascii letter, a digit or "%" or "_" 
9899# 
99- cdef Py_UNICODE  _transl(Py_UNICODE x) :
100+ def   _transl (x :  cython . Py_UNICODE )  ->   cython . Py_UNICODE :
100101    if  ("a"  <=  x  <=  "z" ) or  ("A"  <=  x  <=  "Z" ) or  ("0"  <=  x  <=  "9" ) or  x  ==  "%" :
101102        return  x 
102103    return  "_" 
0 commit comments