Re: [Cython] [cython-users] Confusing error when trying to get non-existent attribute of cimported library

2015-08-12 Thread Robert Bradshaw
On Tue, Aug 11, 2015 at 9:10 PM, Antony Lee  wrote:
> Compiling and running
>
> from libc cimport math
> def f():
> print(math.abs(-1)) # oops, should be fabs
>
> results in NameError, name 'math' is not defined.  I guess that this results
> from the fact that cimported names and other names effectively live in
> different namespaces, but this is a bit confusing.

Agreed, this confusing.

We do want to support

from libc cimport math
import math

math.somthing_that_only_exists_in_the_python_module()

I'm not sure we need to support

from libc cimport math
globals()['math'] = whatever
math.somthing_that_only_exists_in_whatever

We've long wanted to restrict arbitrary writes to a Cython module's
global namespace... and of course such writes already aren't respected
by compile-time bindings, so is anyone opposed to making this an
error?

- Robert
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


[Cython] Cython Modules as builtins

2015-08-12 Thread Phil Thompson
Is there any reason why cython generated modules don’t use the fully qualified 
name (ie. __Pyx_MODULE_NAME) in the call to Py_InitModule4() and the 
PyModuleDef structure? I want to statically link a module and add it to 
Python’s inittab but things don’t work without a fully qualified name.

Thanks,
Phil
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel