KenKundert / psf_utils

Read Spectre PSF files
49 stars 14 forks source link

illegal character '"' #7

Closed dan-zilla closed 2 years ago

dan-zilla commented 2 years ago

I have converted a psf file to ascii using the psf utility as described in the readme. However, I am still not able to read the file. The error I am getting is below. I am attaching the psf file as well. psf.zip

Generating LALR tables
ipykernel_launcher.py error:
    /nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii(172): illegal character '"'.
        "net4\<0\>" "V"
        ^
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "/home/danvilla/.local/lib/python3.9/site-packages/psf_utils/psf.py", line 80, in __init__
    sections = parser.parse(filename, content)
  File "/home/danvilla/.local/lib/python3.9/site-packages/psf_utils/parse.py", line 486, in parse
    result = self.parser.parse(content, tracking=False, lexer=self.lexer)
  File "/home/danvilla/.local/lib/python3.9/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/home/danvilla/.local/lib/python3.9/site-packages/ply/yacc.py", line 1063, in parseopt_notrack
    lookahead = get_token()     # Get the next token
  File "/home/danvilla/.local/lib/python3.9/site-packages/ply/lex.py", line 386, in token
    newtok = self.lexerrorf(tok)
  File "/home/danvilla/.local/lib/python3.9/site-packages/psf_utils/parse.py", line 167, in t_error
    raise ParseError("illegal character '%s'." % c, loc)
psf_utils.parse.ParseError: /nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii(172): illegal character '"'.
    "net4\<0\>" "V"
    ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/ipykernel_3069086/3652989650.py", line 10, in <module>
    psf = PSF('/nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii')
  File "/home/danvilla/.local/lib/python3.9/site-packages/psf_utils/psf.py", line 82, in __init__
    raise Error(str(e))
inform.inform.Error: /nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii(172): illegal character '"'.
    "net4\<0\>" "V"
    ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/tmp/ipykernel_3069086/3652989650.py", line 17, in <module>
    e.terminate()
  File "/home/danvilla/.local/lib/python3.9/site-packages/inform/inform.py", line 3101, in terminate
    fatal(*self.args, **kwargs)
  File "/home/danvilla/.local/lib/python3.9/site-packages/inform/inform.py", line 1944, in __call__
    INFORMER._report(args, kwargs, self)
  File "/home/danvilla/.local/lib/python3.9/site-packages/inform/inform.py", line 2485, in _report
    self.terminate(status=action.terminate)
  File "/home/danvilla/.local/lib/python3.9/site-packages/inform/inform.py", line 2619, in terminate
    raise SystemExit(status)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 1101, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 248, in wrapped
    return f(*args, **kwargs)
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/home/danvilla/local/anaconda3/envs/spectre/lib/python3.9/inspect.py", line 1541, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'

---------------------------------------------------------------------------
ParseError                                Traceback (most recent call last)
~/.local/lib/python3.9/site-packages/psf_utils/psf.py in __init__(self, filename, sep, use_cache, update_cache)
     79             content = psf_filepath.read_text()
---> 80             sections = parser.parse(filename, content)
     81         except ParseError as e:

~/.local/lib/python3.9/site-packages/psf_utils/parse.py in parse(self, filename, content)
    485 
--> 486         result = self.parser.parse(content, tracking=False, lexer=self.lexer)
    487         return result

~/.local/lib/python3.9/site-packages/ply/yacc.py in parse(self, input, lexer, debug, tracking, tokenfunc)
    332         else:
--> 333             return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
    334 

~/.local/lib/python3.9/site-packages/ply/yacc.py in parseopt_notrack(self, input, lexer, debug, tracking, tokenfunc)
   1062                     if not lookaheadstack:
-> 1063                         lookahead = get_token()     # Get the next token
   1064                     else:

~/.local/lib/python3.9/site-packages/ply/lex.py in token(self)
    385                     self.lexpos = lexpos
--> 386                     newtok = self.lexerrorf(tok)
    387                     if lexpos == self.lexpos:

~/.local/lib/python3.9/site-packages/psf_utils/parse.py in t_error(t)
    166     t.lexer.skip(1)
--> 167     raise ParseError("illegal character '%s'." % c, loc)
    168 

ParseError: /nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii(172): illegal character '"'.
    "net4\<0\>" "V"
    ^

During handling of the above exception, another exception occurred:

Error                                     Traceback (most recent call last)
/tmp/ipykernel_3069086/3652989650.py in <module>
      9 try:
---> 10     psf = PSF('/nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii')
     11 

~/.local/lib/python3.9/site-packages/psf_utils/psf.py in __init__(self, filename, sep, use_cache, update_cache)
     81         except ParseError as e:
---> 82             raise Error(str(e))
     83         except OSError as e:

Error: /nfs/regress_04_snc/analog/danvilla/simulation/adc12b_starter/spectre/schematic/psf/tran.psfascii(172): illegal character '"'.
    "net4\<0\>" "V"
    ^

During handling of the above exception, another exception occurred:

SystemExit                                Traceback (most recent call last)
    [... skipping hidden 1 frame]

/tmp/ipykernel_3069086/3652989650.py in <module>
     16 except Error as e:
---> 17     e.terminate()

~/.local/lib/python3.9/site-packages/inform/inform.py in terminate(self, **new_kwargs)
   3100             kwargs = self.kwargs
-> 3101         fatal(*self.args, **kwargs)
   3102 

~/.local/lib/python3.9/site-packages/inform/inform.py in __call__(self, *args, **kwargs)
   1943     def __call__(self, *args, **kwargs):
-> 1944         INFORMER._report(args, kwargs, self)
   1945 

~/.local/lib/python3.9/site-packages/inform/inform.py in _report(self, args, kwargs, action)
   2484         if action.terminate is not False:
-> 2485             self.terminate(status=action.terminate)
   2486         self.previous_action = action

~/.local/lib/python3.9/site-packages/inform/inform.py in terminate(self, status, exit)
   2618         if exit:
-> 2619             raise SystemExit(status)
   2620         else:

SystemExit: 1

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
    [... skipping hidden 1 frame]

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
   2052                     stb = ['An exception has occurred, use %tb to see '
   2053                            'the full traceback.\n']
-> 2054                     stb.extend(self.InteractiveTB.get_exception_only(etype,
   2055                                                                      value))
   2056                 else:

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in get_exception_only(self, etype, value)
    752         value : exception value
    753         """
--> 754         return ListTB.structured_traceback(self, etype, value)
    755 
    756     def show_exception_only(self, etype, evalue):

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
    627             chained_exceptions_tb_offset = 0
    628             out_list = (
--> 629                 self.structured_traceback(
    630                     etype, evalue, (etb, chained_exc_ids),
    631                     chained_exceptions_tb_offset, context)

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1365         else:
   1366             self.tb = tb
-> 1367         return FormattedTB.structured_traceback(
   1368             self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1369 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1265         if mode in self.verbose_modes:
   1266             # Verbose modes need a full traceback
-> 1267             return VerboseTB.structured_traceback(
   1268                 self, etype, value, tb, tb_offset, number_of_lines_of_context
   1269             )

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
   1122         """Return a nice text document describing the traceback."""
   1123 
-> 1124         formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
   1125                                                                tb_offset)
   1126 

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
   1080 
   1081 
-> 1082         last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
   1083 
   1084         frames = self.format_records(records, last_unique, recursion_repeat)

~/local/anaconda3/envs/spectre/lib/python3.9/site-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
    380     # first frame (from in to out) that looks different.
    381     if not is_recursion_error(etype, value, records):
--> 382         return len(records), 0
    383 
    384     # Select filename, lineno, func_name to track frames with

TypeError: object of type 'NoneType' has no len()
KenKundert commented 2 years ago

I think I have fixed the issue. Can you pull the latest version (1.3.1) from github and try it.

dan-zilla commented 2 years ago

It works for me now. Thanks for providing and supporting this tool!

KenKundert commented 2 years ago

I have updated pypi. Thanks for your help.