PyThreadState_Get

2016-09-23 Thread Bharadwaj Srivatsa
Which ever project I am trying to install using python setup.py install 
command, i am getting the following error..



python -mtrace --trace setup.py install
Fatal Python error: PyThreadState_Get: no current thread
ABORT instruction (core dumped)

How to get rid of this error and whats the cause for this
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27298] redundant iteration over digits in _PyLong_AsUnsignedLongMask

2016-09-23 Thread Oren Milman

Changes by Oren Milman :


--
versions: +Python 3.7 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: h(re) for help, import re - on NameError

2016-09-23 Thread Chris Angelico
On Fri, Sep 23, 2016 at 4:40 PM, Peter Otten <__pete...@web.de> wrote:
> By the way, the current help() already loads a module if you pass its name
> as a string:
>

Yes, which is the basis of my alternate exec trick:

exec(tb.tb_frame.f_code, tb.tb_frame.f_globals, {n: n})

Basically it creates a new locals dict that just has (eg) re="re",
which allows help(re) to function as help("re").

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


[issue28253] calendar.prcal(9999) output has a problem

2016-09-23 Thread lijp

Changes by lijp :


Added file: http://bugs.python.org/file44788/20160923154147.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: h(re) for help, import re - on NameError

2016-09-23 Thread Peter Otten
Veek M wrote:

> Is there a way to use .pythonrc.py to provide a help function that
> autoloads whatever module name is passed like so:

By the way, the current help() already loads a module if you pass its name 
as a string:

$ echo 'print("importing foo")' >  foo.py
$ python3
Python 3.4.3 (default, Sep 14 2016, 12:36:27) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help("foo")
importing foo
Help on module foo:

NAME
foo

[snip]


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


[issue28253] calendar.prcal(9999) output has a problem

2016-09-23 Thread lijp

Changes by lijp :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
title: the reply's additional "Re:" -> calendar.prcal() output has a problem
type:  -> behavior
versions: +Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Pasting code into the cmdline interpreter

2016-09-23 Thread Gregory Ewing

eryk sun wrote:

if we see
a read that returns less than the buffer size but doesn't end on a
newline, then for a terminal, and only a terminal, I think we can
infer Ctrl+D was typed and handle it as EOF.


I don't think it would be wise to rely on that. There is
no promise that any given read() call will read all the
data that's available.

Even if it worked, I'm not sure that this behaviour would
be desirable. Some programs may rely on the current
behaviour, e.g. shells that do auto-completion when you
type ctrl-D on a non-empty line.

At the very least it would make programs written in
Python behave differently from any other unix program
when reading from a terminal, which I don't think is
a good idea.

--
Greg

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


[issue28254] Add C API for gc.enable, gc.disable, and gc.isenabled

2016-09-23 Thread Joe Jevnik

New submission from Joe Jevnik:

I was writing an extension module that was working with weakrefs and wanted to 
ensure that the GC would not run for a block of code. I noticed that 
gc.enable/gc.disable are not exposed to C and the state of the gc is in a 
static variable so it cannot be mutated from an extension.

This change adds an easier way to access this functionality in the C api 
without going through an import or PyObject_Call.

I am wondering where to document these functions as well as PyGC_Collect. I 
didn't see that function anywhere in the docs (and didn't know about it) so I 
would like to make them more visible. My first thought was 
Doc/c-api/gcsupport.rst but this is not in service of supporting the GC, it is 
about the state of the GC itself. If that seems like a decent place I could add 
a small section at the bottom about interacting with the GC and document these 
new functions and PyGC_Collect.

I'm sorry if this is exposed elsewhere. If it is I can try to add some links to 
i

--
components: Extension Modules
files: gc-capi.patch
keywords: patch
messages: 277245
nosy: ll
priority: normal
severity: normal
status: open
title: Add C API for gc.enable, gc.disable, and gc.isenabled
versions: Python 3.7
Added file: http://bugs.python.org/file44787/gc-capi.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: h(re) for help, import re - on NameError

2016-09-23 Thread Veek M
Chris Angelico wrote:

> On Thu, Sep 22, 2016 at 8:10 PM, Veek M  wrote:
>> Is there a way to use .pythonrc.py to provide a help function that
>> autoloads whatever module name is passed like so:
>> \>>> h(re)
>>
>> I tried inheriting site._Helper and overriding __init__ and __call__
>> but that didn't work, also I don't know how to deal/trap/catch the
>> NameError (no quotes on h(re)) - is there a way to insert a
>> try/except block around the >>> prompt?
>>
>> I hate having to: import whatever every-time i forget. Actually could
>> I ditch the () in h(re) and just do: h re - the joy of that :p
> 
> You could use sys.excepthook to catch the NameError. I don't know of a
> way to catch the SyntaxError and look at the original text, but with
> NameError it's pretty easy:
> 
> def excepthook(t,v,tb):
> if t is NameError:
> n = v.args[0].split("'")[1]
> globals()[n] = __import__(n)
> exec(tb.tb_frame.f_code, tb.tb_frame.f_globals)
> else:
> excepthook.old(t,v,tb)
> 
> import sys
> excepthook.old = sys.excepthook
> sys.excepthook = excepthook
> 
> Paste that into interactive Python and give it a try. Be aware that
> it'll attempt to import *any* dud name, so it'll potentially slow
> stuff down any time you typo. Also, it re-executes the current
> traceback frame, which may or may not be appropriate; it's fine for
> help(re), but not otherwise.
> 
> As an alternative, you could inspect tb.tb_frame.f_code to see if it
> matches "help(x)", and if it does, simply re-execute it with the
> string form of the name:
> 
> exec(tb.tb_frame.f_code, tb.tb_frame.f_globals, {n: n})
> 
> This works because help('re') does the same thing as help(re), so by
> effectively setting re="re", you gain that functionality without
> actually importing into the global namespace.
> 
> Adequately recognizing help(re) without false positives is left as an
> exercise for the reader. :)
> 
> ChrisA

works great :) - okay so you save and replace the default exception 
handler for the interpreter. Then when the procedure is called, check to 
see if type is NameError - if yes, then value contains the error string 
with module name, so you split and extract module name, and import the 
module and map it to a name in the global NS and hey presto (run the old 
code with the modified NS - that's a bit funky)!

Regarding fiddling with the code-object, yep, 
tb.tb_frame.f_code.co_names has a tuple ('h', 're') I suppose that's 
clean because it's your input after all vs splitting on something system 
generated (like an error message) 

works brilliantly - thanks :)
-- 
https://mail.python.org/mailman/listinfo/python-list


<    1   2