New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py3: import error #27472
Comments
comment:1
I haven't looked at the code yet, but apparently it's generating some code (which it perhaps shouldn't be doing in the first place?) which is deriving a Python module name from the filename by dropping the |
comment:2
I feel like I've fixed some other issues related to this, but I don't recall if this is one of them. |
comment:3
I have this patch floating around in my old python3 branch which might do the trick. I'm going to try it later (no time right this minute): diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
index a231502..db1ef3e 100644
--- a/src/sage/misc/sageinspect.py
+++ b/src/sage/misc/sageinspect.py
@@ -122,11 +122,18 @@ import ast
import inspect
import functools
import os
-import tokenize
import re
+import sys
+import tokenize
EMBEDDED_MODE = False
from sage.env import SAGE_SRC
+try:
+ import importlib.machinery as import_machinery
+except ImportError:
+ pass
+
def loadable_module_extension():
r"""
Return the filename extension of loadable modules, including the dot.
@@ -138,11 +145,17 @@ def loadable_module_extension():
sage: sage.structure.sage_object.__file__.endswith(loadable_module_extension())
True
"""
- import sys
- if sys.platform == 'cygwin':
- return os.path.extsep+'dll'
+
+ if six.PY2:
+ if sys.platform == 'cygwin':
+ return os.path.extsep + 'dll'
+ else:
+ return os.path.extsep + 'so'
else:
- return os.path.extsep+'so'
+ # Return the full platform-specific extension module
+ # extension
+ return import_machinery.EXTENSION_SUFFIXES[0]
+
def isclassinstance(obj):
r""" |
Branch: public/ticket/27472 |
comment:4
I have made a branch from your diff, but not tested yet. New commits:
|
Commit: |
comment:5
Thanks. I will try it out now. I would have yesterday but I was in a rush to get out the door. |
comment:6
I went through your example (is there an existing test that might reproduce this?) and, with this branch, it worked a couple times:
where the "reloading" messages came after me modifying and saving the file. But I tried it a few more times and then (seemingly randomly) got this apparently unrelated problem:
along with the usual message when the interpreter itself crashes. The crash reported ends in:
I think this might be due to a race with my editor and/or filesystem--I was editing in vim which writes changes to a swap file, and then when you save copies the swap file over the actual filename of the file. The actual crash--the |
comment:8
This seems to fix my %attach problem, and the patchbot is green. Please review my last commit. |
Author: Erik Bray, Frédéric Chapoton |
comment:10
green bot, please review |
comment:11
LGTM. |
Reviewer: François Bissey |
Changed branch from public/ticket/27472 to |
This is bug report on python3-build sage.
When attaching a file which loads a pyx file, the reloading fails.
Steps to reproduce:
create a file "test.py" with
and a pyx file with the chosen name.
Then attach the test.py file. This should compile the pyx file.
Then modify a function in the test.py file and save it.
Then one gets an error:
I suspect that maybe the issue is the presence of
-
in the name of the created python module.CC: @embray @jdemeyer @kiwifb @tscrim @vinklein
Component: python3
Author: Erik Bray, Frédéric Chapoton
Branch/Commit:
d29aa5c
Reviewer: François Bissey
Issue created by migration from https://trac.sagemath.org/ticket/27472
The text was updated successfully, but these errors were encountered: