Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a7a0d0

Browse files
DOC: Fixes line numbers on classes decorated with set_module (#28629) (#28918)
1 parentb1656d2 commit2a7a0d0

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

‎doc/source/conf.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,14 @@ def linkcode_resolve(domain, info):
544544
fn=None
545545
lineno=None
546546

547-
# Make a poor effort at linking C extension types
548-
ifisinstance(obj,type)andobj.__module__=='numpy':
549-
fn=_get_c_source_file(obj)
547+
ifisinstance(obj,type):
548+
# Make a poor effort at linking C extension types
549+
ifobj.__module__=='numpy':
550+
fn=_get_c_source_file(obj)
550551

551-
# This can be removed when removing the decorator set_module. Fix issue #28629
552-
ifhasattr(obj,'_module_file'):
553-
fn=obj._module_file
554-
fn=relpath(fn,start=dirname(numpy.__file__))
552+
# This can be removed when removing the decorator set_module. Fix issue #28629
553+
ifhasattr(obj,'_module_source'):
554+
obj.__module__,obj._module_source=obj._module_source,obj.__module__
555555

556556
iffnisNone:
557557
try:
@@ -578,6 +578,9 @@ def linkcode_resolve(domain, info):
578578
else:
579579
linespec=""
580580

581+
ifisinstance(obj,type)andhasattr(obj,'_module_source'):
582+
obj.__module__,obj._module_source=obj._module_source,obj.__module__
583+
581584
if'dev'innumpy.__version__:
582585
returnf"https://github.com/numpy/numpy/blob/main/numpy/{fn}{linespec}"
583586
else:

‎numpy/_utils/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"""
1010

1111
importfunctools
12-
importsys
1312
importwarnings
1413

1514
from ._convertionsimportasbytes,asunicode
@@ -30,8 +29,8 @@ def decorator(func):
3029
ifmoduleisnotNone:
3130
ifisinstance(func,type):
3231
try:
33-
func._module_file=sys.modules.get(func.__module__).__file__
34-
except (AttributeError,KeyError):
32+
func._module_source=func.__module__
33+
except (AttributeError):
3534
pass
3635

3736
func.__module__=module

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp