bugGNU TeXmacs - Bugs: bug #64154, *UnboundLocalError* Occured when...


You are not allowed to post comments on this tracker with your current authentication level.

bug #64154: *UnboundLocalError* Occured when passing the *raw PostScript* of type str to *ps_out*

Submitter:  juntong <ohitworks>
Submitted:  Fri 05 May 2023 04:13:42 PM UTC
Category:  Plugins Priority:  5 - Normal
Item Group:  Cleanup Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  None Release:  all
Fixed Release:  None Fixed Release: 

Fri 05 May 2023 04:13:42 PM UTC, original submission:  

Hello. The error occurs when I insert into the file a script of type Folded->Executable->Python to generate the picture.

Here is the code:

  import schemdraw

  import schemdraw.elements as elm

  d = schemdraw.Drawing()

  d += elm.Resistor().label('100K\<Omega\>')

  d += elm.Capacitor().down().label('0.1\<mu\>F', loc='bottom')

  d += elm.Line().left()

  d += elm.Ground()

  d += elm.SourceV().up().label('10V')


  bit = d.draw(show=False).getimage('eps')



I successfully fixed it by edit `postscript.py` and `protocol.py` in `plugins/tmpy`. I attached the .diff files in this report.

In `plugins/tmpy/postscript.py`, line 83, code should not enter the `for loop` when the out.find('\n') > 0 is True.
In `plugins/tmpy/protocol.py`, line 37, because the change abosve, data maybe a str type value, so add code to encode it before reture.

By the way, bytes can be added as a supported data type. It is useful in many third-party Python packages.

juntong <ohitworks>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #54705:  postscript_py.diff added by ohitworks (822B - application/octet-stream)
file #54706:  protocol_py.diff added by ohitworks (170B - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ohitworks (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-05-05 ohitworks Attached File- Added postscript_py.diff, #54705
        Attached File- Added protocol_py.diff, #54706

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code