Re: right list for SIGABRT python binary question ?

2017-10-21 Thread dieter
Karsten Hilbert  writes:
> ...
> So here's the final console output of that:
> ...
>   Debug memory block at address p=0x717b7c: API ''
>   0 bytes originally requested
>   The 3 pad bytes at p-3 are not all FORBIDDENBYTE (0xfb):
>   at p-3: 0x03 *** OUCH
>   at p-2: 0x4e *** OUCH
>   at p-1: 0x00 *** OUCH
>   Because memory is corrupted at the start, the count of bytes 
> requested
>  may be bogus, and checking the trailing pad bytes may segfault.
>   The 4 pad bytes at tail=0x717b7c are not all FORBIDDENBYTE (0xfb):
>   at tail+0: 0x00 *** OUCH
>   at tail+1: 0x00 *** OUCH
>   at tail+2: 0x00 *** OUCH
>   at tail+3: 0x00 *** OUCH
>   The block was made by call #0 to debug malloc/realloc.
>   Fatal Python error: bad ID: Allocated using API '', verified using API 
> 'o'
> ...
> Can anyone give more guidance on what the above python debug
> output might vaguely point to ?

It points to a memory corruption.

I would approach the problem by means of debugging: put a write
breakpoint at the corrupted address "0x717b7c" and check what part
of the system accesses it (this assumes you are using a CPU
supporting write breakpoints).
It may be very tedious as the address might be accessed very often
legally before it gets corrupted.

Another approach may be to use a tool designed for memory debugging,
e.g. "valgrind".

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


Re: grapheme cluster library

2017-10-21 Thread Rustom Mody
On Saturday, October 21, 2017 at 11:51:57 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Oct 21, 2017 at 3:25 PM, Stefan Ram wrote:
> > Rustom Mody  writes:
> >>Is there a recommended library for manipulating grapheme clusters?
> >
> >   The Python Library has a module "unicodedata", with functions like:
> >
> > |unicodedata.normalize( form, unistr )
> > |
> > |Returns the normal form »form« for the Unicode string »unistr«.
> > |Valid values for »form« are »NFC«, »NFKC«, »NFD«, and »NFKD«.
> >
> >   . I don't know whether the transformation you are looking for
> >   is one of those.
> 
> No, that's at a lower level than grapheme clusters.
> 
> Rustom, have you looked on PyPI? There are a couple of hits, including
> one simply called "grapheme".

There is this one line solution using regex (or 2 char solution!)
Not perfect but a good start

>>> from regex import findall
>>> veda="""ॐ पूर्णमदः पूर्णमिदं पूर्णात्पुर्णमुदच्यते
पूर्णस्य पूर्णमादाय पूर्णमेवावशिष्यते ॥
ॐ शान्तिः शान्तिः शान्तिः ॥"""

>>> findall(r'\X', veda)
['ॐ', ' ', 'पू', 'र्', 'ण', 'म', 'दः', ' ', 'पू', 'र्', 'ण', 'मि', 'दं', ' ', 
'पू', 'र्', 'णा', 'त्', 'पु', 'र्', 'ण', 'मु', 'द', 'च्', 'य', 'ते', '\n', 
'पू', 'र्', 'ण', 'स्', 'य', ' ', 'पू', 'र्', 'ण', 'मा', 'दा', 'य', ' ', 'पू', 
'र्', 'ण', 'मे', 'वा', 'व', 'शि', 'ष्', 'य', 'ते', ' ', '॥', '\n', 'ॐ', ' ', 
'शा', 'न्', 'तिः', ' ', 'शा', 'न्', 'तिः', ' ', 'शा', 'न्', 'तिः', ' ', '॥']
>>> 

Compare

>>> [x for x in veda]
['ॐ', ' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'द', 'ः', ' ', 'प', 'ू', 'र', '्', 
'ण', 'म', 'ि', 'द', 'ं', ' ', 'प', 'ू', 'र', '्', 'ण', 'ा', 'त', '्', 'प', 'ु', 
'र', '्', 'ण', 'म', 'ु', 'द', 'च', '्', 'य', 'त', 'े', '\n', 'प', 'ू', 'र', 
'्', 'ण', 'स', '्', 'य', ' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'ा', 'द', 'ा', 'य', 
' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'े', 'व', 'ा', 'व', 'श', 'ि', 'ष', '्', 'य', 
'त', 'े', ' ', '॥', '\n', 'ॐ', ' ', 'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 
'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 
'॥']

What is not working are the vowel-less consonant-joins: 
ie ... 'र्', 'ण' ... 
[3,4 element of the findall]
should be one 'र्ण'

But its good enough for me for now I think

PS Stefan I dont see your responses unless someone quotes them. Thanks anyway 
for the inputs
-- 
https://mail.python.org/mailman/listinfo/python-list


