Sponsored Content
Full Discussion: Is this a Python 3.x.x bug?
Top Forums Programming Is this a Python 3.x.x bug? Post 302998783 by wisecracker on Wednesday 7th of June 2017 08:59:02 AM
Old 06-07-2017
Is this a Python 3.x.x bug?

Following my OSX bash bug discovery the other week what about this baby.

Just to let you guys know, since my post Sinclair Spectrum days where it was impossible to do a syntax error I do a great deal of syntax juggling to see what works on the few languages that I know, and I have done it for years, a form of hacking if you like......

I found this and mentioned it to someone I know on a python list.
NOTE: The help in the second code snippet. It seems that the string length is printed to sys.stderr .
The guy said it was part of the standard library in Version 3.x.x, NOT in Version 2.7.x and lower.

This IS actually in Python 3.x's standard library!? <Shock!>

I don't know about the latest Python 3.6.1 as I have not installed it yet.
The use of Python's exit function here is none standard but it does NOT give an error.
INSTEAD it gives a return code of the string length.
Surely this HAS to be a bug?
Code:
Last login: Wed Jun  7 13:16:13 on ttys000
AMIGA:amiga~> python3.5
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> help(sys.stdout.write)

>>> sys.stdout.write("Hello World!\n")
Hello World!
13
>>> exit(sys.stdout.write("Hello World!\n"))
Hello World!
AMIGA:amiga~> echo "$?"
13
AMIGA:amiga~> _

OUCH!
The help(sys.stdout.write) on python3.5.x
Code:
Help on built-in function write:

write(text, /) method of _io.TextIOWrapper instance
    Write string to stream.
    Returns the number of characters written (which is always equal to
    the length of the string).
(END)

Comments anyone?

EDIT:
OSX 10.12.5, default bash terminal running Python 3.5.2 in interactive mode.

Last edited by wisecracker; 06-07-2017 at 10:26 AM.. Reason: Give OS and bash bersion.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is it a bug ..?

Hi All, I am using Red Hat Linux on my servers. The problem that I am facing is, sometimes the /opt usage on the server shows used percentage as 100% , when actually it is simply 20%. When I reboot the system, it comes back to 20%.Is this a bug in the system or my settings have gone wrong... (1 Reply)
Discussion started by: nua7
1 Replies

2. AIX

bug in 43 ???

xxxxserver# lsattr -El inet0 | grep 255.240.0.0,32.224.0.0,32.78.120.254 | grep '.40' route net,-hopcount,1,-netmask,255.240.0.0,32.224.0.0,32.78.120.254 How this is possible? (1 Reply)
Discussion started by: itik
1 Replies

3. UNIX for Dummies Questions & Answers

where's the bug?

#!/bin/bash if then #echo "infinite loop" exit 0 fi when I run this file I get the following error: ./test_infinite_loop: line 5: syntax error near unexpected token `fi' ./test_infinite_loop: line 5: `fi' :confused: (4 Replies)
Discussion started by: jon80
4 Replies

4. SuSE

"ssh suse-server 'python -V' > python-version.out" not redirecting

Okay, so I have had this problem on openSUSE, and Debian systems now and I am hoping for a little help. I think it has something to do with Python but I couldn't find a proper Python area here. I am trying to redirect the output of "ssh suse-server 'python -V'" to a file. It seems that no matter... (3 Replies)
Discussion started by: Druonysus
3 Replies

5. Shell Programming and Scripting

**python** unable to read the background color in python

I am working on requirement on spreadsheet in python scripting. I have a spreadsheet containing cell values and with background color. I am able to read the value value but unable to get the background color of that particular cell. Actually my requirement is to read the cell value along... (1 Reply)
Discussion started by: giridhar276
1 Replies

6. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

7. Windows & DOS: Issues & Discussions

How to execute python script on remote with python way..?

Hi all, I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine.. Below is the code I am trying: #!/usr/bin/env python import wmi c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
Discussion started by: onenessboy
1 Replies

8. Programming

Create a C source and compile inside Python 1.4.0 to 3.7.0 in Python for ALL? platforms...

Hi all... As you know I like making code backwards compatible for as many platforms as possible. This Python script was in fact dedicated for the AMIGA A1200 using Pythons 1.4.0, 1.5.2, 1.6.0, 2.0.1, and 2.4.6 as that is all we have for varying levels of upgrades from a HDD and 4MB FastRam... (1 Reply)
Discussion started by: wisecracker
1 Replies
rzxtool(1)							     Emulators								rzxtool(1)

NAME
rzxtool - Modify Sinclair ZX Spectrum input recording files SYNOPSIS
rzxtool [-dblock number] [-eblock number,filename] [-iblock number,filename] [-u] rzxfile [outfile] DESCRIPTION
rzxtool allows some simple modifications to be made to Sinclair ZX Spectrum input recording files: blocks can be removed, snapshot data can be extracted or snapshots can be inserted into the file. The file can also be uncompressed. OPTIONS
-dblock number The block number specified will be deleted from the file. Block numbers start at zero and ignore any "creator information" blocks in the file. The modified file will be written to outfile. -eblock number,filename The snapshot in the specified block number will be written to the specified filename. All snapshot formats supported by libspec- trum(3) are available. -iblock number,filename The snapshot specified in filename will be added to the file at the position specified by block number. -u When outputting an RZX file, this option causes the input recording data to be output uncompressed; if this option is not given, the data will be compressed using zlib(3). rzxfile specifies an input recording file whose contents are to be modified. outfile specifies where the modified input file should be written. BUGS
None known SEE ALSO
fuse(1), fuse-utils(1), rzxcheck(1), rzxdump(1), zlib(3) The comp.sys.sinclair Spectrum FAQ, at http://www.worldofspectrum.org/faq/index.html. AUTHOR
Philip Kendall (philip-fuse@shadowmagic.org.uk). Version 1.0.0 16th December, 2010 rzxtool(1)
All times are GMT -4. The time now is 10:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy