Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String termination on Linux #59224

Closed
jjanis mannequin opened this issue Jun 6, 2012 · 5 comments
Closed

String termination on Linux #59224

jjanis mannequin opened this issue Jun 6, 2012 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@jjanis
Copy link
Mannequin

jjanis mannequin commented Jun 6, 2012

BPO 15019
Nosy @birkenfeld, @terryjreedy, @amauryfa, @ezio-melotti, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-03-28.10:08:29.126>
created_at = <Date 2012-06-06.14:47:44.729>
labels = ['interpreter-core', 'type-bug']
title = 'String termination on Linux'
updated_at = <Date 2013-03-28.10:08:29.124>
user = 'https://bugs.python.org/jjanis'

bugs.python.org fields:

activity = <Date 2013-03-28.10:08:29.124>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2013-03-28.10:08:29.126>
closer = 'georg.brandl'
components = ['Interpreter Core']
creation = <Date 2012-06-06.14:47:44.729>
creator = 'jjanis'
dependencies = []
files = []
hgrepos = []
issue_num = 15019
keywords = []
message_count = 5.0
messages = ['162413', '162414', '162538', '162902', '185416']
nosy_count = 6.0
nosy_names = ['georg.brandl', 'terry.reedy', 'amaury.forgeotdarc', 'ezio.melotti', 'r.david.murray', 'jjanis']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue15019'
versions = ['Python 2.7']

@jjanis
Copy link
Mannequin Author

jjanis mannequin commented Jun 6, 2012

test = "Hi there :)"
    print len(test), test // Prints "11 Hi there :)"
    test = test.replace(" ", "\x00")
    print len(test), test // Prints "11 

On Windows '\x00' is same as ' ', but on linux string is terminated at first occurance of '\x00'. Results on problems with pySerial and binary data, so I can't replace '\x00' with ' '.

@jjanis jjanis mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 6, 2012
@bitdancer
Copy link
Member

Windows makes \x00 a space? How odd.

This is the result for me on linux:

Python 2.7.3+ (2.7:1f5d2642929a, May 25 2012, 12:47:34) 
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> test = "Hi there :)"
>>> print len(test), test
11 Hi there :)
>>> test = test.replace(" ", "\x00")
>>> print len(test), test
11 Hithere:)

Your comment on the last line of your example seems to have been truncated, so I'm not sure what you really saw.

@terryjreedy
Copy link
Member

Jānis, please present examples as proper python -- indentation and comment char -- so others can copy/paste to run without editing.
In Idle (tkinter -- tk), '\0' is displayed as a wider space than ' '. The console is fixed pitch, so it cannot do that.

I suspect that the response of a window to \0 is window system dependent and probably out of our control. If so, this issue should be closed.

@terryjreedy terryjreedy changed the title Sting termination on Linux String termination on Linux Jun 8, 2012
@amauryfa
Copy link
Member

Jānis:

Prints "11

This is not what I get on Linux: I see "11 Hithere:)" because the console chooses to not print the \x00. The character is present in the output stream though.

Did you really got a truncated output? How did you run the above script?

@birkenfeld
Copy link
Member

Closing due to lack of response.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants