Re: Help to debug my free library

2018-01-31 Thread Rustom Mody
On Thursday, February 1, 2018 at 1:11:50 AM UTC+5:30, Victor Porton wrote:
> wxjmfauth wrote:
> 
> > Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
> >> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
> >> > LibComCom is a C library which passes a string as stdin of an OS
> >> > command and stores its stdout in another string.
> >> 
> >> Something like the built-in subprocess module does?
> >> 
> >> ChrisA
> > 
> > Do you mean the buggy subprocess module (coding of characters) ?
> > Yes, there is a working workaround : QtCore.QProcess().
> 
> Please elaborate: which bugs it has? in which versions?
> 

jmf is a pillar of the community who runs a campaign for equity and justice

In particular that a $ costs just 0x24  (6 significant bits)
whereas a € costs 0x20AC (14 bits) and (3 bytes in UTF-8 n0xE2 0x82 0xAC)
is highly unacceptable to him and he is taking it up with the UN.

We must heartily support him in this noble endeavour

[And when you get a chance to get your word in edgeways do ask him what this
has to do with python]


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Victor Porton
Dennis Lee Bieber wrote:

> On Wed, 31 Jan 2018 20:58:56 +0200, Victor Porton 
> declaimed the following:
> 
>>LibComCom is a C library which passes a string as stdin of an OS command
>>and stores its stdout in another string.
>>
>>I wrote this library recently:
>>https://github.com/vporton/libcomcom
>>
>>Complete docs are available at
>>https://vporton.github.io/libcomcom-docs/
>>
>>Now I am trying to make Python bindings to the library:
>>https://github.com/vporton/libcomcom-python
>>
> 
> Debug -- no help, I'm not a fluent Linux programmer...
> 
> But based upon the description of this library, I would have to ask:
> 
> "What does this library provide that isn't already in the Python standard
> library?"
> 
> "Why would I want to use this library instead of, say
> subprocess.Popen().communicate()?" (or the older Popen* family)
> 
> {Though .communicate() is a one-shot call -- sends one packet to
> subprocess' stdin, reads to EOF, and waits for subprocess to terminate. If
> one needs interactive control, one needs explicit write/read calls,
> although those can deadlock if the caller and subprocess aren't written
> for such interaction}

If it "sends one packet", this would lead to a deadlock (even for "cat" 
command). Hopefully, you are wrong here.

I found that Popen.communicate() seems to solve my problem. (Previously I 
programmed in Java and found no native solution. For this reason I created 
my LibComCom.)

-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 9:31 AM, alister via Python-list
 wrote:
> On Thu, 01 Feb 2018 06:48:03 +1100, Chris Angelico wrote:
>
>> On Thu, Feb 1, 2018 at 6:41 AM, Victor Porton  wrote:
>>> wxjmfa...@gmail.com wrote:
>>>
 Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton 
> wrote:
> > LibComCom is a C library which passes a string as stdin of an OS
> > command and stores its stdout in another string.
>
> Something like the built-in subprocess module does?
>
> ChrisA

 Do you mean the buggy subprocess module (coding of characters) ?
>>>
>>> Please elaborate: which bugs it has? in which versions?
>>>
 Yes, there is a working workaround : QtCore.QProcess().
>>
>> Ignore jmf, he wouldn't know a bug if he were eating it for dinner. His
>> posts are blocked on the mailing list, and you'd do well to just plonk
>> him in your newsreader.
>>
>> ChrisA
>
>
> I disagree jmf's posts are worth reading, if you find yourself agreeing
> with him you know you have got something wrong.
>

Heh. That would be useful if he ever actually posted anything other
than "Python is buggy". I'm pretty sure I've already read everything
he actually has to say.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread alister via Python-list
On Thu, 01 Feb 2018 06:48:03 +1100, Chris Angelico wrote:

> On Thu, Feb 1, 2018 at 6:41 AM, Victor Porton  wrote:
>> wxjmfa...@gmail.com wrote:
>>
>>> Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
 On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton 
 wrote:
 > LibComCom is a C library which passes a string as stdin of an OS
 > command and stores its stdout in another string.

 Something like the built-in subprocess module does?

 ChrisA
>>>
>>> Do you mean the buggy subprocess module (coding of characters) ?
>>
>> Please elaborate: which bugs it has? in which versions?
>>
>>> Yes, there is a working workaround : QtCore.QProcess().
> 
> Ignore jmf, he wouldn't know a bug if he were eating it for dinner. His
> posts are blocked on the mailing list, and you'd do well to just plonk
> him in your newsreader.
> 
> ChrisA


I disagree jmf's posts are worth reading, if you find yourself agreeing 
with him you know you have got something wrong.


-- 
Bernard Shaw is an excellent man; he has not an enemy in the world, and
none of his friends like him either.
-- Oscar Wilde
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread breamoreboy
On Wednesday, January 31, 2018 at 7:41:50 PM UTC, Victor Porton wrote:
> wxjmfa...@gmail.com wrote:
> 
> > Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
> >> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton wrote:
> >> > LibComCom is a C library which passes a string as stdin of an OS
> >> > command and stores its stdout in another string.
> >> 
> >> Something like the built-in subprocess module does?
> >> 
> >> ChrisA
> > 
> > Do you mean the buggy subprocess module (coding of characters) ?
> 
> Please elaborate: which bugs it has? in which versions?
> 
> > Yes, there is a working workaround : QtCore.QProcess().
> -- 
> Victor Porton - http://portonvictor.org

