Skip to content

Commit 9e37aeb

Browse files
committed
docs(python-core): add errors/segment-fault & tools/pip/command
1 parent 2920f4a commit 9e37aeb

File tree

13 files changed

+1632
-97
lines changed

13 files changed

+1632
-97
lines changed

.clang-format

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BasedOnStyle: Google
2+
UseTab: Never
3+
IndentWidth: 4
4+
TabWidth: 4
5+
PointerAlignment: Left
6+
DerivePointerAlignment: false
7+
ReflowComments: true
8+
AccessModifierOffset: -4

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!docs/.vuepress/

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rules": {
3+
},
4+
"extends": [
5+
"@antfu"
6+
]
7+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dist-ssr
1515
# Editor directories and files
1616
.vscode/*
1717
!.vscode/extensions.json
18+
!.vscode/settings.json
1819
.idea
1920
.DS_Store
2021
*.suo

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.analysis.typeCheckingMode": "basic"
3+
}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Builder
2-
FROM node:18.16.0-bullseye-slim as builder
2+
FROM node:18.17.0-bullseye-slim as builder
33

44
WORKDIR /app
55

@@ -16,7 +16,7 @@ RUN npm -v \
1616
&& pnpm build
1717

1818
# Nginx Server
19-
FROM nginx:1.24.0-alpine3.17-slim
19+
FROM nginx:nginx:1.25.2-alpine3.18-slim
2020

2121
WORKDIR /usr/share/nginx/html/vuepress-python-notes/
2222

docs/.vuepress/config.ts

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from 'node:process'
22
import { getDirname, path } from '@vuepress/utils'
3-
import { defineUserConfig, defaultTheme } from 'vuepress'
3+
import { defaultTheme, defineUserConfig } from 'vuepress'
44
import { mdEnhancePlugin } from 'vuepress-plugin-md-enhance'
55
import { copyCodePlugin } from 'vuepress-plugin-copy-code2'
66
import { searchProPlugin } from 'vuepress-plugin-search-pro'
@@ -19,12 +19,12 @@ export default defineUserConfig({
1919
title: 'Python 笔记',
2020
description: 'Python 笔记',
2121
head: [
22-
['link', { rel: 'icon', href: `${BASE_PATH}favicon.svg` }]
22+
['link', { rel: 'icon', href: `${BASE_PATH}favicon.svg` }],
2323
],
2424
base: BASE_PATH,
2525
markdown: {
2626
code: {
27-
lineNumbers: 10
27+
lineNumbers: 10,
2828
},
2929
importCode: {
3030
handleImportPath: str => str
@@ -71,7 +71,7 @@ export default defineUserConfig({
7171
card: true,
7272
codetabs: true,
7373
include: {
74-
resolvePath: file => {
74+
resolvePath: (file) => {
7575
if (file.startsWith('@'))
7676
return file.replace('@', CURRENT_PATH)
7777
if (file.startsWith('/'))
@@ -96,45 +96,54 @@ export default defineUserConfig({
9696
{
9797
matcher: '@def',
9898
replacer: ({ tag }) => {
99-
if (tag === 'em') return {
100-
tag: 'Badge',
101-
attrs: { type: 'tip' },
102-
content: '定义'
99+
if (tag === 'em') {
100+
return {
101+
tag: 'Badge',
102+
attrs: { type: 'tip' },
103+
content: '定义',
104+
}
103105
}
104-
}
106+
},
105107
},
106108
{
107109
matcher: /@3.[0-9]+\+/,
108110
replacer: ({ tag, content }) => {
109-
if (tag === 'em') return {
110-
tag: 'Badge',
111-
attrs: { type: 'tip' },
112-
content: content.replace('@', '')
111+
if (tag === 'em') {
112+
return {
113+
tag: 'Badge',
114+
attrs: { type: 'tip' },
115+
content: content.replace('@', ''),
116+
}
113117
}
114-
}
118+
},
115119
},
116120
{
117121
matcher: '@TODO',
118122
replacer: ({ tag }) => {
119-
if (tag === 'em') return {
120-
tag: 'Badge',
121-
attrs: { type: 'danger' },
122-
content: 'TODO'
123+
if (tag === 'em') {
124+
return {
125+
tag: 'Badge',
126+
attrs: { type: 'danger' },
127+
content: 'TODO',
128+
}
123129
}
124-
}
125-
}
126-
]
130+
},
131+
},
132+
],
127133
}, false),
128134
searchProPlugin({}),
129135
autoCatalogPlugin({
130136
orderGetter: ({ title, routeMeta }) => {
131-
if (routeMeta.order) return routeMeta.order as number
137+
if (routeMeta.order)
138+
return routeMeta.order as number
132139
const prefix = title.match(/^\d+. /)
133-
if (prefix) return parseInt(prefix[0])
140+
if (prefix)
141+
return Number.parseInt(prefix[0])
134142
const suffix = title.match(/\d+$/)
135-
if (suffix) return parseInt(suffix[0])
143+
if (suffix)
144+
return Number.parseInt(suffix[0])
136145
return 0
137-
}
146+
},
138147
}),
139148
copyCodePlugin({
140149
showInMobile: true,

docs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ footer: Python 笔记合集,由 @Sun-ZhenXing 创建
1414
# Python 笔记合集
1515

1616
<AutoCatalog />
17+
18+
::: warning TODO
19+
20+
- [ ] 使用 `TypedDict` 构造类型字典
21+
- [ ] 如何构建像 SymPy 一样的代数系统
22+
- [ ] 从零构建 JS 逆向工具,通过网站验签
23+
- [ ] PySide6: 添加笔记:Tree/Table 扩展最后一行/列
24+
- [ ] Celery:Python 异步任务调度
25+
- [ ] Rocketry:Python 下的轻量调度框架
26+
27+
:::

docs/mixed-programming/c-cpp-mixed/src/sample.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ int in_mandel(double x0, double y0, int n) {
2020
y = 2 * x * y + y0;
2121
x = xtemp;
2222
n -= 1;
23-
if (x * x + y * y > 4)
24-
return 0;
23+
if (x * x + y * y > 4) return 0;
2524
}
2625
return 1;
2726
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Python 如何查找 Segment Fault(段错误)
2+
3+
[[TOC]]
4+
5+
## 1. Python 调试选项
6+
7+
问题背景:在开发 PySide6 程序时出现了闪退错误,Windows 上不显示任何内容崩溃,Mac 上出现段错误(内容已转储)。常规调试器无法得出错误出现的位置,因为出错的位置不是在 Python 解释器执行时出现的。
8+
9+
通过下面的方法成功定位到问题,发现是线程中调用了 UI 功能导致的。PySide6 要求线程想修改或读取 UI 控件的内容必须借助信号通信。
10+
11+
在执行 Python 时加上 `-X faulthandler` 选项,可以在程序出现 Segment Fault 时打印出调用栈。
12+
13+
```bash
14+
python -X faulthandler test.py
15+
```

0 commit comments

Comments
 (0)