Ticket #3826 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

[with patch; positive review] Empty string in interact prints \x00

Reported by: slabbe Assigned to: itolkov
Priority: major Milestone: sage-3.1.2
Component: interact Keywords: interact empty string
Cc: saliola

Description

In the notebook of sage 3.0.6:

Write

@interact
def f(a=input_box(default='aaa',type=str,label='Your name :')):
    print a
    print [1,2,3,a]

Then, delete 'aaa' from the box. Press enter and the list prints like this :

[1, 2, 3, '\x00']

while should be :

[1, 2, 3, '']

Attachments

sage.patch (2.5 kB) - added by itolkov on 08/13/2008 02:05:08 PM.
trac3826-javascript-base64.patch (1.4 kB) - added by cwitty on 08/23/2008 11:22:13 AM.

Change History

08/12/2008 05:01:39 PM changed by mabshoff

  • owner changed from boothby to itolkov.
  • component changed from notebook to interact.

Reassigning the component to "interact" since I just created it.

Cheers,

Michael

08/13/2008 02:05:08 PM changed by itolkov

  • attachment sage.patch added.

08/13/2008 02:19:06 PM changed by itolkov

  • summary changed from Empty string in interact prints \x00 to [with patch; needs review] Empty string in interact prints \x00.
javascript: encode64("")

AA==

sage.server.notebook.interact.standard_b64decode("AA==")

'\x00'

My patch adds a check in the interact() function. However, encode64() and decode64() seem to be buggy. In particular, they are not inverses. For example,

javascript: encode64(decode64(""))

AAAA

08/23/2008 11:22:13 AM changed by cwitty

  • attachment trac3826-javascript-base64.patch added.

08/23/2008 11:24:03 AM changed by cwitty

Rather than working around the bug, it seems better to just fix the bug. My patch changes encode64 and decode64 to match the Python behavior (which I believe to be the correct behavior), where the empty string encodes/decodes to the empty string.

08/26/2008 06:09:02 PM changed by itolkov

  • summary changed from [with patch; needs review] Empty string in interact prints \x00 to [with patch; positive review] Empty string in interact prints \x00.

Seems to be working in the example above, as well as in my example.

+1

08/26/2008 06:15:47 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged in Sage 3.1.2.alpha1

08/26/2008 06:16:18 PM changed by mabshoff

PS: I merged *only* Carl's patch, i.e. trac3826-javascript-base64.patch