You've now met the RUE, the Resident Unicode Expert.  For years he's been 
stating that the Python 3 Flexible String Representation is buggy, to the 
extent that Python 3.6.2 is unusable on Windows.  Strangely he cannot produce a 
shred of evidence to support his case so feel free to ignore him.

--
Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 6:41 AM, Victor Porton  wrote:
> wxjmfa...@gmail.com wrote:
>
>> Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
>>> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
>>> > LibComCom is a C library which passes a string as stdin of an OS
>>> > command and stores its stdout in another string.
>>>
>>> Something like the built-in subprocess module does?
>>>
>>> ChrisA
>>
>> Do you mean the buggy subprocess module (coding of characters) ?
>
> Please elaborate: which bugs it has? in which versions?
>
>> Yes, there is a working workaround : QtCore.QProcess().

Ignore jmf, he wouldn't know a bug if he were eating it for dinner.
His posts are blocked on the mailing list, and you'd do well to just
plonk him in your newsreader.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 6:26 AM, Victor Porton  wrote:
> Chris Angelico wrote:
>
>> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
>>> LibComCom is a C library which passes a string as stdin of an OS command
>>> and stores its stdout in another string.
>>
>> Something like the built-in subprocess module does?
>
> I was going to write: "It seems that subprocess module can cause deadlocks.
> For example, if it first writes a long string to "cat" command input (going
> to read cat's stdout later), then "cat" would block because its output is
> not read while writing input."
>
> But after reading the docs it seems that Popen.communicate() does the job.
>
> Well, I first wrote in Java. For Java there was no ready solution. Later I
> switched to Python and haven't checked the standard libraries.
>
> So, please help me to make sure if Popen.communicate() is a solution for my
> problem (namely that it does not deadlock, as in "cat" example above).
>
> I am interested in both Python 2.7 and 3.x.

I believe communicate() is indeed safe for this. It does retain all
data in memory, so with arbitrarily large output it may be better to
use a pipe and read from it progressively (similarly if the program's
going to run for a long time; communicate() will wait for the process
to terminate before giving you any output), but it won't just
deadlock.

Even if what you want can't be done with communicate(), I would
definitely recommend looking at the subprocess module. Worst case, you
do in Python what your C library is doing: create pipes to communicate
with the process. It's a lot easier in Python than in C, but the logic
would be similar.

Bonus: subprocess is available on all supported platforms (most
notably Windows and POSIX, which are drastically different; there are
a handful of Windows-only or Unix-only features, but the core is all
identical, despite the implementation differing), and you can still
support 2.7, although you have to forego the new and improved API in
Python 3.5+.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Victor Porton
wxjmfa...@gmail.com wrote:

> Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
>> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
>> > LibComCom is a C library which passes a string as stdin of an OS
>> > command and stores its stdout in another string.
>> 
>> Something like the built-in subprocess module does?
>> 
>> ChrisA
> 
> Do you mean the buggy subprocess module (coding of characters) ?

Please elaborate: which bugs it has? in which versions?

> Yes, there is a working workaround : QtCore.QProcess().
-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Victor Porton
Chris Angelico wrote:

> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
>> LibComCom is a C library which passes a string as stdin of an OS command
>> and stores its stdout in another string.
> 
> Something like the built-in subprocess module does?

I was going to write: "It seems that subprocess module can cause deadlocks. 
For example, if it first writes a long string to "cat" command input (going 
to read cat's stdout later), then "cat" would block because its output is 
not read while writing input."

But after reading the docs it seems that Popen.communicate() does the job.

Well, I first wrote in Java. For Java there was no ready solution. Later I 
switched to Python and haven't checked the standard libraries.

So, please help me to make sure if Popen.communicate() is a solution for my 
problem (namely that it does not deadlock, as in "cat" example above).

I am interested in both Python 2.7 and 3.x.

> ChrisA

-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Chris Angelico
On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
> LibComCom is a C library which passes a string as stdin of an OS command and
> stores its stdout in another string.

Something like the built-in subprocess module does?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Help to debug my free library

2018-01-31 Thread Victor Porton
LibComCom is a C library which passes a string as stdin of an OS command and 
stores its stdout in another string.

I wrote this library recently:
https://github.com/vporton/libcomcom

Complete docs are available at
https://vporton.github.io/libcomcom-docs/

Now I am trying to make Python bindings to the library:
https://github.com/vporton/libcomcom-python

I use CFFI (API level).

However testing my Python bindings segfaults in an unknown reason. Please 
help to debug the following:

$ LD_LIBRARY_PATH=.:/usr/local/lib:/usr/lib:/lib \
  PYTHONPATH=build/lib.linux-x86_64-2.7/ python test2.py 
Traceback (most recent call last):
Segmentation fault

(here libcomcom.so is installed in /usr/local/lib)

-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list