Sandsifter software finds hidden instructions inside processors.

2017-10-21 Thread skybuck2000
Hello,

I just watched this video, it's pretty interesting and somewhat amazing, this 
guy find a way to find hidden instructions inside processors:

https://www.youtube.com/watch?v=KrksBdWcZgQ

The software which finds these hidden instructions is available too:

https://github.com/xoreaxeaxeax/sandsifter

Apperently it's open source python and a little bit of C.

It will probably require some kind of python interpreter/executor and probably 
admin rights to run.

I am not yet sure how to run this software it will require installing some 
additional capstone disassembler.

I am curious what would be found on my AMD X2 3800+ from almost 12 years ago... 
if it will run at all... I think it will run.

I would be curious to also here results of other people ! ;)

So if you curious as to what secret instructions exist inside your computer 
give this a run.

Later today or in the coming days when I have some time for this I will return 
to 
this subject.

For now I may have other things to do or maybe not :P :)

Bye,
  Skybuck =D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application and package of the same name

2017-10-21 Thread David Stanek
On 19-Oct 19:34, Paul Moore wrote:
> On 19 October 2017 at 19:18, Skip Montanaro  wrote:
> >
> > This is in Python 2.7, FWIW. What am I missing?
> 
> My immediate reaction is "you shouldn't name your main program and
> your package the same". It's not a pattern I've seen commonly used.
> 

This is actually a common pattern I see when teaching the language. For
example, when a student wants to test out a package like requests many
seem to initially want to create a requests.py module. Then they become
very confused when they get an AttributeError on requests.get().

-- 
david stanek
web: https://dstanek.com
twitter: https://twitter.com/dstanek
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application and package of the same name

2017-10-21 Thread Skip Montanaro
This is actually a common pattern I see when teaching the language. For
example, when a student wants to test out a package like requests many
seem to initially want to create a requests.py module. Then they become
very confused when they get an AttributeError on requests.get().


That I should fall prey to this after using Python for over 20 years...
Should I be humbled, ashamed, delighted that I unwittingly demonstrated
something I've seen in others' code?

The sequence of events here was that I actually did have my main program
inside the package, but wanted to separate the two, since the package is
installed for clients of the allocation to use. As I was moving the
application into a Docker environment, it made sense to extract the main
program from the package and copy it separately into the image. I just git
mv'd the file from the package directory to the scripts directory, and it
stopped working. I should have realized right then and there what I'd done
wrong, but I got hung up thinking I'd done something wrong with absolute
imports.

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


Re: grapheme cluster library

2017-10-21 Thread MRAB

On 2017-10-21 05:11, Rustom Mody wrote:

Is there a recommended library for manipulating grapheme clusters?

In particular, in devanagari
क् + ि = कि
in (pseudo)unicode names
KA-letter + I-sign = KI-composite-letter

I would like to be able to handle KI as a letter rather than two code-points.
Can of course write an automaton to group but guessing that its already
available some place…


You can use the regex module to split a string into graphemes:

regex.findall(r'\X', string)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application and package of the same name

2017-10-21 Thread Christopher Reimer
On Oct 21, 2017, at 6:08 AM, David Stanek  wrote:

> This is actually a common pattern I see when teaching the language. For
> example, when a student wants to test out a package like requests many
> seem to initially want to create a requests.py module. Then they become
> very confused when they get an AttributeError on requests.get().

For my web scraper program, I'm using "requestor.py" for requests. :)

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


Re: right list for SIGABRT python binary question ?

2017-10-21 Thread M.-A. Lemburg
On 17.10.2017 09:30, Karsten Hilbert wrote:
> On Tue, Oct 17, 2017 at 12:04:09PM +1100, Steve D'Aprano wrote:
> 
>>> is this the right list to ask for help in debugging a
>>> SIGABORT (?) happening on shutdown of a Python 2.7 script ?
>>>
>>> If not, which one is ?
>>
>> You should try here first.
>>
>> Please ensure you read and follow this first:
>>
>> http://sscce.org/
>>
>> and post a *minimum* example of your code. (Sorry for the redundant
>> instructions if you already know this, but you would be surprised how many
>> people don't.)
> 
> Thanks. I'll work towards a postable example.
> 
> Running a debug build of py27 gave me a first lead: this
> Debian system (Testing, upgraded all the way from various
> releases ago) carries an incompatible mxDateTime which I'll
> take care of.
> 
>   *** You don't have the (right) mxDateTime binaries installed !
>   Traceback (most recent call last):
> File "./bootstrap_gm_db_system.py", line 87, in 
>   from Gnumed.pycommon import gmCfg2, gmPsql, gmPG2, gmTools, gmI18N
> File 
> "/home/ncq/Projekte/gm-git/gnumed/gnumed/Gnumed/pycommon/gmPG2.py", line 34, 
> in 
>   from Gnumed.pycommon import gmDateTime
> File 
> "/home/ncq/Projekte/gm-git/gnumed/gnumed/Gnumed/pycommon/gmDateTime.py", line 
> 52, in 
>   import mx.DateTime as mxDT
> File "/usr/lib/python2.7/dist-packages/mx/DateTime/__init__.py", line 
> 8, in 
>   from DateTime import *
> File "/usr/lib/python2.7/dist-packages/mx/DateTime/DateTime.py", line 
> 9, in 
>   from mxDateTime import *
> File 
> "/usr/lib/python2.7/dist-packages/mx/DateTime/mxDateTime/__init__.py", line 
> 13, in 
>   raise ImportError, why
>   ImportError: 
> /usr/lib/python2.7/dist-packages/mx/DateTime/mxDateTime/mxDateTime.so: 
> undefined symbol: Py_InitModule4

This error suggests that you have 32- and 64-bit versions of
Python and mxDateTime mixed in your installation.

Py_InitModule4 is only available in the 32-bit build of
Python. With the 64-bit build, it's called Py_InitModule4_64.

Since you're getting the same error from faulthandler,
this is where I'd start to investigate.

"nm" will list all exported and required symbols. As first step,
you should probably check the python binary for its symbols and
see whether it exports Py_InitModule* symbols.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Oct 21 2017)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...   http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...   http://zope.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
  http://www.malemburg.com/

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


Re: grapheme cluster library

2017-10-21 Thread Rustom Mody
On Saturday, October 21, 2017 at 9:22:24 PM UTC+5:30, MRAB wrote:
> On 2017-10-21 05:11, Rustom Mody wrote:
> > Is there a recommended library for manipulating grapheme clusters?
> > 
> > In particular, in devanagari
> > क् + ि = कि
> > in (pseudo)unicode names
> > KA-letter + I-sign = KI-composite-letter
> > 
> > I would like to be able to handle KI as a letter rather than two 
> > code-points.
> > Can of course write an automaton to group but guessing that its already
> > available some place…
> > 
> You can use the regex module to split a string into graphemes:
> 
> regex.findall(r'\X', string)

Thanks MRAB
Yes as I said I discovered r'\X'
Ultimately my code was (effectively) one line!

print("".join(map[x] for x in findall(r'\X', l)))

with map being a few 100 elements of a dictionary such as
map = {
 ...
 'ॐ': "OM",
...
}

$ cat purnam-deva 
ॐ पूर्णमदः पूर्णमिदं पूर्णात्पुर्णमुदच्यते
पूर्णस्य पूर्णमादाय पूर्णमेवावशिष्यते ॥

$ ./devanagari2roman.py purnam-deva 
OM pUraNamadaH pUraNamidaM pUraNAtpuraNamudachyate
pUraNasya pUraNamAdAya pUraNamavAvashiShyate ..
OM shAntiH shAntiH shAntiH ..

Basically, an inversion of the itrans input method
https://en.wikipedia.org/wiki/ITRANS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to debug an unfired tkinter event?

2017-10-21 Thread jfong
Terry Reedy at 2017-10-20 UTC+8 AM 7:37:59 wrote:
> On 10/19/2017 5:07 AM, jf...@ms4.hinet.net wrote:
> 
> > I got some info below each time when I squeeze the table:
> > .
> > .5006
> > .5006.50712528
> > .5006.50712496
> > .5006.50712464
> > .5006.50712144
> > .5006.50712528.50712560.50782256
> > .5006.50712528.50712560.50782256.50783024
> > .5006.50712528.50712560.50782256
> > .5006.50712528.50712560.50782256.50783024
> > 
> > How to change these number(is it a widget ID?) to a meaning name?
> 
> The number strings as names are the defaults that came from tkinter, not 
> tcl/tk.  In 3.6, the default names were changed to be versions of the 
> class name.
> 
>  >>> import tkinter as tk
>  >>> r = tk.Tk()
>  >>> b = tk.Button(r)
>  >>> b
> 
>  >>> b2 = tk.Button(r)
>  >>> b2
> 
> 
I have a question about this change. When there are multiple buttons in the 
same widget hierarchy level and a ".xxx.yyy.!button2" showing up, how to figure 
out which button it means?

By the way, where is the document of this change? Now it doesn't fit the 
description in the "tkinter 8.5 reference manual" anymore.

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


Re: Save non-pickleable variable?

2017-10-21 Thread ROGER GRAYDON CHRISTMAN
On Sat, Oct 21, 2017, Israel Brewster wrote: >
tldr: I have an object that can't be picked. Is there any way to do a
>"raw" dump of the binary data to a file, and re-load it later?
>

>Details: I am using a java (I know, I know - this is a python list. I'm
>not asking about the java - honest!) library (Jasper Reports)
>that I access from python using py4j (www.py4j.org
>). At one point in my code I call a java
>function which, after churning on some data in a database, returns an object
>(a jasper report object populated with the final report data) that I
>can use (via another java call) to display the results in a variety
>of formats (HTML, PDF, XLS, etc). At the time I get the object back,
>I use it to display the results in HTML format for quick display, but the user
>may or may not also want to get a PDF copy in the near future. 
>
>Since it can take some time to generate this object, and also since the data
>may change between when I do the HTML display and when the user requests a PDF
>(if they do at all), I would like to save this object for potential
>future re-use. Because it might be large, and there is actually a fairly good
>chance the user won't need it again, I'd like to save it in a temp file
>(tat would be deleted when the user logs out) rather than in memory.
>Unfortunately, since this is an object created by and returned from a java
>function, not a native python object, it is not able to be pickled (as the
>suggestion typically is), at least to my knowledge.
>
>Given that, is there any way I can write out the "raw" binary data to
>a file, and read it back in later? Or some other way to be able to save this
>object? It is theoretically possible that I could do it on the java side, i.e.
>the library may have some way of writing out the file, but obviously I wouldn't
>expect anyone here to know anything about that - I'm just asking about the
>python side :-)
>
>

Since you suggest a file is a suitable medium, perhaps you can try the JSON
format
I have heard about (but never actually used myself).   Apparently there is
module
support for both Java and Python for this format, which is considered to be
language
independent.

And since the Python view of this data would be a Python data structure,
it should also be pickleable.

The "Json.org" web site should give you a place to download the modules
you would need for each of the two languages.  Hope this helps.

Roger Christman
Pennsylvania State University


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


Re: How to debug an unfired tkinter event?

2017-10-21 Thread Terry Reedy

On 10/21/2017 1:25 PM, jf...@ms4.hinet.net wrote:

Terry Reedy at 2017-10-20 UTC+8 AM 7:37:59 wrote:

On 10/19/2017 5:07 AM, jf...@ms4.hinet.net wrote:


I got some info below each time when I squeeze the table:
.
.5006
.5006.50712528
.5006.50712496
.5006.50712464
.5006.50712144
.5006.50712528.50712560.50782256
.5006.50712528.50712560.50782256.50783024
.5006.50712528.50712560.50782256
.5006.50712528.50712560.50782256.50783024

How to change these number(is it a widget ID?) to a meaning name?


The number strings as names are the defaults that came from tkinter, not
tcl/tk.  In 3.6, the default names were changed to be versions of the
class name.

  >>> import tkinter as tk
  >>> r = tk.Tk()
  >>> b = tk.Button(r)
  >>> b

  >>> b2 = tk.Button(r)
  >>> b2



I have a question about this change. When there are multiple buttons in the same widget 
hierarchy level and a ".xxx.yyy.!button2" showing up, how to figure out which 
button it means?


There is an issue about one particular situation with a name clash. 
This can always be avoided by providing explicit names at least at the leaf.



By the way, where is the document of this change?


What New in 3.6 should have something.


Now it doesn't fit the description in the "tkinter 8.5 reference manual" 
anymore.


If you mean the one at nmt.edu, it is not maintained and is slowly 
becoming out of date.  tcl/tk is now at 8.6.7 or .8.  'tkinter 8.5' is 
something of a misnomer because the tkinter version is the same as the 
Python version and tries to be somewhat up-to-date with tcl/tk, which 
being compatible with earlier tcl/tk versions.


--
Terry Jan Reedy

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


Re: grapheme cluster library

2017-10-21 Thread Steven D'Aprano
On Fri, 20 Oct 2017 21:11:02 -0700, Rustom Mody wrote:

> Is there a recommended library for manipulating grapheme clusters?

Back in July, I asked for anyone interested in grapheme clusters to 
consider checking out this issue on the bug tracker:

http://bugs.python.org/issue30717

My post received at least 170 replies from at least 16 unique people 
(including you, Rustom). As far as I can see, only two of those people 
actually registered on the tracker to follow that ticket.

>From time to time, there are repeated complaints that the Python standard 
library doesn't handle graphemes. Are those complaints mostly hot air, or 
is there actually community interest in having the stdlib deal with this?

If there is community interest, the best ways to register that interest 
are, in order (best to worst):

- step up and provide some code;

- make a concrete proposal (not just "support graphemes") on the 
  Python-Ideas mailing list;

- register a feature request on the tracker;

- complain about the lack of such support here;

- do nothing.



-- 
Steven D'Aprano
-- 
https://mail.python.org/mailman/listinfo/python-list